mirror of
https://github.com/Balshgit/public.git
synced 2026-02-04 10:00:39 +03:00
initial commit
This commit is contained in:
@@ -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
|
||||
@@ -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')
|
||||
Reference in New Issue
Block a user