/
test_magrathea.py
140 lines (111 loc) · 4.03 KB
/
test_magrathea.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# -*- coding: utf-8 -*-
"""
test.test_magrathea
~~~~~~~~~~~~~~~~~~~
:copyright: Copyright 2014 by the RootForum.org team, see AUTHORS.
:license: MIT License, see LICENSE for details.
"""
from unittest import TestCase, skipUnless
import magrathea
class TestMagrathea(TestCase):
"""
Unit tests for :py:mod:`magrathea`
"""
def test_01(self):
"""
Test Case 01:
Test type of :py:data:`magrathea.VERSION`
Test is passed if type of :py:data:`magrathea.VERSION` is a tuple
"""
self.assertIsInstance(magrathea.VERSION, tuple)
def test_02(self):
"""
Test Case 02:
Test length of :py:data:`magrathea.VERSION`
Test is passed if detected length is 5
"""
self.assertEqual(len(magrathea.VERSION), 5)
def test_03(self):
"""
Test Case 03:
Test type of first member of :py:data:`magrathea.VERSION`
Test is passed if detected type is :py:class:`int` and value is not negative
"""
self.assertIsInstance(magrathea.VERSION[0], int)
self.assertGreaterEqual(magrathea.VERSION[0], 0)
def test_04(self):
"""
Test Case 04:
Test type of second member of :py:data:`magrathea.VERSION`
Test is passed if detected type is :py:class:`int` and value is not negative
"""
self.assertIsInstance(magrathea.VERSION[1], int)
self.assertGreaterEqual(magrathea.VERSION[1], 0)
def test_05(self):
"""
Test Case 05:
Test type of third member of :py:data:`magrathea.VERSION`
Test is passed if detected type is :py:class:`int` and value is not negative
"""
self.assertIsInstance(magrathea.VERSION[2], int)
self.assertGreaterEqual(magrathea.VERSION[2], 0)
def test_06(self):
"""
Test Case 06:
Test type of fifth member of :py:data:`magrathea.VERSION`
Test is passed if detected type is :py:class:`int` and value is not negative
"""
self.assertIsInstance(magrathea.VERSION[4], int)
self.assertGreaterEqual(magrathea.VERSION[4], 0)
def test_07(self):
"""
Test Case 07:
Test type of fourth member of :py:data:`magrathea.VERSION`
Test is passed if member is one of ``alpha``, ``beta``, ``candidate``, ``final``
"""
allowed = ('alpha', 'beta', 'candidate', 'final')
self.assertIn(magrathea.VERSION[3], allowed)
@skipUnless(magrathea.VERSION[3] == 'final', 'Test is only for final releases')
def test_08(self):
"""
Test Case 08:
Test suffix plausibility for final releases
Test is passed if suffix is zero.
"""
self.assertEqual(magrathea.VERSION[4], 0)
@skipUnless(magrathea.VERSION[3] in ('beta', 'candidate'), 'Test is only for pre-releases')
def test_09(self):
"""
Test Case 09:
Test suffix plausibility for pre-releases
Test is passed if suffix is greater than zero.
"""
self.assertGreater(magrathea.VERSION[4], 0)
def test_10(self):
"""
Test Case 10:
Test type of :py:data:`magrathea.COPYRIGHT`
Test is passed if type of :py:data:`magrathea.COPYRIGHT` is a tuple
"""
self.assertIsInstance(magrathea.COPYRIGHT, tuple)
def test_11(self):
"""
Test Case 11:
Test length of :py:data:`magrathea.COPYRIGHT`
Test is passed if detected length is 2
"""
self.assertEqual(len(magrathea.COPYRIGHT), 2)
def test_12(self):
"""
Test Case 12:
Test type of first member of :py:data:`magrathea.COPYRIGHT`
Test is passed if detected type is :py:class:`str`
"""
self.assertIsInstance(magrathea.COPYRIGHT[0], str)
def test_13(self):
"""
Test Case 13:
Test type of second member of :py:data:`magrathea.COPYRIGHT`
Test is passed if detected type is :py:class:`str`
"""
self.assertIsInstance(magrathea.COPYRIGHT[1], str)