def test_regexp_component_should_be_parsed_as_regexp(self): for regexp_sample in self._regexp_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [regexp_sample]) self.assertEqual( parsed_type, "regexp", "%s should be parsed as a regexp" % type(regexp_sample).__name__)
def test_wildcard_component_should_be_parsed_as_wildcard(self): for wildcard_sample in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [wildcard_sample]) self.assertEqual( parsed_type, "wildcard", "%s should be parsed as a wildcard" % type(wildcard_sample).__name__)
def test_wildcard_component_should_be_parsed_as_wildcard(self): for wildcard_sample in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component([wildcard_sample]) self.assertEqual( parsed_type, "wildcard", "%s should be parsed as a wildcard" % type(wildcard_sample).__name__, )
def test_combination_of_glob_expressions_should_be_concatenated(self): _, result = bg_elasticsearch.parse_complex_component([ "foo", bg_glob.SequenceIn(["bar", "baz"]), bg_glob.CharNotIn(["a", "b"]), bg_glob.Globstar(), ]) self.assertEqual(result, "foo(bar|baz)[^ab].*")
def test_regexp_component_should_be_parsed_as_regexp(self): for regexp_sample in self._regexp_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component([regexp_sample]) self.assertEqual( parsed_type, "regexp", "%s should be parsed as a regexp" % type(regexp_sample).__name__, )
def test_combination_of_glob_expressions_should_be_concatenated(self): _, result = bg_elasticsearch.parse_complex_component( [ "foo", bg_glob.SequenceIn(["bar", "baz"]), bg_glob.CharNotIn(["a", "b"]), bg_glob.Globstar(), ] ) self.assertEqual(result, "foo(bar|baz)[^ab].*")
def test_combination_of_regexp_components_should_be_parsed_as_regexp(self): for regexp_sample_1 in self._regexp_samples: for regexp_sample_2 in self._regexp_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [regexp_sample_1, regexp_sample_2]) self.assertEqual( parsed_type, "regexp", "[%s, %s] should be parsed as a regexp" % (type(regexp_sample_1).__name__, type(regexp_sample_2).__name__))
def test_combination_of_regexp_and_wildcard_components_should_be_parsed_as_regexp( self): for regexp_sample in self._regexp_samples: for wildcard_sample in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [regexp_sample, wildcard_sample]) self.assertEqual( parsed_type, "regexp", "[%s, %s] should be parsed as a regexp" % (type(regexp_sample).__name__, type(wildcard_sample).__name__))
def test_combination_of_wildcard_components_should_be_parsed_as_wildcard( self): for wildcard_sample_1 in self._wildcard_samples: for wildcard_sample_2 in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [wildcard_sample_1, wildcard_sample_2]) self.assertEqual( parsed_type, "wildcard", "[%s, %s] should be parsed as a wildcard" % (type(wildcard_sample_1).__name__, type(wildcard_sample_2).__name__))
def test_combination_of_regexp_components_should_be_parsed_as_regexp(self): for regexp_sample_1 in self._regexp_samples: for regexp_sample_2 in self._regexp_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [regexp_sample_1, regexp_sample_2] ) self.assertEqual( parsed_type, "regexp", "[%s, %s] should be parsed as a regexp" % (type(regexp_sample_1).__name__, type(regexp_sample_2).__name__), )
def test_combination_of_regexp_and_wildcard_components_should_be_parsed_as_regexp( self ): for regexp_sample in self._regexp_samples: for wildcard_sample in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [regexp_sample, wildcard_sample] ) self.assertEqual( parsed_type, "regexp", "[%s, %s] should be parsed as a regexp" % (type(regexp_sample).__name__, type(wildcard_sample).__name__), )
def test_combination_of_wildcard_components_should_be_parsed_as_wildcard(self): for wildcard_sample_1 in self._wildcard_samples: for wildcard_sample_2 in self._wildcard_samples: parsed_type, _ = bg_elasticsearch.parse_complex_component( [wildcard_sample_1, wildcard_sample_2] ) self.assertEqual( parsed_type, "wildcard", "[%s, %s] should be parsed as a wildcard" % ( type(wildcard_sample_1).__name__, type(wildcard_sample_2).__name__, ), )
def test_string_should_be_translated_into_itself(self): _, result = bg_elasticsearch.parse_complex_component(["a"]) self.assertEqual(result, "a")
def test_SequenceIn_should_be_translated_into_an_enum_regexp(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.SequenceIn(["a", "b"])] ) self.assertEqual(result, "(a|b)")
def test_Globstar_should_be_translated_into_a_match_all_regexp(self): _, result = bg_elasticsearch.parse_complex_component([bg_glob.Globstar()]) self.assertEqual(result, ".*")
def test_CharNotIn_should_be_translated_into_a_range(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.CharNotIn(["a", "b"])] ) self.assertEqual(result, "[^ab]")
def test_AnyChar_should_be_translated_into_a_question_mark(self): _, result = bg_elasticsearch.parse_complex_component([bg_glob.AnyChar()]) self.assertEqual(result, "?")
def test_AnySequence_should_be_translated_into_an_asterisk(self): _, result = bg_elasticsearch.parse_complex_component([bg_glob.AnySequence()]) self.assertEqual(result, "*")
def test_SequenceIn_should_be_translated_into_an_enum_regexp(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.SequenceIn(["a", "b"])]) self.assertEqual(result, "(a|b)")
def test_CharNotIn_should_be_translated_into_a_range(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.CharNotIn(["a", "b"])]) self.assertEqual(result, "[^ab]")
def test_AnyChar_should_be_translated_into_a_question_mark(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.AnyChar()]) self.assertEqual(result, "?")
def test_Globstar_should_be_translated_into_a_match_all_regexp(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.Globstar()]) self.assertEqual(result, ".*")
def test_AnySequence_should_be_translated_into_an_asterisk(self): _, result = bg_elasticsearch.parse_complex_component( [bg_glob.AnySequence()]) self.assertEqual(result, "*")