예제 #1
0
 def test_get_description(self):
     """
     Calling the get_description method should return a non-empty string.
     """
     whoami = WhoAmI(None, None)
     result = whoami.get_description()
     self.assertIsInstance(result, str)
     self.assertTrue(len(result) > 0)
예제 #2
0
 def test_take_action(self):
     """
     Ensure that the take_action method interrogates the user in the
     expected way and produces an appropriate JSON file in the expected
     location containing the expected result.
     """
     with mock.patch('builtins.input', return_value='y'):
         whoami = WhoAmI(None, None)
         with mock.patch('json.dump') as writer:
             whoami.take_action([])
             self.assertEqual(1, writer.call_count)
             output_file = os.path.join(data_dir(), 'whoami.json')
             self.assertEqual(writer.call_args[0][1].name, output_file)