def test_adding_a_simple_address(self): vcard = create_test_vcard() wrapper = VCardWrapper(vcard) components = ('box', 'extended', 'street', 'code', 'city', 'region', 'country') wrapper._add_post_address('home', *components) expected = {item: item for item in components} self.assertDictEqual(wrapper.post_addresses, {'home': [expected]})
def test_adding_preferred_address(self): vcard = create_test_vcard() wrapper = VCardWrapper(vcard) components = ('box', 'extended', 'street', 'code', 'city', 'region', 'country') wrapper._add_post_address('home', *['home1 ' + c for c in components]) wrapper._add_post_address('pref,home', *['home2 ' + c for c in components]) expected_work = {item: 'work ' + item for item in components} expected_home2 = {item: 'home2 ' + item for item in components} expected_home1 = {item: 'home1 ' + item for item in components} self.assertDictEqual(wrapper.post_addresses, { 'home': [expected_home1], 'home, pref': [expected_home2] })
def test_adding_multible_addresses(self): vcard = create_test_vcard() wrapper = VCardWrapper(vcard) components = ('box', 'extended', 'street', 'code', 'city', 'region', 'country') wrapper._add_post_address('work', *['work ' + c for c in components]) wrapper._add_post_address('home', *['home1 ' + c for c in components]) wrapper._add_post_address('home', *['home2 ' + c for c in components]) expected_work = {item: 'work ' + item for item in components} expected_home2 = {item: 'home2 ' + item for item in components} expected_home1 = {item: 'home1 ' + item for item in components} self.assertDictEqual( wrapper.post_addresses, # The lists are sorted! { 'home': [expected_home1, expected_home2], 'work': [expected_work] })