|
1 | | -from proxy import Proxy |
| 1 | +from proxy import Proxy, NoTalkProxy |
2 | 2 | from io import StringIO |
3 | 3 | import sys |
4 | 4 |
|
@@ -41,5 +41,39 @@ def test_sales_manager_shall_respond_through_proxy(self): |
41 | 41 | Sales Manager is busy\n' |
42 | 42 | self.assertEqual(print_output, expected_print_output) |
43 | 43 |
|
| 44 | +class NoTalkProxyTest(unittest.TestCase): |
| 45 | + |
| 46 | + @classmethod |
| 47 | + def setUpClass(self): |
| 48 | + """ Class scope setup. """ |
| 49 | + self.ntp = NoTalkProxy() |
| 50 | + |
| 51 | + def setUp(self): |
| 52 | + """ Function/test case scope setup. """ |
| 53 | + self.output = StringIO() |
| 54 | + self.saved_stdout = sys.stdout |
| 55 | + sys.stdout = self.output |
| 56 | + |
| 57 | + def tearDown(self): |
| 58 | + """ Function/test case scope teardown. """ |
| 59 | + self.output.close() |
| 60 | + sys.stdout = self.saved_stdout |
| 61 | + |
| 62 | + def test_sales_manager_shall_not_work_through_proxy(self): |
| 63 | + self.ntp.busy = 'No' |
| 64 | + self.ntp.work() |
| 65 | + print_output = self.output.getvalue() |
| 66 | + expected_print_output = 'Proxy checking for Sales Manager availability\n\ |
| 67 | +This Sales Manager will not talk to you whether he/she is busy or not\n' |
| 68 | + self.assertEqual(print_output, expected_print_output) |
| 69 | + |
| 70 | + def test_sales_manager_shall_not_respond_through_proxy(self): |
| 71 | + self.ntp.busy = 'Yes' |
| 72 | + self.ntp.work() |
| 73 | + print_output = self.output.getvalue() |
| 74 | + expected_print_output = 'Proxy checking for Sales Manager availability\n\ |
| 75 | +This Sales Manager will not talk to you whether he/she is busy or not\n' |
| 76 | + self.assertEqual(print_output, expected_print_output) |
| 77 | + |
44 | 78 | if __name__ == "__main__": |
45 | 79 | unittest.main() |
0 commit comments