Skip to content

Commit 1127f06

Browse files
committed
Add a test to ensure that object attributes don't collide with dictionary data.
1 parent d2b9f8b commit 1127f06

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

embedly/tests.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_model(self):
4242
'embeds': []
4343
}
4444

45-
obj = Url(data, 'preview', 'http://google.com/')
45+
obj = Url(data, 'preview', 'http://original.url.com/')
4646

4747
self.assertTrue(len(obj) is 17)
4848
self.assertTrue(len(obj.values()) is 17)
@@ -57,6 +57,20 @@ def test_model(self):
5757
self.assertEqual(obj.data['type'], 'html')
5858
self.assertEqual(obj.data.get('type'), 'html')
5959

60+
# our special attrs shouldn't be in the data dict
61+
self.assertFalse('method' in obj.keys())
62+
with self.assertRaises(KeyError):
63+
obj['method']
64+
65+
# attrs and data dict values should be separate
66+
self.assertEqual(obj['original_url'], 'http://google.com/')
67+
self.assertEqual(obj.original_url, 'http://original.url.com/')
68+
69+
obj.new_attr = 'attr value'
70+
obj['new_key'] = 'dict value'
71+
self.assertEqual(obj.new_attr, 'attr value')
72+
self.assertEqual(obj['new_key'], 'dict value')
73+
6074
def test_model_data_can_serialize(self):
6175
obj = Url({'a': {'key': 'value'}})
6276
unserialzed = json.loads(json.dumps(obj.data))

0 commit comments

Comments
 (0)