예제 #1
0
    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)
예제 #2
0
    def setUp(self):
        # create librarian group and those members
        self.librarian_group = modelfactories.GroupFactory(name="Librarian")
        self.librarian1 = auth.UserF(is_active=True)
        self.librarian2 = auth.UserF(is_active=True)

        self.librarian1.groups.add(self.librarian_group)
        self.librarian1.save()

        self.librarian2.groups.add(self.librarian_group)
        self.librarian2.save()

        self.collection = modelfactories.CollectionFactory.create()
        self.editor = auth.UserF(is_active=True)
        self.journal = modelfactories.JournalFactory.create(editor=self.editor)
        self.issue = modelfactories.IssueFactory(journal=self.journal)
        self.board = editorial_modelfactories.EditorialBoardFactory.create(issue=self.issue)
        self.member = editorial_modelfactories.EditorialMemberFactory.create(board=self.board)

        # link journal to collection
        jmodels.Membership.objects.create(journal=self.journal, collection=self.collection, created_by=auth.UserF(is_active=True))

        # link librarians and collection
        self.collection.add_user(self.librarian1)
        self.collection.add_user(self.librarian2)

        self.expected_recipients = []
        self.expected_bcc_recipients = [self.librarian1.email, self.librarian2.email, ]
        self.expected_subject_sufix_by_action = {
            'board_add_member': "Member of the journal board, was added",
            'board_edit_member': "Member of the journal board, was edited",
            'board_delete_member': "Member of the journal board, was deleted",
        }
예제 #3
0
 def setUp(self):
     self.editor = auth.UserF(is_active=True)
     self.journal = modelfactories.JournalFactory.create(editor=self.editor)
     self.issue = modelfactories.IssueFactory(journal=self.journal)
     self.expected_recipients = [self.editor.email, ]
     self.expected_subject_sufix_by_action = {
         'issue_add_no_replicated_board': "Issue Board can't be replicated",
         'issue_add_replicated_board': "Issue has a new replicated board",
     }
예제 #4
0
    def test_get_all_issues(self):
        """
        This interaction is performed by ajax requests, while
        querying for the list of issues of a given journal.
        """
        issue = modelfactories.IssueFactory(journal=self.journal,
                                            is_marked_up=False)
        issue2 = modelfactories.IssueFactory(journal=self.journal,
                                             is_marked_up=True)

        params = 'j={0}&all=1'.format(self.journal.pk)

        response = self.app.get(reverse('ajx.list_issues_for_markup_files') +
                                '?' + params,
                                headers={'x-requested-with': 'XMLHttpRequest'},
                                user=self.user,
                                expect_errors=True)

        response_data = json.loads(response.content)
        self.assertEqual(len(response_data), 2)
예제 #5
0
    def test_get_all_issues_passing_true_as_the_boolean_value(self):
        """
        The recommended values to be used as boolean params are 0 and 1.
        But we are already prepared to handle: True, true, yes, Yes, on,
        On, y, Y. Anything else is handled as False.
        """
        issue = modelfactories.IssueFactory(journal=self.journal,
                                            is_marked_up=False)
        issue2 = modelfactories.IssueFactory(journal=self.journal,
                                             is_marked_up=True)

        params = 'j={0}&all=true'.format(self.journal.pk)

        response = self.app.get(reverse('ajx.list_issues_for_markup_files') +
                                '?' + params,
                                headers={'x-requested-with': 'XMLHttpRequest'},
                                user=self.user,
                                expect_errors=True)

        response_data = json.loads(response.content)
        self.assertEqual(len(response_data), 2)
예제 #6
0
    def test_non_ajax_requests_gets_a_400_error(self):
        issue = modelfactories.IssueFactory(journal=self.journal,
                                            is_marked_up=False)

        params = 'j={0}&all=0'.format(self.journal.pk)

        response = self.app.get(reverse('ajx.list_issues_for_markup_files') +
                                '?' + params,
                                user=self.user,
                                status=400)

        self.assertEqual(response.status_code, 400)
예제 #7
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)
예제 #8
0
    def test_only_authenticated_users_can_query_issues(self):
        """
        Access to the Ajax that returns a list of issues for a
        given Journal.
        """
        issue = modelfactories.IssueFactory(journal=self.journal,
                                            is_marked_up=False)

        params = 'j={0}&all=0'.format(self.journal.pk)

        response = self.app.get(reverse('ajx.list_issues_for_markup_files') +
                                '?' + params,
                                headers={
                                    'x-requested-with': 'XMLHttpRequest'
                                },
                                status=302).follow()

        self.assertTemplateUsed(response, 'registration/login.html')
예제 #9
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)