initial commit

This commit is contained in:
2021-07-28 02:15:48 +03:00
commit 735633853a
6607 changed files with 1084121 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
from hypothesis import given
from hypothesis.extra import django
from server.apps.main.models import BlogPost
class TestBlogPost(django.TestCase):
"""This is a property-based test that ensures model correctness."""
@given(django.from_model(BlogPost))
def test_model_properties(self, instance: BlogPost) -> None:
"""Tests that instance can be saved and has correct representation."""
instance.save()
assert instance.id > 0
assert len(str(instance)) <= 20

View File

@@ -0,0 +1,17 @@
import pytest
from django_test_migrations.migrator import Migrator
from server.apps.main.urls import app_name
def test_initial0001(migrator: Migrator) -> None:
"""Tests the initial migration forward application."""
old_state = migrator.apply_initial_migration((app_name, None))
with pytest.raises(LookupError):
# This model does not exist before this migration:
old_state.apps.get_model(app_name, 'BlogPost')
new_state = migrator.apply_tested_migration((app_name, '0001_initial'))
model = new_state.apps.get_model(app_name, 'BlogPost')
assert model.objects.create(title='test', body='some body')