Пример #1
0
    def test_add_issue(self):
        from models import Journal
        from models import Issue
        journal = Journal.objects.all()[0]

        #empty form
        response = self.client.get(reverse('issue.add', args=[journal.pk]))
        self.assertEqual(response.status_code, 200)

        #add - should work
        sample_license = tests_assets.get_sample_uselicense()
        sample_license.save()

        sample_section = tests_assets.get_sample_section()
        sample_section.journal = journal
        sample_section.save()

        response = self.client.post(reverse('issue.add', args=[journal.pk]),
            tests_assets.get_sample_issue_dataform(section=sample_section.pk,
                                                   use_license=sample_license.pk))

        self.assertRedirects(response, reverse('issue.index', args=[journal.pk]))

        #edit
        journal = Journal.objects.all()[0]

        response = self.client.get(reverse('issue.edit', args=[journal.pk, journal.issue_set.all()[0].pk]))
        self.assertEqual(response.status_code, 200)
Пример #2
0
    def test_add_journal(self):
        #empty form
        response = self.client.get(reverse('journal.add'))
        self.assertEqual(response.status_code, 200)

        sample_publisher = tests_assets.get_sample_publisher()
        sample_publisher.collection = self.collection
        sample_publisher.save()

        sample_uselicense = tests_assets.get_sample_uselicense()
        sample_uselicense.save()

        sample_indexdatabase = tests_assets.get_sample_index_database()
        sample_indexdatabase.save()

        #add journal - missing required
        #response = self.client.post(reverse('journal.add'),
        #   tests_assets.get_sample_journal_dataform())

        #self.assertTrue('field required' in response.content.lower())

        sample_center = tests_assets.get_sample_center()
        sample_center.collection = self.collection
        sample_center.save()

        response = self.client.post(
            reverse('journal.add'),
            tests_assets.get_sample_journal_dataform({
                'journal-publisher':
                sample_publisher.pk,
                'journal-use_license':
                sample_uselicense.pk,
                'journal-collections': [self.collection.pk],
                'journal-center':
                sample_center.pk,
            }))

        self.assertRedirects(response, reverse('journal.index'))

        #edit journal - must be changed
        testing_journal = Journal.objects.get(
            title=
            u'ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)')
        response = self.client.post(
            reverse('journal.edit', args=(testing_journal.pk, )),
            tests_assets.get_sample_journal_dataform({
                'journal-title':
                'Modified Title',
                'journal-publisher':
                sample_publisher.pk,
                'journal-use_license':
                sample_uselicense.pk,
                'journal-collections': [self.collection.pk],
                'journal-center':
                sample_center.pk,
            }))

        self.assertRedirects(response, reverse('journal.index'))
        modified_testing_journal = Journal.objects.get(title='Modified Title')
        self.assertEqual(testing_journal, modified_testing_journal)
Пример #3
0
    def test_add_issue(self):
        from models import Journal
        from models import Issue
        journal = Journal.objects.all()[0]

        #empty form
        response = self.client.get(reverse('issue.add', args=[journal.pk]))
        self.assertEqual(response.status_code, 200)

        #add - should work
        sample_license = tests_assets.get_sample_uselicense()
        sample_license.save()

        sample_section = tests_assets.get_sample_section()
        sample_section.journal = journal
        sample_section.save()

        response = self.client.post(
            reverse('issue.add', args=[journal.pk]),
            tests_assets.get_sample_issue_dataform(
                section=sample_section.pk, use_license=sample_license.pk))

        self.assertRedirects(response, reverse('issue.index',
                                               args=[journal.pk]))

        #edit
        journal = Journal.objects.all()[0]

        response = self.client.get(
            reverse('issue.edit',
                    args=[journal.pk,
                          journal.issue_set.all()[0].pk]))
        self.assertEqual(response.status_code, 200)
Пример #4
0
    def test_add_journal(self):
        """
        Covered cases:
        * Accessing the form
        * Submission with missing data
        * Submission with all required data
        * Edition of a existing record
        """
        #empty form
        response = self.client.get(reverse('journal.add'))
        self.assertEqual(response.status_code, 200)

        sample_publisher = tests_assets.get_sample_publisher()
        sample_publisher.collection = self.collection
        sample_publisher.save()

        sample_uselicense = tests_assets.get_sample_uselicense()
        sample_uselicense.save()

        sample_language = tests_assets.get_sample_language()
        sample_language.save()

        #missing data
        response = self.client.post(reverse('journal.add'),
            tests_assets.get_sample_journal_dataform({'journal-publisher': sample_publisher.pk,
                                                     'journal-collections': [self.usercollections.pk],
                                                     }))

        self.assertTrue('some errors or missing data' in response.content)


        response = self.client.post(reverse('journal.add'),
            tests_assets.get_sample_journal_dataform({'journal-publisher': sample_publisher.pk,
                                                     'journal-use_license': sample_uselicense.pk,
                                                     'journal-collections': [self.usercollections.pk],
                                                     'journal-languages': [sample_language.pk]}))

        self.assertRedirects(response, reverse('journal.index'))

        #edit journal - must be changed
        testing_journal = Journal.objects.get(title = u'ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)')
        response = self.client.post(reverse('journal.edit', args = (testing_journal.pk,)),
            tests_assets.get_sample_journal_dataform({'journal-title': 'Modified Title',
                                                     'journal-publisher': sample_publisher.pk,
                                                     'journal-use_license': sample_uselicense.pk,
                                                     'journal-collections': [self.usercollections.pk],
                                                     'journal-languages': [sample_language.pk], }))

        self.assertRedirects(response, reverse('journal.index'))
        modified_testing_journal = Journal.objects.get(title = 'Modified Title')
        self.assertEqual(testing_journal, modified_testing_journal)
Пример #5
0
    def test_add_journal(self):
        #empty form
        response = self.client.get(reverse('journal.add'))
        self.assertEqual(response.status_code, 200)

        sample_publisher = tests_assets.get_sample_publisher()
        sample_publisher.collection = self.collection
        sample_publisher.save()

        sample_uselicense = tests_assets.get_sample_uselicense()
        sample_uselicense.save()

        sample_indexdatabase = tests_assets.get_sample_index_database()
        sample_indexdatabase.save()

        #add journal - missing required
        #response = self.client.post(reverse('journal.add'),
        #   tests_assets.get_sample_journal_dataform())

        #self.assertTrue('field required' in response.content.lower())

        sample_center = tests_assets.get_sample_center()
        sample_center.collection = self.collection
        sample_center.save() 

        response = self.client.post(reverse('journal.add'),
            tests_assets.get_sample_journal_dataform({'journal-publisher': sample_publisher.pk,
                                                     'journal-use_license': sample_uselicense.pk,
                                                     'journal-collections': [self.collection.pk],
                                                     'journal-center': sample_center.pk, }))

        self.assertRedirects(response, reverse('journal.index'))

        #edit journal - must be changed
        testing_journal = Journal.objects.get(title = u'ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)')
        response = self.client.post(reverse('journal.edit', args = (testing_journal.pk,)),
            tests_assets.get_sample_journal_dataform({'journal-title': 'Modified Title',
                                                     'journal-publisher': sample_publisher.pk,
                                                     'journal-use_license': sample_uselicense.pk,
                                                     'journal-collections': [self.collection.pk],
                                                     'journal-center': sample_center.pk, }))

        self.assertRedirects(response, reverse('journal.index'))
        modified_testing_journal = Journal.objects.get(title = 'Modified Title')
        self.assertEqual(testing_journal, modified_testing_journal)