コード例 #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, "*")