annotate tests/utils.py @ 33:bd2ae8de33c1

Add a .hgignore
author Benoît Allard <benoit.allard@greenbone.net>
date Tue, 04 Nov 2014 16:21:04 +0100
parents e3ee542a89be
children
rev   line source
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
1 import unittest
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
2
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
3 from datetime import datetime
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
4
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
5 from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, ValidationError
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
6
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
7 def minimalDoc():
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
8 """ create a minimal valid document """
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
9 doc = CVRF('title', 'type')
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
10 doc.setPublisher(CVRFPublisher('Other'))
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
11 initial = datetime.now()
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
12 current = datetime.now()
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
13 track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current)
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
14 track.addRevision(CVRFRevision((0,0), current, '1st'))
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
15 doc.setTracking(track)
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
16 return doc
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
17
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
18 class TestCase(unittest.TestCase):
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
19
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
20
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
21 def _validate(self):
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
22 try: self.doc.validate()
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
23 except ValidationError as e: self.fail(e)
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
24
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
25 def setUp(self):
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
26 self.doc = minimalDoc()
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
27 self._validate()
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
28
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)