diff options
author | Mike Crute <mcrute@gmail.com> | 2015-07-28 21:15:06 -0700 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2015-07-28 21:15:06 -0700 |
commit | 6da717bf333dc82c67d7aece3fd36f97090040f8 (patch) | |
tree | 056bb5e2ef5642d836425c2ac85212d3328364bb /tests | |
download | foundry-master.tar.bz2 foundry-master.tar.xz foundry-master.zip |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_frozendict.py | 19 | ||||
-rw-r--r-- | tests/test_implements.py | 51 |
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/test_frozendict.py b/tests/test_frozendict.py new file mode 100644 index 0000000..3f8045d --- /dev/null +++ b/tests/test_frozendict.py | |||
@@ -0,0 +1,19 @@ | |||
1 | from foundry.utils import frozendict | ||
2 | from nose.tools import raises | ||
3 | |||
4 | |||
5 | class TestFrozenDict(object): | ||
6 | |||
7 | def setup(self): | ||
8 | self.inputs = { 'foo': 'bar' } | ||
9 | self.dict_ = frozendict(self.inputs) | ||
10 | |||
11 | @raises(AttributeError) | ||
12 | def test_should_not_allow_assignment(self): | ||
13 | self.dict_['bar'] = 'baz' | ||
14 | |||
15 | def test_should_use_precomputed_hash(self): | ||
16 | assert hash(self.dict_) == self.dict_._frozendict__hash | ||
17 | |||
18 | def test_should_set_slots(self): | ||
19 | assert self.dict_.__slots__ == self.inputs.keys() | ||
diff --git a/tests/test_implements.py b/tests/test_implements.py new file mode 100644 index 0000000..48ffe4b --- /dev/null +++ b/tests/test_implements.py | |||
@@ -0,0 +1,51 @@ | |||
1 | # vim: set filencoding=utf8 | ||
2 | """ | ||
3 | Implements Decorator Tests | ||
4 | |||
5 | @author: Mike Crute (mcrute@gmail.com) | ||
6 | @organization: SoftGroup Interactive, Inc. | ||
7 | @date: May 02, 2010 | ||
8 | """ | ||
9 | |||
10 | |||
11 | from foundry.utils import implements | ||
12 | from nose.tools import raises | ||
13 | |||
14 | |||
15 | class MyInterface(object): | ||
16 | |||
17 | def get(self, foo): | ||
18 | pass | ||
19 | |||
20 | def set(self, bar, baz=None): | ||
21 | pass | ||
22 | |||
23 | def remove(self, *args, **kwargs): | ||
24 | pass | ||
25 | |||
26 | |||
27 | def test_conforming_should_not_fail(): | ||
28 | @implements(MyInterface, debug=True) | ||
29 | class Conforming(object): | ||
30 | |||
31 | def get(self, foo): | ||
32 | pass | ||
33 | |||
34 | def set(self, bar, baz=None): | ||
35 | pass | ||
36 | |||
37 | def remove(self, *args, **kwargs): | ||
38 | pass | ||
39 | |||
40 | |||
41 | @raises(AssertionError) | ||
42 | def test_non_conforming_should_fail(): | ||
43 | @implements(MyInterface, debug=True) | ||
44 | class NonConforming(object): | ||
45 | pass | ||
46 | |||
47 | |||
48 | def test_non_debug_should_do_nothing(): | ||
49 | @implements(MyInterface) | ||
50 | class NonConforming(object): | ||
51 | pass | ||