def _compare_searches(self, invenio_syntax, spires_syntax): """Determine if two queries parse to the same search command. For comparison of actual search results (regression testing), see the tests in the Inspire module. """ parser = search_engine_query_parser.SearchQueryParenthesisedParser() converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() parsed_query = parser.parse_query(converter.convert_query(spires_syntax)) #parse_query removes any parens that convert_query added, but then #we have to rejoin the list it returns and create basic searches result_obtained = create_basic_search_units( None, ' '.join(parsed_query).replace('+ ',''), '', None ) # incase the desired result has parens parsed_wanted = parser.parse_query(invenio_syntax) result_wanted = create_basic_search_units( None, ' '.join(parsed_wanted).replace('+ ',''), '', None) assert result_obtained == result_wanted, \ """SPIRES parsed as %s instead of %s""" % \ (repr(result_obtained), repr(result_wanted)) return
def test_spires_syntax_detected_invenio(self): """SPIRES search syntax - test detection Not SPIRES""" # trac #261 converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() inv_search = converter.is_applicable("t:p a:c") self.assertEqual(inv_search, False)
def test_spires_syntax_detected_second_keyword(self): """SPIRES search syntax - test detection author:ellis and t muon""" converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() spi_search = converter.is_applicable("author:ellis and t muon") self.assertEqual(spi_search, True)
def test_spires_syntax_detected_naked_title(self): """SPIRES search syntax - test detection t muon""" converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() spi_search = converter.is_applicable("t muon") self.assertEqual(spi_search, True)
def test_spires_syntax_detected_naked_author_leading_spaces(self): """SPIRES search syntax - test detection author ellis""" converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() spi_search = converter.is_applicable(" author ellis") self.assertEqual(spi_search, True)
def test_spires_syntax_detected_fin(self): """SPIRES search syntax - test detection fin t p""" # trac #261 converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter() spi_search = converter.is_applicable("fin t p") self.assertEqual(spi_search, True)
def setUp(self): self.parser = search_engine_query_parser.SearchQueryParenthesisedParser() self.converter = search_engine_query_parser.SpiresToInvenioSyntaxConverter()