def test_tostring(self): cont = Contact('test') result = '<item approved="false" jid="test" subscription="none" />' self.assertEqual(ET.tostring(cont.to_element()), result) result = '<item approved="false" jid="test" />' cont.subscription = None self.assertEqual(ET.tostring(cont.to_element()), result) result = '<item jid="test" />' cont.approved = None self.assertEqual(ET.tostring(cont.to_element()), result) result = '<item ask="subscribe" jid="test" name="Joe" />' cont.ask = 'subscribe' cont.name = "Joe" self.assertEqual(ET.tostring(cont.to_element()), result)
def test_invalid_value(self): cont = Contact('test') with self.assertRaises(ValueError): cont.subscription = "fail"