Skip to content

Commit

Permalink
Add more tests for existence queries
Browse files Browse the repository at this point in the history
  • Loading branch information
lucc committed Dec 25, 2024
1 parent ffdb103 commit a756186
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,28 @@ def test_and_queries_match_after_sorting(self):


class TestFieldQuery(unittest.TestCase):
def test_empty_field_values_match_if_the_field_is_present(self):
def test_empty_field_values_match_if_sstring_field_is_present(self):
uid = "Some Test Uid"
vcard1 = TestContact(uid=uid)
vcard2 = TestContact()
query = FieldQuery("uid", "")
self.assertTrue(query.match(vcard1))
self.assertFalse(query.match(vcard2))

def test_empty_field_values_match_if_list_field_is_present(self):
vcard1 = TestContact(categories=["foo", "bar"])
vcard2 = TestContact()
query = FieldQuery("categories", "")
self.assertTrue(query.match(vcard1))
self.assertFalse(query.match(vcard2))

def test_empty_field_values_match_if_dict_field_is_present(self):
query = FieldQuery("emails", "")
vcard = TestContact()
self.assertFalse(query.match(vcard))
vcard.add_email("home", "[email protected]")
self.assertTrue(query.match(vcard))

def test_empty_field_values_fails_if_the_field_is_absent(self):
vcard = TestContact()
query = FieldQuery("emails", "")
Expand Down

0 comments on commit a756186

Please sign in to comment.