def test_keeps_other_fields(self): vcard = vCard(foo='bar') expected = vcard.serialize() vcard.add('BAR').value = 'baz' wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object('BAR') self.assertEqual(wrapper.vcard.serialize(), expected)
def test_deletes_fields_given_in_upper_case(self): vcard = vCard() expected = vcard.serialize() vcard.add('FOO').value = 'bar' wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object('FOO') self.assertEqual(wrapper.vcard.serialize(), expected)
def test_deletes_all_field_occurences(self): vcard = vCard() expected = vcard.serialize() vcard.add('FOO').value = 'bar' vcard.add('FOO').value = 'baz' wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object('FOO') self.assertEqual(wrapper.vcard.serialize(), expected)
def test_deletes_grouped_ablabel_fields(self): vcard = vCard() expected = vcard.serialize() foo = vcard.add('FOO') foo.value = 'bar' foo.group = 'group1' label = vcard.add('X-ABLABEL') label.value = 'test label' label.group = foo.group wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object('FOO') self.assertEqual(wrapper.vcard.serialize(), expected)
def test_does_not_fail_on_non_existing_field_name(self): vcard = vCard(foo='bar') expected = vcard.serialize() wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object('BAR') self.assertEqual(wrapper.vcard.serialize(), expected)
def test_setting_fn_from_labelled_org(self): vcard = create_test_vcard() wrapper = VCardWrapper(vcard) wrapper._delete_vcard_object("FN") wrapper._add_organisation({'Work': ['Test Inc']}) self.assertEqual(wrapper.formatted_name, 'Test Inc')