Ejemplo n.º 1
0
    def testPythonSpecific(self):
        dct = {
            "__class__": "foobar",
        }

        pw_entry = http_api.FlatDictToRDFValue(dct, rdf_client.PwEntry)
        self.assertEqual(pw_entry.__class__, rdf_client.PwEntry)
Ejemplo n.º 2
0
    def testWrongType(self):
        dct = {
            "uid": "foobar",
        }

        with self.assertRaisesRegex(ValueError, "foobar"):
            http_api.FlatDictToRDFValue(dct, rdf_client.User)
Ejemplo n.º 3
0
    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"))
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    def testNested(self):
        dct = {
            "pw_entry.age": "1337",
        }

        user = http_api.FlatDictToRDFValue(dct, rdf_client.User)
        self.assertEqual(user.pw_entry.age, 1337)
Ejemplo n.º 6
0
  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)