-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests for existence queries
- Loading branch information
Showing
1 changed file
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", "") | ||
|