예제 #1
0
 def instantiate_model(self, model_name, model_id, name="Default"):
     return ModelRegistry.get_model(model_name)._set_data({
         "id":
         model_id,
         "name":
         name
     })
예제 #2
0
 def instantiate_model(self, model_name, model_id, name="Default"):
     models = []
     for i in range(3):
         models.append(
             ModelRegistry.get_model(model_name)._set_data({
                 "id":
                 model_id,
                 "name":
                 name
             }))
     return models
예제 #3
0
    def test_model_registry(self):
        class TestBase(SchemaModel):
            pass

        assert "SchemaModel" not in ModelRegistry.models, (
            "There should be no models for the "
            "first base class of SchemaModel")

        num = len(ModelRegistry.models)

        class MyFirstModel(TestBase):
            pass

        class MySecondModel(TestBase):
            pass

        assert (len(ModelRegistry.models) == num +
                2), "There should be 2 models registered"

        assert ModelRegistry.get_model("MyFirstModel") is MyFirstModel
        assert ModelRegistry.get_model("MySecondModel") is MySecondModel
예제 #4
0
 def test_relationship_dump_with_only(self, base, Author, Publisher,
                                      Company, model, only, expected):
     instance = ModelRegistry.get_model(model)()
     assert instance.dump(only=only) == expected
예제 #5
0
 def test_nested_dump_with_include(self, base, Author, Publisher, Company,
                                   model, include, expected):
     instance = ModelRegistry.get_model(model)()
     assert instance.dump(include=include) == expected