Esempio n. 1
0
    def test_creation_and_hydration(self):
        name = random_str()
        description = random_str()
        rmd_1 = RegisteredModel(name, 1, 2, description, [])
        self._check(rmd_1, name, 1, 2, description, [])

        as_dict = {
            "name": name,
            "creation_timestamp": 1,
            "last_updated_timestamp": 2,
            "description": description,
            "latest_versions": []
        }
        self.assertEqual(dict(rmd_1), as_dict)

        proto = rmd_1.to_proto()
        self.assertEqual(proto.name, name)
        self.assertEqual(proto.creation_timestamp, 1)
        self.assertEqual(proto.last_updated_timestamp, 2)
        self.assertEqual(proto.description, description)
        rmd_2 = RegisteredModel.from_proto(proto)
        self._check(rmd_2, name, 1, 2, description, [])

        rmd_3 = RegisteredModel.from_dictionary(as_dict)
        self._check(rmd_3, name, 1, 2, description, [])
Esempio n. 2
0
    def test_creation_and_hydration(self):
        name = random_str()
        registered_model = RegisteredModel(name)
        self._check(registered_model, name)

        as_dict = {"name": name}
        self.assertEqual(dict(registered_model), as_dict)

        proto = registered_model.to_proto()
        self.assertEqual(proto.name, name)
        registered_model2 = RegisteredModel.from_proto(proto)
        self._check(registered_model2, name)

        registered_model3 = RegisteredModel.from_dictionary(as_dict)
        self._check(registered_model3, name)