mirror of
https://github.com/Balshgit/public.git
synced 2025-12-18 04:40:41 +03:00
github stars project celery-rabbit
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')
|
||||
@@ -0,0 +1,18 @@
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
def test_main_page(client: Client, main_heading: str) -> None:
|
||||
"""This test ensures that main page works."""
|
||||
response = client.get('/')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert main_heading in str(response.content)
|
||||
|
||||
|
||||
def test_hello_page(client: Client, main_heading: str) -> None:
|
||||
"""This test ensures that hello page works."""
|
||||
response = client.get(reverse('main:hello'))
|
||||
|
||||
assert response.status_code == 200
|
||||
assert main_heading in str(response.content)
|
||||
Reference in New Issue
Block a user