Beispiel #1
0
    def test_user_reordering_unknown_issues(self):
        """
        The server must respond a http 500 error code when
        it is requested to reorder issues that do not match
        the journal.
        """
        perm1 = _makePermission(perm='list_issue',
                                model='issue',
                                app_label='journalmanager')
        perm2 = _makePermission(perm='reorder_issue',
                                model='issue',
                                app_label='journalmanager')
        self.user.user_permissions.add(perm1)
        self.user.user_permissions.add(perm2)

        params = 'numbers=num%5B%5D%3D8036%26num%5B%5D%3D8035&issues_set=numbers-2005%7CNone'

        response = self.app.get(
            reverse('issue.reorder.ajax', args=[self.journal.pk]) + '?' +
            params,
            headers={'x-requested-with': 'XMLHttpRequest'},
            user=self.user,
            expect_errors=True)

        self.assertEqual(response.status_code, 500)
Beispiel #2
0
    def test_logged_user_access(self):
        perm = _makePermission(perm='change_user', model='user', app_label='auth')
        self.user.user_permissions.add(perm)

        response = self.app.get(reverse('user.index'), user=self.user)

        self.assertTemplateUsed(response, 'journalmanager/user_list.html')
    def test_pressrelease_list_with_itens(self):
        """
        Asserts that threre is itens on press release list
        """
        journal = modelfactories.JournalFactory()
        journal.join(self.collection, self.user)

        issue = modelfactories.IssueFactory(journal=journal)
        perm_journal_list = _makePermission(perm='list_pressrelease',
                                            model='pressrelease',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        language = modelfactories.LanguageFactory.create(iso_code='en', name='english')

        pr = modelfactories.RegularPressReleaseFactory.create(issue=issue)
        pr.add_translation('The new york times Journal',
                           'Biggest rock entered the land was in 1969',
                           language)

        response = self.app.get(reverse('prelease.index',
                                args=[journal.pk]),
                                user=self.user)

        self.assertTrue('The new york times Journal' in response.body)
Beispiel #4
0
    def test_aheadpressrelease_list_with_itens(self):
        """
        Asserts that threre is itens on ahead press release list
        """
        journal = modelfactories.JournalFactory()
        journal.join(self.collection, self.user)

        perm_journal_list = _makePermission(perm='list_pressrelease',
                                            model='pressrelease',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        language = modelfactories.LanguageFactory.create(iso_code='en',
                                                         name='english')

        pr = modelfactories.AheadPressReleaseFactory.create(journal=journal)
        pr.add_translation('Ahead Press Release on new york times',
                           'Biggest rock entered the land was in 1969',
                           language)

        response = self.app.get(reverse('prelease.index', args=[journal.pk]) +
                                '?tab=ahead',
                                user=self.user)
        self.assertTrue(
            'Ahead Press Release on new york times' in response.body)
Beispiel #5
0
    def test_user_access_journals_list_without_itens(self):
        perm_sponsor_list = _makePermission(perm='list_sponsor',
                                            model='sponsor',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_sponsor_list)

        response = self.app.get(reverse('sponsor.index'), user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #6
0
    def test_user_access_issue_list_without_itens(self):
        perm_issue_list = _makePermission(perm='list_issue',
            model='issue', app_label='journalmanager')
        self.user.user_permissions.add(perm_issue_list)

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

        self.assertTrue('There are no items.' in response.body)
Beispiel #7
0
    def test_user_access_journals_list_without_itens(self):
        perm_sponsor_list = _makePermission(perm='list_sponsor',
            model='sponsor', app_label='journalmanager')
        self.user.user_permissions.add(perm_sponsor_list)

        response = self.app.get(reverse('sponsor.index'),
            user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #8
0
    def test_user_reordering_without_passing_params(self):
        """
        The server must respond a http 500 code and do nothing.
        """
        perm1 = _makePermission(perm='list_issue',
            model='issue', app_label='journalmanager')
        perm2 = _makePermission(perm='reorder_issue',
            model='issue', app_label='journalmanager')
        self.user.user_permissions.add(perm1)
        self.user.user_permissions.add(perm2)

        response = self.app.get(
            reverse('issue.reorder.ajax', args=[self.journal.pk]),
            headers={'x-requested-with': 'XMLHttpRequest'},
            user=self.user,
            expect_errors=True
        )

        self.assertEqual(response.status_code, 500)
Beispiel #9
0
    def test_user_access_issue_list_without_itens(self):
        perm_issue_list = _makePermission(perm='list_issue',
                                          model='issue',
                                          app_label='journalmanager')
        self.user.user_permissions.add(perm_issue_list)

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

        self.assertTrue('There are no items.' in response.body)
    def test_toggle_active_collection_unavailable_for_users_with_a_single_collection(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertIn('<li class="disabled" id="edit-brasil">', page)
    def test_auto_define_a_collection_as_default_when_it_is_the_unique(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertTrue(collection.name in page)
Beispiel #12
0
    def test_active_collection_for_user_with_a_single_collection(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)
        _makeUserProfile(user)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertIn('data-active-collection="%s"' % collection.name, page)
Beispiel #13
0
    def test_redirect_to_restricted_page_after_successful_login(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('journal.index'), user=user)

        page.mustcontain('no items')
Beispiel #14
0
    def test_redirect_to_restricted_page_after_successful_login(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('journal.index'), user=user)

        page.mustcontain('no items')
Beispiel #15
0
    def test_active_collection_for_user_with_a_single_collection(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)
        _makeUserProfile(user)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertIn('data-active-collection="%s"' % collection.name, page)
Beispiel #16
0
    def test_user_reordering_without_passing_params(self):
        """
        The server must respond a http 500 code and do nothing.
        """
        perm1 = _makePermission(perm='list_issue',
                                model='issue',
                                app_label='journalmanager')
        perm2 = _makePermission(perm='reorder_issue',
                                model='issue',
                                app_label='journalmanager')
        self.user.user_permissions.add(perm1)
        self.user.user_permissions.add(perm2)

        response = self.app.get(reverse('issue.reorder.ajax',
                                        args=[self.journal.pk]),
                                headers={'x-requested-with': 'XMLHttpRequest'},
                                user=self.user,
                                expect_errors=True)

        self.assertEqual(response.status_code, 500)
Beispiel #17
0
    def test_logged_user_access(self):
        perm = _makePermission(perm='change_user',
            model='user', app_label='auth')
        self.user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(self.user, is_manager=True)

        response = self.app.get(reverse('user.index'), user=self.user)

        self.assertTemplateUsed(response, 'journalmanager/user_list.html')
Beispiel #18
0
    def test_list_without_articles(self):
        perm_article_list = _makePermission(perm='list_article',
                                            model='article',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_article_list)

        journal = modelfactories.JournalFactory(collection=self.collection)
        issue = modelfactories.IssueFactory(journal=journal)

        response = self.app.get(reverse('article.index', args=[issue.pk]), user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #19
0
    def test_journals_list_without_itens(self):
        """
        Asserts the message ``'There are no items.`` is shown
        when the journals list is empty.
        """
        perm_journal_list = _makePermission(perm='list_journal',
            model='journal', app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        response = self.app.get(reverse('journal.index'), user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #20
0
    def test_auto_define_a_collection_as_default_when_it_is_the_unique(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)

        _makeUserProfile(user)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertTrue(collection.name in page)
Beispiel #21
0
    def test_logged_user_access(self):
        perm = _makePermission(perm='change_user',
                               model='user',
                               app_label='auth')
        self.user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(self.user, is_manager=True)

        response = self.app.get(reverse('user.index'), user=self.user)

        self.assertTemplateUsed(response, 'journalmanager/user_list.html')
Beispiel #22
0
    def test_journal_editors_list_without_users(self):
        from waffle import Flag
        Flag.objects.create(name='editor_manager', everyone=True)

        perm_journal_list = _makePermission(perm='list_journal',
                                            model='journal',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        response = self.app.get(reverse('journal_editors.index',
            args=[self.journal.pk]), user=self.user)

        self.assertIn('There are no editors to manage this journal', response.body)
    def test_toggle_active_collection_available_for_users_with_many_collections(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.make_default_to_user(user)
        collection2 = modelfactories.CollectionFactory.create(name='Chile')
        collection2.add_user(user)

        page = self.app.get(reverse('index'), user=user)

        self.assertIn('activate-chile', page)
Beispiel #24
0
    def test_mailto_the_user_responsible_for_the_activity(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.add_user(user)

        journal = modelfactories.JournalFactory(creator=user)
        journal.join(collection, user)

        page = self.app.get(reverse('index'), user=user)
        page.mustcontain('href="mailto:%s"' % user.email)
Beispiel #25
0
    def test_journals_list_without_itens(self):
        """
        Asserts the message ``'There are no items.`` is shown
        when the journals list is empty.
        """
        perm_journal_list = _makePermission(perm='list_journal',
                                            model='journal',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        response = self.app.get(reverse('journal.index'), user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #26
0
    def test_user_reordering_issues_without_permissions(self):
        """
        Asserts that unpriviledged users can't reorder Issues
        """
        perm_issue_list = _makePermission(perm='list_issue',
            model='issue', app_label='journalmanager')
        self.user.user_permissions.add(perm_issue_list)

        response = self.app.get(reverse('issue.reorder.ajax',
            args=[self.journal.pk]), user=self.user).follow()

        response.mustcontain('not authorized to access')
        self.assertTemplateUsed(response, 'accounts/unauthorized.html')
Beispiel #27
0
    def test_logout_button(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('journal.index'), user=user)

        response = page.click(href=u'/accounts/logout/').follow()

        self.assertTemplateUsed(response, 'registration/login.html')
        self.assertNotIn('_auth_user_id', self.client.session)
Beispiel #28
0
    def test_logout_button(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(user)

        page = self.app.get(reverse('journal.index'), user=user)

        response = page.click(href=u'/accounts/logout/').follow()

        self.assertTemplateUsed(response, 'registration/login.html')
        self.assertNotIn('_auth_user_id', self.client.session)
Beispiel #29
0
    def test_logged_editor_user_access_to_list_journal(self):
        editors_group = modelfactories.GroupFactory.create(name='Editors')
        perm = _makePermission(perm='list_editor_journal', model='journal', app_label='journalmanager')
        editors_group.permissions.add(perm)

        collection = modelfactories.CollectionFactory.create()
        collection.add_user(self.user)

        self.user.groups.add(editors_group)

        response = self.app.get(reverse('index'), user=self.user)
        response = response.follow()

        self.assertTemplateUsed(response, 'journal/journal_list.html')
Beispiel #30
0
    def test_user_reordering_unknown_issues(self):
        """
        The server must respond a http 500 error code when
        it is requested to reorder issues that do not match
        the journal.
        """
        perm1 = _makePermission(perm='list_issue',
            model='issue', app_label='journalmanager')
        perm2 = _makePermission(perm='reorder_issue',
            model='issue', app_label='journalmanager')
        self.user.user_permissions.add(perm1)
        self.user.user_permissions.add(perm2)

        params = 'numbers=num%5B%5D%3D8036%26num%5B%5D%3D8035&issues_set=numbers-2005%7CNone'

        response = self.app.get(
            reverse('issue.reorder.ajax', args=[self.journal.pk]) + '?' + params,
            headers={'x-requested-with': 'XMLHttpRequest'},
            user=self.user,
            expect_errors=True
        )

        self.assertEqual(response.status_code, 500)
Beispiel #31
0
    def test_remove_user_from_collection(self):
        perm = _makePermission(perm='change_user', model='user', app_label='auth')
        self.user.user_permissions.add(perm)

        other_user = auth.UserF(is_active=True)
        self.collection.add_user(other_user)

        response = self.app.get(reverse('user.index'), user=self.user)

        self.assertTrue(other_user.username in response.body)

        response = self.app.get(reverse('user.exclude_user_from_collection', args=[other_user.pk]), user=self.user)

        self.assertFalse(other_user.username in response.body)
Beispiel #32
0
    def test_link_to_activate_collection_available_for_users_with_many_collections(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_collection', model='collection')
        user.user_permissions.add(perm)

        _makeUserProfile(user)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.make_default_to_user(user)
        collection2 = modelfactories.CollectionFactory.create(name='Chile')
        collection2.add_user(user)

        page = self.app.get(reverse('index'), user=user)
        self.assertIn('/toggle_active_collection/%s' % collection2.pk, page)
Beispiel #33
0
    def test_sections_list_without_itens(self):
        """
        Asserts the message ``'There are no items.`` is shown
        when the sections list is empty.
        """
        perm_sponsor_list = _makePermission(perm='list_section',
                                            model='section',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_sponsor_list)

        journal = modelfactories.JournalFactory(collection=self.collection)

        page = self.app.get(reverse('section.index', args=[journal.pk]), user=self.user)

        self.assertTrue('There are no items.' in page.body)
Beispiel #34
0
    def test_list_without_articles(self):
        perm_article_list = _makePermission(perm='list_article',
                                            model='article',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_article_list)

        journal = modelfactories.JournalFactory()
        journal.join(self.collection, self.user)

        issue = modelfactories.IssueFactory(journal=journal)

        response = self.app.get(reverse('article.index', args=[issue.pk]),
                                user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #35
0
    def test_pressrelease_list_without_itens(self):
        """
        Asserts the message ``'There are no items.`` is shown
        when the pressrelease list is empty.
        """
        journal = modelfactories.JournalFactory()

        perm_pressrelease_list = _makePermission(perm='list_pressrelease',
                                                 model='pressrelease',
                                                 app_label='journalmanager')
        self.user.user_permissions.add(perm_pressrelease_list)

        response = self.app.get(reverse('prelease.index', args=[journal.pk]), user=self.user)

        self.assertTrue('There are no items.' in response.body)
Beispiel #36
0
    def test_user_reordering_issues_without_permissions(self):
        """
        Asserts that unpriviledged users can't reorder Issues
        """
        perm_issue_list = _makePermission(perm='list_issue',
                                          model='issue',
                                          app_label='journalmanager')
        self.user.user_permissions.add(perm_issue_list)

        response = self.app.get(reverse('issue.reorder.ajax',
                                        args=[self.journal.pk]),
                                user=self.user).follow()

        response.mustcontain('not authorized to access')
        self.assertTemplateUsed(response, 'accounts/unauthorized.html')
Beispiel #37
0
    def test_journal_editors_list_without_users(self):
        from waffle import Flag
        Flag.objects.create(name='editor_manager', everyone=True)

        perm_journal_list = _makePermission(perm='list_journal',
                                            model='journal',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_list)

        response = self.app.get(reverse('journal_editors.index',
                                        args=[self.journal.pk]),
                                user=self.user)

        self.assertIn('There are no editors to manage this journal',
                      response.body)
Beispiel #38
0
    def test_pressrelease_list_without_itens(self):
        """
        Asserts the message ``'There are no items.`` is shown
        when the pressrelease list is empty.
        """
        journal = modelfactories.JournalFactory()
        journal.join(self.collection, self.user)

        perm_pressrelease_list = _makePermission(perm='list_pressrelease',
                                                 model='pressrelease',
                                                 app_label='journalmanager')
        self.user.user_permissions.add(perm_pressrelease_list)

        response = self.app.get(reverse('prelease.index', args=[journal.pk]), user=self.user)

        self.assertTrue('There are no items.' in response.body)
    def test_POST_invalid_formdata_do_not_log(self):
        """
        When an invalid form is submited, no action is taken, no changes are made, so no log are recorded.
        """
        perm = _makePermission(perm="change_journal", model="journal", app_label="journalmanager")
        self.user.user_permissions.add(perm)

        sponsor = jm_modelfactories.SponsorFactory.create()

        form = self.app.get(reverse("journal.add"), user=self.user).forms["journal-form"]

        form["journal-sponsor"] = [sponsor.pk]
        form["journal-ctrl_vocabulary"] = "decs"
        form["journal-frequency"] = "Q"
        form["journal-final_num"] = ""
        form["journal-eletronic_issn"] = "0102-6720"
        form["journal-init_vol"] = "1"
        form["journal-title"] = u"ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)"
        form["journal-title_iso"] = u"ABCD. Arquivos B. de C. D. (São Paulo)"
        form["journal-short_title"] = u"ABCD.(São Paulo)"
        form["journal-editorial_standard"] = "vancouv"
        form["journal-scielo_issn"] = "print"
        form["journal-init_year"] = "1986"
        form["journal-acronym"] = "ABCD"
        form["journal-pub_level"] = "CT"
        form["journal-init_num"] = "1"
        form["journal-final_vol"] = ""
        form["journal-subject_descriptors"] = "MEDICINA, CIRURGIA, GASTROENTEROLOGIA, GASTROENTEROLOGIA"
        form["journal-print_issn"] = "0102-6720"
        form["journal-copyrighter"] = "Texto do copyrighter"
        form["journal-publisher_name"] = "Colégio Brasileiro de Cirurgia Digestiva"
        form["journal-publisher_country"] = "BR"
        form["journal-publisher_state"] = "SP"
        form["journal-publication_city"] = "São Paulo"
        form[
            "journal-editor_address"
        ] = "Av. Brigadeiro Luiz Antonio, 278 - 6° - Salas 10 e 11, 01318-901 \
                                          São Paulo/SP Brasil, Tel.: (11) 3288-8174/3289-0741"
        form["journal-editor_email"] = "*****@*****.**"

        response = form.submit()
        self.assertIn("There are some errors or missing data", response.body)
        self.assertEqual(audit_models.AuditLogEntry.objects.count(), 0)
Beispiel #40
0
    def test_expected_table_row(self):
        user = auth.UserF(is_active=True)
        perm = _makePermission(perm='list_journal', model='journal')
        user.user_permissions.add(perm)

        collection = modelfactories.CollectionFactory.create(name='Brasil')
        collection.add_user(user)

        journal = modelfactories.JournalFactory(creator=user)
        journal.join(collection, user)

        page = self.app.get(reverse('index'), user=user)

        elem = page.lxml.xpath('//table[@id="activities"]/tbody/tr[2]/*')

        self.assertIn(collection.name, elem[0].text)
        self.assertIn(user.username, elem[1].xpath('a')[0].text)
        self.assertIn(journal.short_title, elem[2].xpath('a')[0].text)
        self.assertIn(journal.updated.strftime('%X'), elem[3].text)
Beispiel #41
0
    def test_list_with_articles(self):
        perm_article_list = _makePermission(perm='list_article',
                                            model='article',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_article_list)

        journal = modelfactories.JournalFactory(collection=self.collection)
        issue = modelfactories.IssueFactory(journal=journal)

        front = {
            'title-group': {
                'en': u'Article Title 1',
                'pt': u'Título do Artigo 1'
            }
        }

        article = modelfactories.ArticleFactory.create(issue=issue, front=front)
        response = self.app.get(reverse('article.index', args=[issue.pk]), user=self.user)

        self.assertTrue('Article Title 1' in response.body)
Beispiel #42
0
    def test_POST_invalid_formdata_do_not_log(self):
        """
        When an invalid form is submited, no action is taken, no changes are made, so no log are recorded.
        """
        perm = _makePermission(perm='change_journal', model='journal', app_label='journalmanager')
        self.user.user_permissions.add(perm)

        sponsor = jm_modelfactories.SponsorFactory.create()

        form = self.app.get(reverse('journal.add'), user=self.user).forms['journal-form']

        form['journal-sponsor'] = [sponsor.pk]
        form['journal-ctrl_vocabulary'] = 'decs'
        form['journal-frequency'] = 'Q'
        form['journal-final_num'] = ''
        form['journal-eletronic_issn'] = '0102-6720'
        form['journal-init_vol'] = '1'
        form['journal-title'] = u'ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)'
        form['journal-title_iso'] = u'ABCD. Arquivos B. de C. D. (São Paulo)'
        form['journal-short_title'] = u'ABCD.(São Paulo)'
        form['journal-editorial_standard'] = 'vancouv'
        form['journal-scielo_issn'] = 'print'
        form['journal-init_year'] = '1986'
        form['journal-acronym'] = 'ABCD'
        form['journal-pub_level'] = 'CT'
        form['journal-init_num'] = '1'
        form['journal-final_vol'] = ''
        form['journal-subject_descriptors'] = 'MEDICINA, CIRURGIA, GASTROENTEROLOGIA, GASTROENTEROLOGIA'
        form['journal-print_issn'] = '0102-6720'
        form['journal-copyrighter'] = 'Texto do copyrighter'
        form['journal-publisher_name'] = 'Colégio Brasileiro de Cirurgia Digestiva'
        form['journal-publisher_country'] = 'BR'
        form['journal-publisher_state'] = 'SP'
        form['journal-publication_city'] = 'São Paulo'
        form['journal-editor_address'] = 'Av. Brigadeiro Luiz Antonio, 278 - 6° - Salas 10 e 11, 01318-901 \
                                          São Paulo/SP Brasil, Tel.: (11) 3288-8174/3289-0741'
        form['journal-editor_email'] = '*****@*****.**'

        response = form.submit()
        self.assertIn('There are some errors or missing data', response.body)
        self.assertEqual(audit_models.AuditLogEntry.objects.count(), 0)
Beispiel #43
0
    def test_list_with_articles(self):
        perm_article_list = _makePermission(perm='list_article',
                                            model='article',
                                            app_label='journalmanager')
        self.user.user_permissions.add(perm_article_list)

        journal = modelfactories.JournalFactory()
        journal.join(self.collection, self.user)

        issue = modelfactories.IssueFactory(journal=journal)

        front = {
            'title-group': {
                'en': u'Article Title 1',
                'pt': u'Título do Artigo 1'
            }
        }

        article = modelfactories.ArticleFactory.create(issue=issue,
                                                       front=front)
        response = self.app.get(reverse('article.index', args=[issue.pk]),
                                user=self.user)

        self.assertTrue('Article Title 1' in response.body)
Beispiel #44
0
    def test_POST_valid_formdata_do_log(self):
        # with:
        perm_journal_change = _makePermission(perm='change_journal', model='journal', app_label='journalmanager')
        perm_journal_list = _makePermission(perm='list_journal', model='journal', app_label='journalmanager')
        self.user.user_permissions.add(perm_journal_change)
        self.user.user_permissions.add(perm_journal_list)

        sponsor = jm_modelfactories.SponsorFactory.create()
        use_license = jm_modelfactories.UseLicenseFactory.create()
        language = jm_modelfactories.LanguageFactory.create()
        subject_category = jm_modelfactories.SubjectCategoryFactory.create()
        study_area = jm_modelfactories.StudyAreaFactory.create()

        form = self.app.get(reverse('journal.add'), user=self.user).forms['journal-form']
        form['journal-sponsor'] = [sponsor.pk]
        form['journal-study_areas'] = [study_area.pk]
        form['journal-ctrl_vocabulary'] = 'decs'
        form['journal-frequency'] = 'Q'
        form['journal-final_num'] = ''
        form['journal-eletronic_issn'] = '0102-6720'
        form['journal-init_vol'] = '1'
        form['journal-title'] = u'ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)'
        form['journal-title_iso'] = u'ABCD. Arquivos B. de C. D. (São Paulo)'
        form['journal-short_title'] = u'ABCD.(São Paulo)'
        form['journal-editorial_standard'] = 'vancouv'
        form['journal-scielo_issn'] = 'print'
        form['journal-init_year'] = '1986'
        form['journal-acronym'] = 'ABCD'
        form['journal-pub_level'] = 'CT'
        form['journal-init_num'] = '1'
        form['journal-final_vol'] = ''
        form['journal-subject_descriptors'] = 'MEDICINA, CIRURGIA, GASTROENTEROLOGIA, GASTROENTEROLOGIA'
        form['journal-print_issn'] = '0102-6720'
        form['journal-copyrighter'] = 'Texto do copyrighter'
        form['journal-publisher_name'] = 'Colégio Brasileiro de Cirurgia Digestiva'
        form['journal-publisher_country'] = 'BR'
        form['journal-publisher_state'] = 'SP'
        form['journal-publication_city'] = 'São Paulo'
        form['journal-editor_name'] = 'Colégio Brasileiro de Cirurgia Digestiva'
        form['journal-editor_address'] = 'Av. Brigadeiro Luiz Antonio, 278 - 6° - Salas 10 e 11'
        form['journal-editor_address_city'] = 'São Paulo'
        form['journal-editor_address_state'] = 'SP'
        form['journal-editor_address_zip'] = '01318-901'
        form['journal-editor_address_country'] = 'BR'
        form['journal-editor_phone1'] = '(11) 3288-8174'
        form['journal-editor_phone2'] = '(11) 3289-0741'
        form['journal-editor_email'] = '*****@*****.**'
        form['journal-use_license'] = use_license.pk
        form['journal-languages'] = [language.pk]
        form['journal-abstract_keyword_languages'] = [language.pk]
        form.set('journal-subject_categories', [str(subject_category.pk),])
        form['journal-is_indexed_scie'] = True
        form['journal-is_indexed_ssci'] = False
        form['journal-is_indexed_aehci'] = True

        # when:
        response = form.submit().follow()

        # then:
        self.assertIn('Saved.', response.body)
        self.assertIn('ABCD.(São Paulo)', response.body)
        self.assertTemplateUsed(response, 'journalmanager/journal_dash.html')

        self.assertEqual(audit_models.AuditLogEntry.objects.count(), 1)
        log_entry = audit_models.AuditLogEntry.objects.all()[0]
        audited_object = log_entry.get_audited_object()
        # inspect audited log entry data:
        self.assertEqual(log_entry.action_flag, audit_models.ADDITION)
        self.assertEqual(log_entry.object_id, unicode(audited_object.pk))
        self.assertEqual(log_entry.content_type, ContentType.objects.get_for_model(audited_object))
        self.assertEqual(log_entry.old_values, None)
        self.assertEqual(log_entry.user, self.user)

        fields_edited = [
            'sponsor',
            'use_license',
            'languages',
            'abstract_keyword_languages',
            'subject_categories',
            'study_areas',
            'title',
            'title_iso',
            'short_title',
            'acronym',
            'scielo_issn',
            'print_issn',
            'eletronic_issn',
            'subject_descriptors',
            'init_year',
            'init_vol',
            'init_num',
            'frequency',
            'editorial_standard',
            'ctrl_vocabulary',
            'pub_level',
            'copyrighter',
            'editor_name',
            'editor_address',
            'editor_address_city',
            'editor_address_state',
            'editor_address_zip',
            'editor_address_country',
            'editor_phone1',
            'editor_phone2',
            'editor_email',
            'publisher_name',
            'publisher_country',
            'publisher_state',
            'publication_city',
            'is_indexed_scie',
            'is_indexed_aehci',
        ]

        self.assertEqual(log_entry.new_values.keys(), [u'form_data', u'formsets_data'])
        for field_edited in fields_edited:
            # all edited fields are in "new_values"-dict
            self.assertIn(field_edited, log_entry.new_values['form_data'].keys())
            # all edited fields are in the "change message" field
            self.assertIn(field_edited, log_entry.change_message)

        # compare form data and stored new_values data
        for k,v in log_entry.new_values['form_data'].iteritems():
            form_value = form['journal-%s' % k].value
            self.assertEqual(log_entry.new_values['form_data'][k], force_unicode(v))
    def test_POST_valid_formdata_do_log(self):
        # with:
        perm_journal_change = _makePermission(perm="change_journal", model="journal", app_label="journalmanager")
        perm_journal_list = _makePermission(perm="list_journal", model="journal", app_label="journalmanager")
        self.user.user_permissions.add(perm_journal_change)
        self.user.user_permissions.add(perm_journal_list)

        sponsor = jm_modelfactories.SponsorFactory.create()
        use_license = jm_modelfactories.UseLicenseFactory.create()
        language = jm_modelfactories.LanguageFactory.create()
        subject_category = jm_modelfactories.SubjectCategoryFactory.create()
        study_area = jm_modelfactories.StudyAreaFactory.create()

        form = self.app.get(reverse("journal.add"), user=self.user).forms["journal-form"]
        form["journal-sponsor"] = [sponsor.pk]
        form["journal-study_areas"] = [study_area.pk]
        form["journal-ctrl_vocabulary"] = "decs"
        form["journal-frequency"] = "Q"
        form["journal-final_num"] = ""
        form["journal-eletronic_issn"] = "0102-6720"
        form["journal-init_vol"] = "1"
        form["journal-title"] = u"ABCD. Arquivos Brasileiros de Cirurgia Digestiva (São Paulo)"
        form["journal-title_iso"] = u"ABCD. Arquivos B. de C. D. (São Paulo)"
        form["journal-short_title"] = u"ABCD.(São Paulo)"
        form["journal-editorial_standard"] = "vancouv"
        form["journal-scielo_issn"] = "print"
        form["journal-init_year"] = "1986"
        form["journal-acronym"] = "ABCD"
        form["journal-pub_level"] = "CT"
        form["journal-init_num"] = "1"
        form["journal-final_vol"] = ""
        form["journal-subject_descriptors"] = "MEDICINA, CIRURGIA, GASTROENTEROLOGIA, GASTROENTEROLOGIA"
        form["journal-print_issn"] = "0102-6720"
        form["journal-copyrighter"] = "Texto do copyrighter"
        form["journal-publisher_name"] = "Colégio Brasileiro de Cirurgia Digestiva"
        form["journal-publisher_country"] = "BR"
        form["journal-publisher_state"] = "SP"
        form["journal-publication_city"] = "São Paulo"
        form["journal-editor_name"] = "Colégio Brasileiro de Cirurgia Digestiva"
        form["journal-editor_address"] = "Av. Brigadeiro Luiz Antonio, 278 - 6° - Salas 10 e 11"
        form["journal-editor_address_city"] = "São Paulo"
        form["journal-editor_address_state"] = "SP"
        form["journal-editor_address_zip"] = "01318-901"
        form["journal-editor_address_country"] = "BR"
        form["journal-editor_phone1"] = "(11) 3288-8174"
        form["journal-editor_phone2"] = "(11) 3289-0741"
        form["journal-editor_email"] = "*****@*****.**"
        form["journal-use_license"] = use_license.pk
        form["journal-languages"] = [language.pk]
        form["journal-abstract_keyword_languages"] = [language.pk]
        form.set("journal-subject_categories", [str(subject_category.pk)])
        form["journal-is_indexed_scie"] = True
        form["journal-is_indexed_ssci"] = False
        form["journal-is_indexed_aehci"] = True

        # when:
        response = form.submit().follow()

        # then:
        self.assertIn("Saved.", response.body)
        self.assertIn("ABCD.(São Paulo)", response.body)
        self.assertTemplateUsed(response, "journalmanager/journal_dash.html")

        self.assertEqual(audit_models.AuditLogEntry.objects.count(), 1)
        log_entry = audit_models.AuditLogEntry.objects.all()[0]
        audited_object = log_entry.get_audited_object()
        # inspect audited log entry data:
        self.assertEqual(log_entry.action_flag, audit_models.ADDITION)
        self.assertEqual(log_entry.object_id, unicode(audited_object.pk))
        self.assertEqual(log_entry.content_type, ContentType.objects.get_for_model(audited_object))
        self.assertEqual(log_entry.old_values, None)
        self.assertEqual(log_entry.user, self.user)

        fields_edited = [
            "sponsor",
            "use_license",
            "languages",
            "abstract_keyword_languages",
            "subject_categories",
            "study_areas",
            "title",
            "title_iso",
            "short_title",
            "acronym",
            "scielo_issn",
            "print_issn",
            "eletronic_issn",
            "subject_descriptors",
            "init_year",
            "init_vol",
            "init_num",
            "frequency",
            "editorial_standard",
            "ctrl_vocabulary",
            "pub_level",
            "copyrighter",
            "editor_name",
            "editor_address",
            "editor_address_city",
            "editor_address_state",
            "editor_address_zip",
            "editor_address_country",
            "editor_phone1",
            "editor_phone2",
            "editor_email",
            "publisher_name",
            "publisher_country",
            "publisher_state",
            "publication_city",
            "is_indexed_scie",
            "is_indexed_aehci",
        ]

        self.assertEqual(log_entry.new_values.keys(), [u"form_data", u"formsets_data"])
        for field_edited in fields_edited:
            # all edited fields are in "new_values"-dict
            self.assertIn(field_edited, log_entry.new_values["form_data"].keys())
            # all edited fields are in the "change message" field
            self.assertIn(field_edited, log_entry.change_message)

        # compare form data and stored new_values data
        for k, v in log_entry.new_values["form_data"].iteritems():
            form_value = form["journal-%s" % k].value
            self.assertEqual(log_entry.new_values["form_data"][k], force_unicode(v))