Ejemplo n.º 1
0
def test_dataset_without_resolvable_model_name():
    class UnknownData(DataSet):
        class foo:
            foo = 1

    fixture = DjangoFixture(style=NamedDataStyle())
    ds = UnknownData()
    fixture.attach_storage_medium(ds)
Ejemplo n.º 2
0
    def test_fixture_load(self):
        for model in get_models(models):
            assert 0 == model.objects.count()

        dj_fixture = DjangoFixture()
        with dj_fixture.data(AuthorData, BookData):
            assert models.Author.objects.get(first_name='Frank').books.count() == 1

        for model in get_models(models):
            assert 0 == model.objects.count()
Ejemplo n.º 3
0
def test_dataset_with_malformed_model_name():
    class SomeDataset(DataSet):
        class Meta:
            django_model = "not_dot_separated_model_name"

        class foo:
            foo = 1

    fixture = DjangoFixture()
    ds = SomeDataset()
    fixture.attach_storage_medium(ds)
Ejemplo n.º 4
0
def test_model_lookup_by_qualified_model_name():
    class SomeDataset(DataSet):
        class Meta:
            django_model = "blog.Post"

        class foo:
            foo = 1

    fixture = DjangoFixture()
    ds = SomeDataset()
    fixture.attach_storage_medium(ds)
    assert_equal(ds.meta.storage_medium.medium, Post)
Ejemplo n.º 5
0
def test_model_lookup_by_app_label_and_style_derived_name():
    class PostData(DataSet):
        class Meta:
            django_app_label = "blog"

        class foo:
            foo = 1

    fixture = DjangoFixture(style=NamedDataStyle())
    ds = PostData()
    fixture.attach_storage_medium(ds)
    assert_equal(ds.meta.storage_medium.medium, Post)
Ejemplo n.º 6
0
def test_model_lookup_by_app_label_and_style_derived_name():
    
    class PostData(DataSet):
        class Meta:
            django_app_label = "blog"
        class foo:
            foo = 1
    
    fixture = DjangoFixture(style=NamedDataStyle())
    ds = PostData()
    fixture.attach_storage_medium(ds)
    assert_equal(ds.meta.storage_medium.medium, Post)
Ejemplo n.º 7
0
def test_model_lookup_by_explicit_app_label_and_name():
    class SomeDataset(DataSet):
        class Meta:
            django_app_label = "blog"
            storable_name = "Post"

        class foo:
            foo = 1

    fixture = DjangoFixture()
    ds = SomeDataset()
    fixture.attach_storage_medium(ds)
    assert_equal(ds.meta.storage_medium.medium, Post)
Ejemplo n.º 8
0
def test_model_lookup_by_explicit_app_label_and_name():
    
    class SomeDataset(DataSet):
        class Meta:
            django_app_label = "blog"
            storable_name = "Post"
        class foo:
            foo = 1
    
    fixture = DjangoFixture()
    ds = SomeDataset()
    fixture.attach_storage_medium(ds)
    assert_equal(ds.meta.storage_medium.medium, Post)