예제 #1
0
    def test_do_not_count_operator(self):
        """
        Tests the get_num_searchterms method when operators are not counted
        as search terms. Uses the Twitter Public Streams API as an example.
        """
        terms = SearchTerm.objects.filter(pk=1)
        accounts = Account.objects.filter(pk__in=[1, 2])
        query = ReservoirQuery(searchterms=terms, accounts=accounts)
        specs = PipeSpecSheet.objects.get(pipe=2)  # Twitter Public Streams API
        engineer = Engineer(query=query, specs=specs)

        # expect 1: 1 for SearchTerm
        self.assertEqual(engineer.get_num_searchterms(query), 1)
예제 #2
0
    def test_with_or_operator(self):
        """
        Tests the get_num_searchterms method when operators are counted as
        search terms, the default logic is "AND", and an "OR" operator can
        be used to join terms. Uses the Twitter Search API as an example.
        """
        terms = SearchTerm.objects.filter(pk=1)
        accounts = Account.objects.filter(pk__in=[1, 2])
        query = ReservoirQuery(searchterms=terms, accounts=accounts)
        specs = PipeSpecSheet.objects.get(pipe=1)  # Twitter Search API
        engineer = Engineer(query=query, specs=specs)

        # expect 5: 1 for SearchTerm, 2 for Accounts, 2 for "OR" operators
        self.assertEqual(engineer.get_num_searchterms(query), 5)
예제 #3
0
    def test_without_or(self):
        """
        Tests the get_num_searchterms method when the operators are counted as
        search terms and the default logic is "OR".
        """
        terms = SearchTerm.objects.filter(pk=1)
        accounts = Account.objects.filter(pk__in=[1, 2])
        query = ReservoirQuery(searchterms=terms, accounts=accounts)
        specs = PipeSpecSheet(combine_trm_fol=True,
                              combine_trm_opr=True,
                              trm_trm_logic='OR',
                              OR_operator='OR')
        engineer = Engineer(query=query, specs=specs)

        # expect 5: 1 for SearchTerm, 2 for Accounts
        self.assertEqual(engineer.get_num_searchterms(query), 3)