def test_invalid(self): """ Initializing the Identity object with a dictionary with missing values or with anything else should raise TypeError. """ dicts = [{}, {"org_id": "some org id"}, "some string", ["some", "list"]] for dict_ in dicts: with self.assertRaises(TypeError): from_dict(dict_)
def test_valid(self): """ Initialize the Identity object with a valid dictionary. """ identity = self._identity() dict_ = { "account_number": identity.account_number, "internal": {"org_id": "some org id", "extra_field": "extra value"}, } self.assertEqual(identity, from_dict(dict_))