Commit 5e4aaacf authored by okhin's avatar okhin 🚴

We need an actual dict without None as parameters for forms

parent 32ce8428
Pipeline #2640 failed with stages
in 40 seconds
......@@ -202,11 +202,13 @@ class TestArticleViews(TestCase):
self.client.force_login(user=self.user)
pk = self.articles[0].pk
fields = {'title': 'Zog Zog'}
r = self.client.post('/rp/article/edit/{}/'.format(pk), fields)
a = {'title': 'Zog Zog',
'status': 'NEW',
'lang': 'FR',
'url': 'https://www.example.org/'}
r = self.client.post('/rp/article/edit/{}/'.format(pk), a)
a = Article.objects.get(pk=pk)
assert r.status_code == 302 # We're redirecting after edit
assert r.status_code == 302 # We're redirecting to the view or preview of the article
assert a.title == 'Zog Zog'
......@@ -244,8 +246,8 @@ class TestArticleApi(TestCase):
article = {'title': 'Zog Zog',
'url': 'https://article.org/Zog+Zog'}
r = self.client.put('/api/articles/{}/'.format(pk),
article,
format='json')
article,
format='json')
assert r.status_code == 200
assert Article.objects.get(pk=pk).title == 'Zog Zog'
......@@ -266,7 +268,7 @@ class TestArticleApi(TestCase):
assert r.status_code == 200
a = Article.objects.get(pk=pk)
assert list(a.tags.values('name',).order_by('name')) == [{'name': 'New Tag 1'},
{'name': 'New Tag 2'}]
{'name': 'New Tag 2'}]
def test_api_filter_tag(self):
tag = 'Tag 1'
......@@ -347,7 +349,7 @@ class TestArticleApi(TestCase):
# We cannot recover a published article
a = ArticleFactory(status='PUBLISHED')
r = self.client.post('/api/articles/{}/recover/'.format(a.id))
assert r.status_code == 403
assert r.status_code == 400
def test_api_set_priority(self):
self.user.user_permissions.add(Permission.objects.get(
......@@ -355,7 +357,7 @@ class TestArticleApi(TestCase):
self.client.force_login(user=self.user)
a = ArticleFactory(status='DRAFT')
assert a.priority is False
r = self.client.post('/api/articles/{}/set_priority/'.format(a.id))
r = self.client.post('/api/articles/{}/set-priority/'.format(a.id))
assert r.status_code == 200
assert r.data['priority']
......@@ -365,6 +367,6 @@ class TestArticleApi(TestCase):
self.client.force_login(user=self.user)
a = ArticleFactory(status='DRAFT', priority=True)
assert a.priority
r = self.client.post('/api/articles/{}/unset_priority/'.format(a.id))
r = self.client.post('/api/articles/{}/unset-priority/'.format(a.id))
assert r.status_code == 200
assert r.data['priority'] is False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment