fix test and news type

This commit is contained in:
alex 2019-12-23 15:39:54 +03:00
parent 50d0997569
commit 1c04703c77
6 changed files with 21 additions and 4 deletions

View File

@ -39,7 +39,6 @@ class BaseTestCase(APITestCase):
title={"en-GB": "Test news"},
news_type=self.test_news_type,
description={"en-GB": "Description test news"},
start=datetime.fromisoformat("2020-12-03 12:00:00"),
end=datetime.fromisoformat("2020-12-03 12:00:00"),
state=News.PUBLISHED,
slugs={'en-GB': 'test-news'}

View File

@ -0,0 +1,19 @@
# Generated by Django 2.2.7 on 2019-12-23 12:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('news', '0049_auto_20191223_0619'),
]
operations = [
migrations.AlterField(
model_name='news',
name='news_type',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='news', to='news.NewsType', verbose_name='news type'),
),
]

View File

@ -177,7 +177,7 @@ class News(GalleryMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixin,
old_id = models.PositiveIntegerField(_('old id'), blank=True, null=True, default=None)
news_type = models.ForeignKey(NewsType, on_delete=models.PROTECT,
verbose_name=_('news type'))
verbose_name=_('news type'), related_name='news')
title = TJSONField(blank=True, null=True, default=None,
verbose_name=_('title'),
help_text='{"en-GB":"some text"}')

View File

@ -79,7 +79,6 @@ class NewsTestCase(BaseTestCase):
"title": {"ru-RU": "Test news POST"},
"news_type_id": self.test_news_type.id,
"description": {"ru-RU": "Description test news"},
"start": datetime.now() + timedelta(hours=-2),
"end": datetime.now() + timedelta(hours=2),
"state": News.PUBLISHED,
"slugs": {'en-GB': 'test-news-slug_post'},

View File

@ -30,6 +30,7 @@ def clear_old_news():
)
img_num = images.count()
NewsType.objects.all().delete()
news = News.objects.filter(old_id__isnull=False)
news_num = news.count()

View File

@ -53,7 +53,6 @@ class TranslateFieldTests(BaseTestCase):
"ru-RU": "Тестовая новость"
},
description={"en-GB": "Test description"},
start=datetime.now(pytz.utc) + timedelta(hours=-13),
end=datetime.now(pytz.utc) + timedelta(hours=13),
news_type=self.news_type,
slugs={'en-GB': 'test'},