Example #1
0
 def test_CharIn_should_have_regex_constraint(self):
     value1 = "a"
     value2 = "b"
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.CharIn([value1, value2])]),
         ("regexp", "[ab]"),
     )
 def test_CharIn_should_have_regex_constraint(self):
     value1 = "a"
     value2 = "b"
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.CharIn([value1, value2])]),
         ("regexp", "[ab]"),
     )
Example #3
0
 def test_SequenceIn_should_have_regexp_constraint_when_there_are_regexp_in_terms(
     self
 ):
     values = ["a", "b*"]
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.SequenceIn(values)]),
         ("regexp", "(a|b*)"),
     )
Example #4
0
 def test_SequenceIn_should_have_regexp_constraint_when_there_are_regexp_in_terms(
         self):
     values = ["a", "b*"]
     self.assertEqual(
         bg_elasticsearch.parse_simple_component(
             [bg_glob.SequenceIn(values)]),
         ("regexp", "(a|b*)"),
     )
Example #5
0
 def test_None_component_should_trigger_Error(self):
     with self.assertRaisesRegexp(bg_elasticsearch.Error, "Unhandled type 'None'"):
         bg_elasticsearch.parse_simple_component([None])
Example #6
0
 def test_Globstar_component_should_trigger_Error(self):
     with self.assertRaisesRegexp(
         bg_elasticsearch.Error, "Unhandled type 'Globstar'"
     ):
         bg_elasticsearch.parse_simple_component([bg_glob.Globstar()])
Example #7
0
 def test_AnyChar_should_have_wildcard_constraint(self):
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.AnyChar()]),
         ("wildcard", "?"),
     )
Example #8
0
 def test_string_sequence_should_have_term_constraint(self):
     value = "foo"
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([value]), ("term", value)
     )
Example #9
0
 def test_any_sequence_should_have_no_constraint(self):
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.AnySequence()]),
         (None, None),
     )
Example #10
0
 def test_None_component_should_trigger_Error(self):
     with self.assertRaisesRegexp(bg_elasticsearch.Error,
                                  "Unhandled type 'None'"):
         bg_elasticsearch.parse_simple_component([None])
Example #11
0
 def test_Globstar_component_should_trigger_Error(self):
     with self.assertRaisesRegexp(bg_elasticsearch.Error,
                                  "Unhandled type 'Globstar'"):
         bg_elasticsearch.parse_simple_component([bg_glob.Globstar()])
Example #12
0
 def test_AnyChar_should_have_wildcard_constraint(self):
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.AnyChar()]),
         ("wildcard", "?"),
     )
Example #13
0
 def test_string_sequence_should_have_term_constraint(self):
     value = "foo"
     self.assertEqual(bg_elasticsearch.parse_simple_component([value]),
                      ("term", value))
Example #14
0
 def test_any_sequence_should_have_no_constraint(self):
     self.assertEqual(
         bg_elasticsearch.parse_simple_component([bg_glob.AnySequence()]),
         (None, None),
     )