def test_init(self): e1 = osm.Element(self.d, {'foo': 'bar'}) e2 = osm.Element(self.d) self.assertEqual(e1.container, self.d) self.assertEqual(e1.tags['foo'], 'bar') self.assertEqual(e1.id, -1) self.assertEqual(e2.id, -2) e3 = osm.Element(self.d, attrs={'id': '4'}) self.assertEqual(e3.id, 4) self.assertEqual(self.d.counter, -2)
def test_is_new(self): e = osm.Element(self.d) self.assertTrue(e.is_new()) e.id = -random.randint(0, 1000) self.assertTrue(e.is_new()) e.id = random.randint(0, 1000) self.assertFalse(e.is_new())
def test_attrs(self): e = osm.Element(self.d) self.assertEqual(e.attrs, dict(action=e.action, visible=e.visible, id='-1')) e.id = 1 self.assertEqual(e.attrs['id'], '1') e.version = '2' self.assertEqual(e.attrs['version'], '2') e.timestamp = '3' self.assertEqual(e.attrs['timestamp'], '3') e.changeset = '4' self.assertEqual(e.attrs['changeset'], '4') e.uid = '5' self.assertEqual(e.attrs['uid'], '5') e.user = '******' self.assertEqual(e.attrs['user'], '6')
def test_set_attrs(self): e = osm.Element(self.d) e.attrs = dict(id=1, action='Delete', visible='False', foo='bar') self.assertEqual(e.id, 1) self.assertEqual(e.action, 'Delete') self.assertFalse(hasattr(e, 'foo'))