示例#1
0
 def test_contact_from_json_requires_tags_key(self):
     with self.assertRaises(ValueError):
         Contact.from_json({"wrongkey": [], "name": "Asriel"})
示例#2
0
 def test_contact_from_json_requires_dict(self):
     with self.assertRaises(TypeError):
         Contact.from_json("some string")
示例#3
0
 def test_contact_from_json_requires_name_key(self):
     with self.assertRaises(ValueError):
         Contact.from_json({"wrongkey": "Lord Asriel", "tags": []})
示例#4
0
 def test_can_make_contact_from_json(self):
     json = {"name": "Lord Asriel", "tags": ["aaa", "ddd", "zzz"]}
     contact = Contact.from_json(json)
     self.assertIsInstance(contact, Contact)
     self.assertEqual(contact._name, "Lord Asriel")
     self.assertEqual(contact._tags, set(["aaa", "ddd", "zzz"]))