33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from django.test import TestCase
|
|
from django.urls import reverse
|
|
|
|
from .models import Article, Topic
|
|
|
|
|
|
class NewsroomFlowTests(TestCase):
|
|
def setUp(self):
|
|
self.topic = Topic.objects.create(name='Artificial Intelligence', slug='artificial-intelligence', accent_color='#00c2a8')
|
|
|
|
def test_home_page_renders(self):
|
|
response = self.client.get(reverse('home'))
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertContains(response, 'Signal')
|
|
|
|
def test_submit_flow_creates_original_article(self):
|
|
response = self.client.post(
|
|
reverse('article_submit'),
|
|
{
|
|
'title': 'Why startup teams need faster AI evaluation loops',
|
|
'topic': self.topic.pk,
|
|
'author_name': 'Editorial Desk',
|
|
'excerpt': 'A crisp summary explaining why the speed of model testing is now a product advantage.',
|
|
'content': 'This is a long enough editorial body to satisfy validation. ' * 4,
|
|
'is_featured': 'on',
|
|
},
|
|
follow=True,
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|
|
article = Article.objects.get(title='Why startup teams need faster AI evaluation loops')
|
|
self.assertContains(response, 'Your story is now live.')
|
|
self.assertEqual(article.article_kind, Article.ArticleKind.ORIGINAL)
|