-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_doc.py
65 lines (54 loc) · 2.36 KB
/
test_doc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# coding: utf-8
import datetime
import unittest
import fastobo
# -- OboDoc ------------------------------------------------------------------
class TestOboDoc(unittest.TestCase):
type = fastobo.doc.OboDoc
def setUp(self):
self.header = fastobo.header.HeaderFrame([
fastobo.header.FormatVersionClause("1.4"),
fastobo.header.SavedByClause("Martin Larralde"),
])
self.entities = [
fastobo.term.TermFrame(fastobo.id.PrefixedIdent("MS", "1000031")),
fastobo.typedef.TypedefFrame(fastobo.id.UnprefixedIdent("part_of"))
]
def test_init(self):
try:
doc = self.type()
except Exception:
self.fail("could not create `OboDoc` instances")
self.assertEqual(len(doc.header), 0)
self.assertEqual(len(doc), 0)
def test_init_header(self):
try:
doc = self.type(self.header)
except Exception:
self.fail("could not create `OboDoc` instances with a header")
self.assertEqual(len(doc.header), 2)
self.assertEqual(doc.header[0], self.header[0])
self.assertEqual(doc.header[1], self.header[1])
self.assertEqual(len(doc), 0)
def test_init_entities(self):
try:
doc = self.type(entities=self.entities)
except Exception:
self.fail("could not create `OboDoc` instances with a header")
self.assertEqual(len(doc.header), 0)
self.assertEqual(len(doc), 2)
self.assertEqual(doc[0], self.entities[0])
self.assertEqual(doc[1], self.entities[1])
def test_init_type_error(self):
self.assertRaises(TypeError, self.type, 1)
self.assertRaises(TypeError, self.type, [1])
self.assertRaises(TypeError, self.type, ["abc"])
self.assertRaises(TypeError, self.type, "abc")
self.assertRaises(TypeError, self.type, self.header, 1)
self.assertRaises(TypeError, self.type, self.header, [1])
self.assertRaises(TypeError, self.type, self.header, ["abc"])
self.assertRaises(TypeError, self.type, self.header, "abc")
self.assertRaises(TypeError, self.type, 1, self.entities)
self.assertRaises(TypeError, self.type, [1], self.entities)
self.assertRaises(TypeError, self.type, ["abc"], self.entities)
self.assertRaises(TypeError, self.type, "abc", self.entities)