Exemplo n.º 1
0
 def test_can_embed_the_latest_issue_in_the_context(self):
     # Setup
     collection = CollectionFactory.create()
     journal = JournalFactory.create(collection=collection)
     JournalInformationFactory.create(journal=journal)
     IssueFactory.create(
         journal=journal, date_published=dt.datetime.now() - dt.timedelta(days=1))
     issue_2 = IssueFactory.create(journal=journal, date_published=dt.datetime.now())
     IssueFactory.create(journal=journal, date_published=None)
     url = reverse('public:journal:journal-detail', kwargs={'code': journal.code})
     # Run
     response = self.client.get(url)
     # Check
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['latest_issue'], issue_2)
Exemplo n.º 2
0
 def test_can_embed_the_journal_information_in_the_context_if_available(self):
     # Setup
     collection = CollectionFactory.create()
     journal_1 = JournalFactory.create(collection=collection)
     journal_2 = JournalFactory.create(collection=collection)
     journal_info = JournalInformationFactory.create(journal=journal_1)
     url_1 = reverse('public:journal:journal-detail', kwargs={'code': journal_1.code})
     url_2 = reverse('public:journal:journal-detail', kwargs={'code': journal_2.code})
     # Run
     response_1 = self.client.get(url_1)
     response_2 = self.client.get(url_2)
     # Check
     self.assertEqual(response_1.status_code, 200)
     self.assertEqual(response_2.status_code, 200)
     self.assertEqual(response_1.context['journal_info'], journal_info)
     self.assertTrue('journal_info' not in response_2.context)