|
19 | 19 |
|
20 | 20 | from selenium.webdriver.common.print_page_options import PrintOptions
|
21 | 21 |
|
| 22 | + |
22 | 23 | @pytest.fixture
|
23 | 24 | def print_options():
|
24 | 25 | return PrintOptions()
|
25 | 26 |
|
| 27 | + |
26 | 28 | def test_set_orientation(print_options):
|
27 | 29 | print_options.orientation = 'portrait'
|
28 | 30 | assert print_options.orientation == 'portrait'
|
29 | 31 |
|
| 32 | + |
30 | 33 | def test_raises_exception_if_orientation_is_invalid(print_options):
|
31 | 34 | with pytest.raises(ValueError):
|
32 | 35 | print_options.orientation = 'foobar'
|
33 | 36 |
|
| 37 | + |
34 | 38 | def test_set_scale(print_options):
|
35 | 39 | print_options.scale = 1
|
36 | 40 | assert print_options.scale == 1
|
37 | 41 |
|
| 42 | + |
38 | 43 | def test_raises_exception_if_scale_is_outside_range(print_options):
|
39 | 44 | with pytest.raises(ValueError):
|
40 | 45 | print_options.scale = 3
|
41 | 46 |
|
| 47 | + |
42 | 48 | def test_raises_exception_if_scale_is_not_an_integer(print_options):
|
43 | 49 | with pytest.raises(ValueError):
|
44 | 50 | print_options.scale = "1"
|
45 | 51 |
|
| 52 | + |
46 | 53 | def test_set_background(print_options):
|
47 | 54 | print_options.background = True
|
48 | 55 | assert print_options.background is True
|
49 | 56 |
|
| 57 | + |
50 | 58 | def test_unset_value_to_be_none(print_options):
|
51 | 59 | assert print_options.page_width is None
|
52 | 60 |
|
| 61 | + |
53 | 62 | def test_set_width(print_options):
|
54 | 63 | print_options.page_width = 3
|
55 | 64 | assert print_options.page_width == 3
|
56 | 65 |
|
| 66 | + |
57 | 67 | def test_raises_exception_if_set_invalid_width(print_options):
|
58 | 68 | with pytest.raises(ValueError):
|
59 | 69 | print_options.page_width = -1
|
60 | 70 |
|
| 71 | + |
61 | 72 | def test_raises_exception_if_set_with_not_int(print_options):
|
62 | 73 | with pytest.raises(ValueError):
|
63 | 74 | print_options.page_width = "2"
|
64 | 75 |
|
| 76 | + |
65 | 77 | def test_set_height(print_options):
|
66 | 78 | print_options.page_height = 2
|
67 | 79 | assert print_options.page_height == 2
|
68 | 80 |
|
| 81 | + |
69 | 82 | def test_set_shrink_to_fit(print_options):
|
70 | 83 | print_options.shrink_to_fit = True
|
71 | 84 | assert print_options.shrink_to_fit is True
|
72 | 85 |
|
| 86 | + |
73 | 87 | def test_raises_exception_if_set_shrink_to_fit_non_bool(print_options):
|
74 | 88 | with pytest.raises(ValueError):
|
75 | 89 | print_options.shrink_to_fit = 'True'
|
76 | 90 |
|
| 91 | + |
77 | 92 | def test_set_page_ranges(print_options):
|
78 | 93 | print_options.page_ranges = ['1-2']
|
79 | 94 | assert print_options.page_ranges == ['1-2']
|
80 | 95 |
|
| 96 | + |
81 | 97 | def test_raises_exception_if_page_ranges_not_list(print_options):
|
82 | 98 | with pytest.raises(ValueError):
|
83 | 99 | print_options.page_ranges = 'foobar'
|
84 | 100 |
|
| 101 | + |
85 | 102 | def test_margin_height(print_options):
|
86 | 103 | print_options.margin_top = 2
|
87 | 104 | assert print_options.margin_top == 2
|
88 | 105 |
|
| 106 | + |
89 | 107 | def test_raises_exception_if_margin_is_invalid(print_options):
|
90 | 108 | with pytest.raises(ValueError):
|
91 | 109 | print_options.margin_top = -1
|
|
0 commit comments