-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmtest.py
53 lines (39 loc) · 1.52 KB
/
rmtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import rm
import unittest
class TestModel(rm.Model):
a = rm.Attribute()
b = rm.Attribute()
class ModelTests(unittest.TestCase):
def testCreateDelete(self):
count = TestModel.objects.count()
instance = TestModel(a='text a', b='text b')
self.assertFalse(instance.id)
instance.save()
self.assertTrue(instance.id)
self.assertTrue(TestModel.objects.contains(instance.id))
new_count = TestModel.objects.count()
self.assertEquals(count+1, new_count)
new_instance = TestModel.get(id=instance.id)
self.assertTrue(new_instance)
self.assertEquals(new_instance.a, 'text a')
self.assertEquals(new_instance.b, 'text b')
new_instance.a = 'new a'
new_instance.save()
self.assertEquals(instance.id, new_instance.id)
new_instance_2 = TestModel.get(id=instance.id)
self.assertEquals(new_instance_2.a, 'new a')
self.assertEquals(new_instance_2.b, 'text b')
instance.delete()
self.assertFalse(TestModel.get(id=instance.id))
self.assertFalse(TestModel.objects.contains(instance.id))
new_count = TestModel.objects.count()
self.assertEquals(count, new_count)
instance = TestModel.create(a='text a', b='text b')
self.assertTrue(instance.id)
instance.delete()
new_count = TestModel.objects.count()
self.assertEquals(count, new_count)
def testSlicing(self):
pass # TODO
if __name__ == "__main__":
unittest.main()