def testPythonSpecific(self): dct = { "__class__": "foobar", } pw_entry = http_api.FlatDictToRDFValue(dct, rdf_client.PwEntry) self.assertEqual(pw_entry.__class__, rdf_client.PwEntry)
def testWrongType(self): dct = { "uid": "foobar", } with self.assertRaisesRegex(ValueError, "foobar"): http_api.FlatDictToRDFValue(dct, rdf_client.User)
def testNonExistingField(self): dct = { "some_non_existing_field": "foobar", } pw_entry = http_api.FlatDictToRDFValue(dct, rdf_client.PwEntry) self.assertFalse(hasattr(pw_entry, "some_non_existing_field"))
def testEnum(self): dct = { "hash_type": "MD5", } pw_entry = http_api.FlatDictToRDFValue(dct, rdf_client.PwEntry) self.assertEqual(pw_entry.hash_type, rdf_client.PwEntry.PwHash.MD5)
def testNested(self): dct = { "pw_entry.age": "1337", } user = http_api.FlatDictToRDFValue(dct, rdf_client.User) self.assertEqual(user.pw_entry.age, 1337)
def testSimple(self): dct = { "username": "******", "uid": "42", } user = http_api.FlatDictToRDFValue(dct, rdf_client.User) self.assertEqual(user.username, "foo") self.assertEqual(user.uid, 42)