1 | Certificates |
---|
2 | ************ |
---|
3 | |
---|
4 | :Test-Layer: unit |
---|
5 | |
---|
6 | Creating certificates |
---|
7 | ===================== |
---|
8 | |
---|
9 | Because certificates make use of components registered with the Zope |
---|
10 | Component Architecture (ZCA), we first have to grok the `waeup` |
---|
11 | package. This happens automatically in real-world use: |
---|
12 | |
---|
13 | >>> import grok |
---|
14 | >>> grok.testing.grok('waeup') |
---|
15 | |
---|
16 | We can create certificates: |
---|
17 | |
---|
18 | >>> from waeup.university.certificate import Certificate |
---|
19 | >>> mycertificate = Certificate() |
---|
20 | >>> mycertificate |
---|
21 | <waeup.university.certificate.Certificate object at 0x...> |
---|
22 | |
---|
23 | Another way to create certificates is by asking for a factory called |
---|
24 | ``waeup.Certificate``. This way we can create a factory without |
---|
25 | importing a class: |
---|
26 | |
---|
27 | >>> from zope.component import createObject |
---|
28 | >>> mycertificate = createObject(u'waeup.Certificate') |
---|
29 | >>> mycertificate |
---|
30 | <waeup.university.certificate.Certificate object at 0x...> |
---|
31 | |
---|
32 | |
---|
33 | Certificate attributes |
---|
34 | ====================== |
---|
35 | |
---|
36 | Certificates have the attributes required by the `ICertificate` interface: |
---|
37 | |
---|
38 | >>> from waeup.interfaces import ICertificate |
---|
39 | >>> ICertificate.providedBy(mycertificate) |
---|
40 | True |
---|
41 | |
---|
42 | >>> from zope.interface.verify import verifyObject |
---|
43 | >>> verifyObject(ICertificate, mycertificate) |
---|
44 | True |
---|
45 | |
---|
46 | Each of the following attributes is mandatory. |
---|
47 | |
---|
48 | `title` |
---|
49 | ------- |
---|
50 | |
---|
51 | Each certificate has a title: |
---|
52 | |
---|
53 | >>> mycertificate.title |
---|
54 | u'Unnamed Certificate' |
---|
55 | |
---|
56 | `code` |
---|
57 | ------ |
---|
58 | |
---|
59 | Each certificate holds a code, which might be a shortcut or abbreviation |
---|
60 | of the real certificate name. By default the code is ``NA`` (=not assigned): |
---|
61 | |
---|
62 | >>> mycertificate.code |
---|
63 | u'NA' |
---|
64 | |
---|
65 | `review_state` |
---|
66 | -------------- |
---|
67 | |
---|
68 | The review state can have one of the ``checking`` states defined in |
---|
69 | the WAeUP workflow. These are at least the states ``checked`` and |
---|
70 | ``unchecked``. After a certificate is created, the review state is |
---|
71 | ``unchecked``: |
---|
72 | |
---|
73 | >>> mycertificate.review_state |
---|
74 | 'unchecked' |
---|
75 | |
---|
76 | We can mark a certificate as checked: |
---|
77 | |
---|
78 | >>> mycertificate.check() |
---|
79 | >>> mycertificate.review_state |
---|
80 | 'checked' |
---|
81 | |
---|
82 | We cannot uncheck a certificate: |
---|
83 | |
---|
84 | >>> mycertificate.review_state = 'init' |
---|