Beispiel #1
0
    def test_foreign_key_inverse(self):
        identifier = factories.WorkIdentifierFactory()

        assert models.WorkIdentifier.objects.count() == 1
        assert models.AbstractCreativeWork.objects.count() == 1
        assert models.WorkIdentifierVersion.objects.count() == 1
        assert models.AbstractCreativeWorkVersion.objects.count() == 1

        identifier.creative_work.delete()

        assert models.WorkIdentifier.objects.count() == 0
        assert models.AbstractCreativeWork.objects.count() == 0
        assert models.WorkIdentifierVersion.objects.count() == 0
        assert models.AbstractCreativeWorkVersion.objects.count() == 0
Beispiel #2
0
    def test_foreign_key(self):
        identifier = factories.WorkIdentifierFactory()

        assert models.WorkIdentifier.objects.exclude(id=None).count() == 1
        assert models.AbstractCreativeWork.objects.exclude(
            id=None).count() == 1
        assert models.WorkIdentifierVersion.objects.exclude(
            id=None).count() == 1
        assert models.AbstractCreativeWorkVersion.objects.exclude(
            id=None).count() == 1

        identifier.delete()

        assert models.WorkIdentifier.objects.exclude(id=None).count() == 0
        assert models.AbstractCreativeWork.objects.exclude(
            id=None).count() == 1
        assert models.WorkIdentifierVersion.objects.exclude(
            id=None).count() == 0
        assert models.AbstractCreativeWorkVersion.objects.exclude(
            id=None).count() == 1