def test_to_json_data(self): rep = "John Don" lawyers = ["Alex Kesley", "Richard Thaler"] p = Person("John Co. Ltd", representative=rep, lawyers=lawyers) data = p.to_json_data() expected = {'lawyers': lawyers, 'name': 'John Co. Ltd', 'rep': 'John Don'} for key in expected: self.assertEqual(expected[key], data[key])
def test_name_getter_setter(self): rep = "John Don" p = Person("John Co. Ltd", representative=rep) self.assertEqual(rep, p.get_representative()) self.assertTrue(len(p.get_lawyers()) == 0) lawyers = ["Alex", "Mary"] q = Person("Bob", representative=None, lawyers=lawyers) self.assertTrue("Alex" in q.get_lawyers()) self.assertTrue("" == q.get_representative())