Ejemplo n.º 1
0
    def test_custom_filter_not_equal(self):

        journal = makeOneJournal({'title': 'title-%s' % str(uuid4().hex)})
        makeOneIssue({'journal': journal})
        column = Issue.journal
        custom_filter = CustomFilterNotEqual(column=column, name=__('Periódico'))

        result = custom_filter.apply(Issue.objects, journal.title)

        journals = Journal.objects.filter(Q(**{'title__ne': journal.title}))
        expected = Issue.objects.filter(Q(**{'%s__in' % column.name: journals}))

        self.assertListEqual([_ for _ in expected], [_ for _ in result])
Ejemplo n.º 2
0
    def test_custom_filter_not_in_list(self):

        journal = makeOneJournal({'title': 'title-%s' % str(uuid4().hex)})
        makeOneIssue({'journal': journal})
        column = Issue.journal
        custom_filter = CustomFilterNotInList(column=column, name=__(u'Periódico'))

        result = custom_filter.apply(Issue.objects, [journal.title])

        journals = Journal.objects.filter(Q(**{'title__nin': [journal.title]}))
        expected = Issue.objects.filter(Q(**{'%s__in' % column.name: journals}))

        self.assertItemsEqual(expected, result)
Ejemplo n.º 3
0
    def test_flt_search_reference_issue(self):

        journal = makeOneJournal()
        issue = makeOneIssue({'journal': journal})
        makeOneArticle({'journal': journal, 'issue': issue})

        op, term = parse_like_term(issue.label)
        result = get_flt(Article.issue, term, op)

        issues = Issue.objects.filter(Q(**{'label__%s' % op: term}))
        expected = Q(**{'issue__in': issues})

        self.assertIn('issue__in', result.query)
        self.assertItemsEqual(expected.query['issue__in'], result.query['issue__in'])
Ejemplo n.º 4
0
    def test_custom_filter_not_like(self):

        journal = makeOneJournal({'title': 'title-%s' % str(uuid4().hex)})
        makeOneIssue({'journal': journal})
        column = Issue.journal
        custom_filter = CustomFilterNotLike(column=column, name=__(u'Periódico'))

        result = custom_filter.apply(Issue.objects, journal.title)

        term, data = parse_like_term(journal.title)
        journals = Journal.objects.filter(Q(**{'title__not__%s' % term: data}))
        expected = Issue.objects.filter(Q(**{'%s__in' % column.name: journals}))

        self.assertItemsEqual(expected, result)
Ejemplo n.º 5
0
    def test_custom_filter_equal(self):

        journal_fields = {'title': 'title-%s' % str(uuid4().hex)}
        journal = makeOneJournal(journal_fields)
        makeOneIssue({'journal': journal})
        column = Issue.journal
        custom_filter = CustomFilterEqual(column=column, name=__(u'Periódico'))

        result = custom_filter.apply(Issue.objects, journal.title)

        journals = Journal.objects.filter(Q(**{'title__': journal.title}))
        expected = Issue.objects.filter(Q(**{'%s__in' % column.name: journals}))

        self.assertItemsEqual(expected, result)
Ejemplo n.º 6
0
    def test_flt_search_reference_issue(self):

        journal = makeOneJournal()
        issue = makeOneIssue({'journal': journal})
        makeOneArticle({'journal': journal, 'issue': issue})

        op, term = parse_like_term(issue.label)
        result = get_flt(Article.issue, term, op)

        issues = Issue.objects.filter(Q(**{'label__%s' % op: term}))
        expected = Q(**{'issue__in': issues})

        self.assertIn('issue__in', result.query)
        self.assertListEqual([_ for _ in expected.query['issue__in']],
                             [_ for _ in result.query['issue__in']])
Ejemplo n.º 7
0
    def test_flt_reference_journal(self):

        journal_fields = {
            'title': 'title-%s' % str(uuid4().hex),
            'title_iso': 'title_iso-%s' % str(uuid4().hex),
            'short_title': 'short_title-%s' % str(uuid4().hex),
            'acronym': 'acronym-%s' % str(uuid4().hex),
            'print_issn': 'print_issn-%s' % str(uuid4().hex),
            'eletronic_issn': 'eletronic_issn-%s' % str(uuid4().hex)}

        journal = makeOneJournal(journal_fields)
        makeOneIssue({'journal': journal})

        for field in journal_fields:
            op, term = parse_like_term(journal[field])
            result = get_flt(Issue.journal, term, op)

            journals = Journal.objects.filter(Q(**{'%s__%s' % (field, op): term}))
            expected = Q(**{'journal__in': journals})

            self.assertIn('journal__in', result.query)
            self.assertItemsEqual(expected.query['journal__in'], result.query['journal__in'])
Ejemplo n.º 8
0
    def test_flt_reference_journal(self):

        journal_fields = {
            'title': 'title-%s' % str(uuid4().hex),
            'title_iso': 'title_iso-%s' % str(uuid4().hex),
            'short_title': 'short_title-%s' % str(uuid4().hex),
            'acronym': 'acronym-%s' % str(uuid4().hex),
            'print_issn': 'print_issn-%s' % str(uuid4().hex),
            'eletronic_issn': 'eletronic_issn-%s' % str(uuid4().hex)}

        journal = makeOneJournal(journal_fields)
        makeOneIssue({'journal': journal})

        for field in journal_fields:
            op, term = parse_like_term(journal[field])
            result = get_flt(Issue.journal, term, op)

            journals = Journal.objects.filter(Q(**{'%s__%s' % (field, op): term}))
            expected = Q(**{'journal__in': journals})

            self.assertIn('journal__in', result.query)

            self.assertListEqual([_ for _ in expected.query['journal__in']],
                                 [_ for _ in result.query['journal__in']])