|
1 | 1 | """Tests for main.py.""" |
2 | | -#pylint: disable=import-error, wrong-import-position, unused-argument, line-too-long |
| 2 | +# pylint: disable=import-error, wrong-import-position, unused-argument, line-too-long |
3 | 3 |
|
4 | 4 | import sys |
5 | 5 | import os |
|
10 | 10 | import main |
11 | 11 |
|
12 | 12 |
|
13 | | -@patch('builtins.input', side_effect=["newpiece", "Brick", "Red", "5"]) |
14 | | -@patch('builtins.print') |
| 13 | +@patch("builtins.input", side_effect=["newpiece", "Brick", "Red", "5"]) |
| 14 | +@patch("builtins.print") |
15 | 15 | def test_lego_cmd_newpiece(self, mock_print): |
16 | 16 | """Test the newpiece command.""" |
17 | 17 | main.lego_cmd() |
18 | | - mock_print.assert_has_calls([ |
19 | | - call('LEGO CMD: '), |
20 | | - call('Name the piece you would like to add: '), |
21 | | - call('What is the piece colour (make sure this colour is in the colour database, otherwise add using "newcolour")? '), |
22 | | - call('How many of that would you like to add? ') |
23 | | - ]) |
24 | | - |
25 | | - |
26 | | -@patch('builtins.input', side_effect=["newcolour", "Red"]) |
27 | | -@patch('builtins.print') |
| 18 | + mock_print.assert_has_calls( |
| 19 | + [ |
| 20 | + call("LEGO CMD: "), |
| 21 | + call("Name the piece you would like to add: "), |
| 22 | + call( |
| 23 | + 'What is the piece colour (make sure this colour is in the colour database, otherwise add using "newcolour")? ' |
| 24 | + ), |
| 25 | + call("How many of that would you like to add? "), |
| 26 | + ] |
| 27 | + ) |
| 28 | + |
| 29 | + |
| 30 | +@patch("builtins.input", side_effect=["newcolour", "Red"]) |
| 31 | +@patch("builtins.print") |
28 | 32 | def test_lego_cmd_newcolour(self, mock_print): |
29 | 33 | """Test the newcolour command.""" |
30 | 34 | main.lego_cmd() |
31 | | - mock_print.assert_has_calls([ |
32 | | - call('LEGO CMD: '), |
33 | | - call('Name the colour you would like to add: '), |
34 | | -]) |
| 35 | + mock_print.assert_has_calls( |
| 36 | + [ |
| 37 | + call("LEGO CMD: "), |
| 38 | + call("Name the colour you would like to add: "), |
| 39 | + ] |
| 40 | + ) |
35 | 41 |
|
36 | 42 |
|
37 | | -@patch('builtins.input', side_effect=["newcolor", "Red"]) |
38 | | -@patch('builtins.print') |
| 43 | +@patch("builtins.input", side_effect=["newcolor", "Red"]) |
| 44 | +@patch("builtins.print") |
39 | 45 | def test_lego_cmd_newcolor(self, mock_print): |
40 | 46 | """Test the newcolor command.""" |
41 | 47 | main.lego_cmd() |
42 | | - mock_print.assert_has_calls([ |
43 | | - call('LEGO CMD: '), |
44 | | - call('Name the color you would like to add: '), |
45 | | -]) |
| 48 | + mock_print.assert_has_calls( |
| 49 | + [ |
| 50 | + call("LEGO CMD: "), |
| 51 | + call("Name the color you would like to add: "), |
| 52 | + ] |
| 53 | + ) |
46 | 54 |
|
47 | 55 |
|
48 | | -@patch('builtins.input', side_effect=["addpiece", "Brick", "Red", "5"]) |
49 | | -@patch('builtins.print') |
| 56 | +@patch("builtins.input", side_effect=["addpiece", "Brick", "Red", "5"]) |
| 57 | +@patch("builtins.print") |
50 | 58 | def test_lego_cmd_addpiece(self, mock_print): |
51 | 59 | """Test the addpiece command.""" |
52 | 60 | main.lego_cmd() |
53 | | - mock_print.assert_has_calls([ |
54 | | - call('LEGO CMD: '), |
55 | | - call('What is the name of the piece that you would like to add to? '), |
56 | | - call('What is the piece colour? '), |
57 | | - call('How many of that piece do you want to add? ') |
58 | | -]) |
59 | | - |
60 | | - |
61 | | -@patch('builtins.input', side_effect=["removepiece", "Brick", "Red", "5"]) |
62 | | -@patch('builtins.print') |
| 61 | + mock_print.assert_has_calls( |
| 62 | + [ |
| 63 | + call("LEGO CMD: "), |
| 64 | + call("What is the name of the piece that you would like to add to? "), |
| 65 | + call("What is the piece colour? "), |
| 66 | + call("How many of that piece do you want to add? "), |
| 67 | + ] |
| 68 | + ) |
| 69 | + |
| 70 | + |
| 71 | +@patch("builtins.input", side_effect=["removepiece", "Brick", "Red", "5"]) |
| 72 | +@patch("builtins.print") |
63 | 73 | def test_lego_cmd_removepiece(self, mock_print): |
64 | 74 | """Test the removepiece command.""" |
65 | 75 | main.lego_cmd() |
66 | | - mock_print.assert_has_calls([ |
67 | | - call('LEGO CMD: '), |
68 | | - call('What is the name of the piece that you would like to remove? '), |
69 | | - call('What is the piece colour? '), |
70 | | - call('How many of that piece do you want to remove? ') |
71 | | -]) |
72 | | - |
73 | | - |
74 | | -@patch('builtins.input', side_effect=["newset", "Police Station", "123456", "City", "100", "5"]) |
75 | | -@patch('builtins.print') |
| 76 | + mock_print.assert_has_calls( |
| 77 | + [ |
| 78 | + call("LEGO CMD: "), |
| 79 | + call("What is the name of the piece that you would like to remove? "), |
| 80 | + call("What is the piece colour? "), |
| 81 | + call("How many of that piece do you want to remove? "), |
| 82 | + ] |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +@patch( |
| 87 | + "builtins.input", |
| 88 | + side_effect=["newset", "Police Station", "123456", "City", "100", "5"], |
| 89 | +) |
| 90 | +@patch("builtins.print") |
76 | 91 | def test_lego_cmd_newset(self, mock_print): |
77 | 92 | """Test the newset command.""" |
78 | 93 | main.lego_cmd() |
79 | | - mock_print.assert_has_calls([ |
80 | | - call('LEGO CMD: '), |
81 | | - call('Name the set you would like to add: '), |
82 | | - call('What is the set number for the set you would like to add? '), |
83 | | - call('What is the theme for the set you would like to add? \ |
| 94 | + mock_print.assert_has_calls( |
| 95 | + [ |
| 96 | + call("LEGO CMD: "), |
| 97 | + call("Name the set you would like to add: "), |
| 98 | + call("What is the set number for the set you would like to add? "), |
| 99 | + call( |
| 100 | + 'What is the theme for the set you would like to add? \ |
84 | 101 | (make sure this theme is in the database, \ |
85 | | - otherwise add using "newtheme") '), |
86 | | - call('How many pieces are there in this set? '), |
87 | | - call('How many of this set would you like to add? ') |
88 | | -]) |
| 102 | + otherwise add using "newtheme") ' |
| 103 | + ), |
| 104 | + call("How many pieces are there in this set? "), |
| 105 | + call("How many of this set would you like to add? "), |
| 106 | + ] |
| 107 | + ) |
89 | 108 |
|
90 | 109 |
|
91 | | -@patch('builtins.input', side_effect=["newtheme", "City"]) |
92 | | -@patch('builtins.print') |
| 110 | +@patch("builtins.input", side_effect=["newtheme", "City"]) |
| 111 | +@patch("builtins.print") |
93 | 112 | def test_lego_cmd_newtheme(self, mock_print): |
94 | 113 | """Test the newtheme command.""" |
95 | 114 | main.lego_cmd() |
96 | | - mock_print.assert_has_calls([ |
97 | | - call('LEGO CMD: '), |
98 | | - call('Name the theme you would like to add: '), |
99 | | -]) |
| 115 | + mock_print.assert_has_calls( |
| 116 | + [ |
| 117 | + call("LEGO CMD: "), |
| 118 | + call("Name the theme you would like to add: "), |
| 119 | + ] |
| 120 | + ) |
100 | 121 |
|
101 | 122 |
|
102 | | -@patch('builtins.input', side_effect=["addset", "123456", "5"]) |
103 | | -@patch('builtins.print') |
| 123 | +@patch("builtins.input", side_effect=["addset", "123456", "5"]) |
| 124 | +@patch("builtins.print") |
104 | 125 | def test_lego_cmd_addset(self, mock_print): |
105 | 126 | """Test the addset command.""" |
106 | 127 | main.lego_cmd() |
107 | | - mock_print.assert_has_calls([ |
108 | | - call('LEGO CMD: '), |
109 | | - call('What is the set number of the set that you would like to add? '), |
110 | | - call('How many of that set do you want to add? ') |
111 | | -]) |
| 128 | + mock_print.assert_has_calls( |
| 129 | + [ |
| 130 | + call("LEGO CMD: "), |
| 131 | + call("What is the set number of the set that you would like to add? "), |
| 132 | + call("How many of that set do you want to add? "), |
| 133 | + ] |
| 134 | + ) |
112 | 135 |
|
113 | 136 |
|
114 | | -@patch('builtins.input', side_effect=["removeset", "123456", "5"]) |
115 | | -@patch('builtins.print') |
| 137 | +@patch("builtins.input", side_effect=["removeset", "123456", "5"]) |
| 138 | +@patch("builtins.print") |
116 | 139 | def test_lego_cmd_removeset(self, mock_print): |
117 | 140 | """Test the removeset command.""" |
118 | 141 | main.lego_cmd() |
119 | | - mock_print.assert_has_calls([ |
120 | | - call('LEGO CMD: '), |
121 | | - call('What is the set number of the set that you would like to remove? '), |
122 | | - call('How many of that set do you want to remove? ') |
123 | | -]) |
| 142 | + mock_print.assert_has_calls( |
| 143 | + [ |
| 144 | + call("LEGO CMD: "), |
| 145 | + call("What is the set number of the set that you would like to remove? "), |
| 146 | + call("How many of that set do you want to remove? "), |
| 147 | + ] |
| 148 | + ) |
0 commit comments