def test_query_filter_for_tags_any(self):
        tags = ['tag3', 'tag4']

        res = DjangoGateway._query_problems(tags_any=tags)

        self.assertEqual(len(res), 2)
        self.assertEqual(sorted([prob.name for prob in res]),
                         ['many_tags', 'single_tag'])
    def test_query_filter_for_tags_all(self):
        required_tags = ['tag1', 'tag2']

        res = DjangoGateway._query_problems(tags_all=required_tags)

        self.assertEqual(len(res), 3)
        self.assertEqual(sorted([prob.name for prob in res]),
                         ['many_tags', 'prob_1', 'prob_2'])
 def test_query_filter_by_substring(self):
     self.assertEqual(2,
                      len(DjangoGateway._query_problems(name_substr='pro')))
     self.assertEqual(1,
                      len(DjangoGateway._query_problems(name_substr='_1')))
 def test_query_filter_by_name(self):
     self.assertEqual(1, len(DjangoGateway._query_problems(name='prob_1')))
 def test_query_all(self):
     self.assertEqual(4, len(DjangoGateway._query_problems(name=None)))
    def test_query_combined(self):
        res = DjangoGateway._query_problems(
            name_substr='b',  # exclude 'many_tags'
            tags_all=['tag1', 'tag2'])  # exclude 'single_tag'

        self.assertEqual(['prob_1', 'prob_2'], sorted([p.name for p in res]))