def test_not_handled_together(self): """ Tests the _handle_combined_trm_fol_limit method for an API that doesn't count accounts as search terms. """ specs = PipeSpecSheet.objects.get(pipe=2) # Twitter Public Streams API engineer = Engineer(query=self.query, specs=specs) queries = engineer._handle_combined_trm_fol_limit([self.query]) self.assertEqual(len(queries), 1)
def test_does_not_exceed_limit(self): """ Tests the _handle_combined_trm_fol_limit method for a query that includes accounts and search terms, but that doesn't exceed the API limit. """ specs = PipeSpecSheet.objects.get(pipe=1) # Twitter Search API engineer = Engineer(query=self.query, specs=specs) queries = engineer._handle_combined_trm_fol_limit([self.query]) self.assertEqual(len(queries), 1)
def test_no_accounts(self): """ Tests the _handle_combined_trm_fol_limit method for a query that doesn't include any accounts. """ terms = SearchTerm.objects.all() # exceeds search terms limit query = ReservoirQuery(searchterms=terms) specs = PipeSpecSheet.objects.get(pipe=1) # Twitter Search API engineer = Engineer(query=query, specs=specs) queries = engineer._handle_combined_trm_fol_limit([query]) self.assertEqual(len(queries), 1)
def test_no_searchterms(self): """ Tests the _handle_combined_trm_fol_limit method for a query that doesn't include any search terms. """ accounts = Account.objects.filter(pk__in=[1, 2, 3]) accounts = list(accounts).extend(accounts) # exceeds search terms limit query = ReservoirQuery(accounts=accounts) specs = PipeSpecSheet.objects.get(pipe=1) # Twitter Search API engineer = Engineer(query=query, specs=specs) queries = engineer._handle_combined_trm_fol_limit([query]) self.assertEqual(len(queries), 1)
def test_needs_splitting(self): """ Tests the _handle_combined_trm_fol_limit method for a query that includes accounts and search terms, but that doesn't exceed the API limit. """ specs = PipeSpecSheet(searchterms_limit=8, combine_trm_fol=True, trm_trm_logic='AND', combine_trm_opr=True, OR_operator='OR') engineer = Engineer(query=self.query, specs=specs) queries = engineer._handle_combined_trm_fol_limit([self.query]) self.assertEqual(len(queries), 2)