Exemplo n.º 1
0
 def test_check_operator_comparison(self):
     string_type = StringType('yo yo')
     with patch.object(string_type, 'contains', return_value=True):
         result = engine._do_operator_comparison(
             string_type, 'contains', 'its mocked')
         self.assertTrue(result)
         string_type.contains.assert_called_once_with('its mocked')
Exemplo n.º 2
0
 def test_non_empty(self):
     self.assertTrue(StringType("hello").non_empty())
     self.assertFalse(StringType("").non_empty())
     self.assertFalse(StringType(None).non_empty())
Exemplo n.º 3
0
 def test_string_contains(self):
     self.assertTrue(StringType("hello").contains("ell"))
     self.assertTrue(StringType("hello").contains("he"))
     self.assertTrue(StringType("hello").contains("lo"))
     self.assertFalse(StringType("hello").contains("asdf"))
     self.assertFalse(StringType("hello").contains("ElL"))
Exemplo n.º 4
0
 def test_string_matches_regex(self):
     self.assertTrue(StringType("hello").matches_regex(r"^h"))
     self.assertFalse(StringType("hello").matches_regex(r"^sh"))
Exemplo n.º 5
0
 def test_string_starts_with(self):
     self.assertTrue(StringType("hello").starts_with("he"))
     self.assertFalse(StringType("hello").starts_with("hey"))
     self.assertFalse(StringType("hello").starts_with("He"))
Exemplo n.º 6
0
 def test_string_ends_with(self):
     self.assertTrue(StringType("hello").ends_with("lo"))
     self.assertFalse(StringType("hello").ends_with("boom"))
     self.assertFalse(StringType("hello").ends_with("Lo"))
Exemplo n.º 7
0
 def test_string_equal_to_case_insensitive(self):
     self.assertTrue(StringType("foo").equal_to_case_insensitive("FOo"))
     self.assertTrue(StringType("foo").equal_to_case_insensitive("foo"))
     self.assertFalse(StringType("foo").equal_to_case_insensitive("blah"))
Exemplo n.º 8
0
 def test_string_equal_to(self):
     self.assertTrue(StringType("foo").equal_to("foo"))
     self.assertFalse(StringType("foo").equal_to("Foo"))
Exemplo n.º 9
0
 def test_operator_decorator(self):
     self.assertTrue(StringType("foo").equal_to.is_operator)
Exemplo n.º 10
0
 def test_invalid_value(self):
     with self.assertRaises(AssertionError):
         StringType(123)
Exemplo n.º 11
0
 def test_string_not_equal_to(self):
     self.assertTrue(StringType("foo").not_equal_to("bar"))
     self.assertTrue(StringType("foo").not_equal_to("Foo"))