diff options
Diffstat (limited to 'tests/test_implements.py')
-rw-r--r-- | tests/test_implements.py | 51 |
1 files changed, 51 insertions, 0 deletions
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 | ||