forked from onyb/reobject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprototype.py
35 lines (24 loc) · 814 Bytes
/
prototype.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
# -*- coding: utf-8 -*-
import unittest
from copy import deepcopy
from reobject.models import Model
class Prototype(Model):
value = 'default'
def clone(self, **attrs):
obj = deepcopy(self)
obj.__dict__.update(attrs)
return obj
class TestPrototype(unittest.TestCase):
def setUp(self):
self.prototype = Prototype()
self.prototype.clone()
self.prototype.clone(value='a-value', category='a')
self.prototype.clone(value='b-value', is_checked=True)
def test_dispatcher(self):
self.assertEqual(Prototype.objects.count(), 4)
self.assertSetEqual(
set(Prototype.objects.all().values_list('value', flat=True)),
{'a-value', 'default', 'b-value'}
)
if __name__ == '__main__':
unittest.main()