Exemplo n.º 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
     })
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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