29
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
1 import unittest |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
2 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
3 from datetime import datetime |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
4 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
5 from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, ValidationError |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
6 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
7 def minimalDoc(): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
8 """ create a minimal valid document """ |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
9 doc = CVRF('title', 'type') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
10 doc.setPublisher(CVRFPublisher('Other')) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
11 initial = datetime.now() |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
12 current = datetime.now() |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
13 track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
14 track.addRevision(CVRFRevision((0,0), current, '1st')) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
15 doc.setTracking(track) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
16 return doc |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
17 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
18 class TestCase(unittest.TestCase): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
19 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
20 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
21 def _validate(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
22 try: self.doc.validate() |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
23 except ValidationError as e: self.fail(e) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
24 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
25 def setUp(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
26 self.doc = minimalDoc() |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
27 self._validate() |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
28 |