Example #1
0
 def test_upd_ex_unrelated_article(self):
     """
     обновляем непривязанную статью
     """
     cleaned_data = self.get_cleaned_data()
     cleaned_data['tags'] = ['tag1', 'tag2']
     article = MfSystemArticle.objects.get(pk=377)
     article.tags.add('old_tag1', 'old_tag2')
     with patch(
         "api.cc._remove_cach_file_by_url", return_value=1
     ) as mock_cc:
         sabnac.update_article(article, cleaned_data)
         self.assertEquals(mock_cc.mock_calls, [
             call('/api/test_orthodoxy/article/article_50_1.json'),
             call('/api/test_orthodoxy/article/article_50_1.xml'),
             call('/api/test_orthodoxy/article/377.json'),
             call('/api/test_orthodoxy/article/377.xml'),
             #почему-то такой порядок
             call('/api/test_orthodoxy/article/tag/old_tag2.json'),
             call('/api/test_orthodoxy/article/tag/old_tag2.xml'),
             call('/api/test_orthodoxy/article/tag/old_tag1.json'),
             call('/api/test_orthodoxy/article/tag/old_tag1.xml'),
             call('/api/somesite/article/tag/tag1.json'),
             call('/api/somesite/article/tag/tag1.xml'),
             call('/api/somesite/article/tag/tag2.json'),
             call('/api/somesite/article/tag/tag2.xml'),
         ])
Example #2
0
 def test_upd_ex_related_article(self):
     """
     обновляем привязанную статью
     """
     article = MfSystemArticle.objects.get(pk=374)
     with patch(
         "api.cc._remove_cach_file_by_url", return_value=1
     ) as mock_cc:
         sabnac.update_article(article, self.get_cleaned_data())
         self.assertEquals(mock_cc.mock_calls, [
             # урл старый
             call('/api/test_orthodoxy/article/article_14_2.json'),
             call('/api/test_orthodoxy/article/article_14_2.xml'),
             # id статьи
             call('/api/test_orthodoxy/article/374.json'),
             call('/api/test_orthodoxy/article/374.xml'),
             # calendar/(все даты по smart_function события,
             # к которому привязана статья)
             call('/api/calendar/2010-04-07.json'),
             call('/api/calendar/2010-04-07.xml'),
             call('/api/calendar/2011-04-07.json'),
             call('/api/calendar/2011-04-07.xml'),
             # event/[id к которому привязана статья]
             call('/api/event/14.json'),
             call('/api/event/14.xml'),
             # event/[url к которому привязана статья]
             call('/api/event/blagoveshenie_presvyatoy_bogorodicy.json'),
             call('/api/event/blagoveshenie_presvyatoy_bogorodicy.xml'),
         ])
Example #3
0
 def test_create_article(self):
     cleaned_data = self.get_cleaned_data()
     #проверим теги
     cleaned_data['tags'] = ['xxx', 'yyy']
     with patch(
         "api.cc._remove_cach_file_by_url", return_value=1
     ) as mock_cc:
         sabnac.update_article(MfSystemArticle(), cleaned_data)
         self.assertEquals(mock_cc.mock_calls, [
             call('/api/somesite/article/tag/xxx.json'),
             call('/api/somesite/article/tag/xxx.xml'),
             call('/api/somesite/article/tag/yyy.json'),
             call('/api/somesite/article/tag/yyy.xml'),
         ])