예제 #1
0
 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__)
예제 #2
0
 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__)
예제 #3
0
 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__,
         )
예제 #4
0
 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].*")
예제 #5
0
 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__,
         )
예제 #6
0
 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].*")
예제 #7
0
 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__))
예제 #8
0
 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__))
예제 #9
0
 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__))
예제 #10
0
 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__),
             )
예제 #11
0
 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__),
             )
예제 #12
0
 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__,
                 ),
             )
예제 #13
0
 def test_string_should_be_translated_into_itself(self):
     _, result = bg_elasticsearch.parse_complex_component(["a"])
     self.assertEqual(result, "a")
예제 #14
0
 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)")
예제 #15
0
 def test_Globstar_should_be_translated_into_a_match_all_regexp(self):
     _, result = bg_elasticsearch.parse_complex_component([bg_glob.Globstar()])
     self.assertEqual(result, ".*")
예제 #16
0
 def test_string_should_be_translated_into_itself(self):
     _, result = bg_elasticsearch.parse_complex_component(["a"])
     self.assertEqual(result, "a")
예제 #17
0
 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]")
예제 #18
0
 def test_AnyChar_should_be_translated_into_a_question_mark(self):
     _, result = bg_elasticsearch.parse_complex_component([bg_glob.AnyChar()])
     self.assertEqual(result, "?")
예제 #19
0
 def test_AnySequence_should_be_translated_into_an_asterisk(self):
     _, result = bg_elasticsearch.parse_complex_component([bg_glob.AnySequence()])
     self.assertEqual(result, "*")
예제 #20
0
 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)")
예제 #21
0
 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]")
예제 #22
0
 def test_AnyChar_should_be_translated_into_a_question_mark(self):
     _, result = bg_elasticsearch.parse_complex_component(
         [bg_glob.AnyChar()])
     self.assertEqual(result, "?")
예제 #23
0
 def test_Globstar_should_be_translated_into_a_match_all_regexp(self):
     _, result = bg_elasticsearch.parse_complex_component(
         [bg_glob.Globstar()])
     self.assertEqual(result, ".*")
예제 #24
0
 def test_AnySequence_should_be_translated_into_an_asterisk(self):
     _, result = bg_elasticsearch.parse_complex_component(
         [bg_glob.AnySequence()])
     self.assertEqual(result, "*")