7 @unittest.skip("this is broken")
8 class ClockClassOffsetTestCase(unittest
.TestCase
):
9 def test_create_default(self
):
10 cco
= bt2
.ClockClassOffset()
11 self
.assertEqual(cco
.seconds
, 0)
12 self
.assertEqual(cco
.cycles
, 0)
14 def test_create(self
):
15 cco
= bt2
.ClockClassOffset(23, 4871232)
16 self
.assertEqual(cco
.seconds
, 23)
17 self
.assertEqual(cco
.cycles
, 4871232)
19 def test_create_kwargs(self
):
20 cco
= bt2
.ClockClassOffset(seconds
=23, cycles
=4871232)
21 self
.assertEqual(cco
.seconds
, 23)
22 self
.assertEqual(cco
.cycles
, 4871232)
24 def test_create_invalid_seconds(self
):
25 with self
.assertRaises(TypeError):
26 bt2
.ClockClassOffset('hello', 4871232)
28 def test_create_invalid_cycles(self
):
29 with self
.assertRaises(TypeError):
30 bt2
.ClockClassOffset(23, 'hello')
33 cco1
= bt2
.ClockClassOffset(23, 42)
34 cco2
= bt2
.ClockClassOffset(23, 42)
35 self
.assertEqual(cco1
, cco2
)
37 def test_ne_seconds(self
):
38 cco1
= bt2
.ClockClassOffset(23, 42)
39 cco2
= bt2
.ClockClassOffset(24, 42)
40 self
.assertNotEqual(cco1
, cco2
)
42 def test_ne_cycles(self
):
43 cco1
= bt2
.ClockClassOffset(23, 42)
44 cco2
= bt2
.ClockClassOffset(23, 43)
45 self
.assertNotEqual(cco1
, cco2
)
47 def test_eq_invalid(self
):
48 self
.assertFalse(bt2
.ClockClassOffset() == 23)
51 @unittest.skip("this is broken")
52 class ClockClassTestCase(unittest
.TestCase
):
54 self
._cc
= bt2
.ClockClass('salut', 1000000)
59 def test_create_default(self
):
60 self
.assertEqual(self
._cc
.name
, 'salut')
62 def test_create_invalid_no_name(self
):
63 with self
.assertRaises(TypeError):
66 def test_create_full(self
):
67 my_uuid
= uuid
.uuid1()
68 cc
= bt2
.ClockClass(name
='name', description
='some description',
69 frequency
=1001, precision
=176,
70 offset
=bt2
.ClockClassOffset(45, 3003),
71 is_absolute
=True, uuid
=my_uuid
)
72 self
.assertEqual(cc
.name
, 'name')
73 self
.assertEqual(cc
.description
, 'some description')
74 self
.assertEqual(cc
.frequency
, 1001)
75 self
.assertEqual(cc
.precision
, 176)
76 self
.assertEqual(cc
.offset
, bt2
.ClockClassOffset(45, 3003))
77 self
.assertEqual(cc
.is_absolute
, True)
78 self
.assertEqual(cc
.uuid
, copy
.deepcopy(my_uuid
))
80 def test_assign_name(self
):
81 self
._cc
.name
= 'the_clock'
82 self
.assertEqual(self
._cc
.name
, 'the_clock')
84 def test_assign_invalid_name(self
):
85 with self
.assertRaises(TypeError):
88 def test_assign_description(self
):
89 self
._cc
.description
= 'hi people'
90 self
.assertEqual(self
._cc
.description
, 'hi people')
92 def test_assign_invalid_description(self
):
93 with self
.assertRaises(TypeError):
94 self
._cc
.description
= 23
96 def test_assign_frequency(self
):
97 self
._cc
.frequency
= 987654321
98 self
.assertEqual(self
._cc
.frequency
, 987654321)
100 def test_assign_invalid_frequency(self
):
101 with self
.assertRaises(TypeError):
102 self
._cc
.frequency
= 'lel'
104 def test_assign_precision(self
):
105 self
._cc
.precision
= 12
106 self
.assertEqual(self
._cc
.precision
, 12)
108 def test_assign_invalid_precision(self
):
109 with self
.assertRaises(TypeError):
110 self
._cc
.precision
= 'lel'
112 def test_assign_offset(self
):
113 self
._cc
.offset
= bt2
.ClockClassOffset(12, 56)
114 self
.assertEqual(self
._cc
.offset
, bt2
.ClockClassOffset(12, 56))
116 def test_assign_invalid_offset(self
):
117 with self
.assertRaises(TypeError):
118 self
._cc
.offset
= object()
120 def test_assign_absolute(self
):
121 self
._cc
.is_absolute
= True
122 self
.assertTrue(self
._cc
.is_absolute
)
124 def test_assign_invalid_absolute(self
):
125 with self
.assertRaises(TypeError):
126 self
._cc
.is_absolute
= 23
128 def test_assign_uuid(self
):
129 the_uuid
= uuid
.uuid1()
130 self
._cc
.uuid
= the_uuid
131 self
.assertEqual(self
._cc
.uuid
, the_uuid
)
133 def test_assign_invalid_uuid(self
):
134 with self
.assertRaises(TypeError):
135 self
._cc
.uuid
= object()
137 def test_create_clock_snapshot(self
):
139 self
.assertEqual(cs
.clock_class
.addr
, self
._cc
.addr
)
141 def _test_copy(self
, cpy
):
142 self
.assertIsNot(cpy
, self
._cc
)
143 self
.assertNotEqual(cpy
.addr
, self
._cc
.addr
)
144 self
.assertEqual(cpy
, self
._cc
)
147 cpy
= copy
.copy(self
._cc
)
150 def test_deepcopy(self
):
151 cpy
= copy
.deepcopy(self
._cc
)
155 my_uuid
= uuid
.uuid1()
156 cc1
= bt2
.ClockClass(name
='name', description
='some description',
157 frequency
=1001, precision
=176,
158 offset
=bt2
.ClockClassOffset(45, 3003),
159 is_absolute
=True, uuid
=my_uuid
)
160 cc2
= bt2
.ClockClass(name
='name', description
='some description',
161 frequency
=1001, precision
=176,
162 offset
=bt2
.ClockClassOffset(45, 3003),
163 is_absolute
=True, uuid
=my_uuid
)
164 self
.assertEqual(cc1
, cc2
)
166 def test_ne_name(self
):
167 my_uuid
= uuid
.uuid1()
168 cc1
= bt2
.ClockClass(name
='mane', description
='some description',
169 frequency
=1001, precision
=176,
170 offset
=bt2
.ClockClassOffset(45, 3003),
171 is_absolute
=True, uuid
=my_uuid
)
172 cc2
= bt2
.ClockClass(name
='name', description
='some description',
173 frequency
=1001, precision
=176,
174 offset
=bt2
.ClockClassOffset(45, 3003),
175 is_absolute
=True, uuid
=my_uuid
)
176 self
.assertNotEqual(cc1
, cc2
)
178 def test_ne_description(self
):
179 my_uuid
= uuid
.uuid1()
180 cc1
= bt2
.ClockClass(name
='name', description
='some descripti2',
181 frequency
=1001, precision
=176,
182 offset
=bt2
.ClockClassOffset(45, 3003),
183 is_absolute
=True, uuid
=my_uuid
)
184 cc2
= bt2
.ClockClass(name
='name', description
='some description',
185 frequency
=1001, precision
=176,
186 offset
=bt2
.ClockClassOffset(45, 3003),
187 is_absolute
=True, uuid
=my_uuid
)
188 self
.assertNotEqual(cc1
, cc2
)
190 def test_ne_frequency(self
):
191 my_uuid
= uuid
.uuid1()
192 cc1
= bt2
.ClockClass(name
='name', description
='some description',
193 frequency
=1003, precision
=176,
194 offset
=bt2
.ClockClassOffset(45, 3003),
195 is_absolute
=True, uuid
=my_uuid
)
196 cc2
= bt2
.ClockClass(name
='name', description
='some description',
197 frequency
=1001, precision
=176,
198 offset
=bt2
.ClockClassOffset(45, 3003),
199 is_absolute
=True, uuid
=my_uuid
)
200 self
.assertNotEqual(cc1
, cc2
)
202 def test_ne_precision(self
):
203 my_uuid
= uuid
.uuid1()
204 cc1
= bt2
.ClockClass(name
='name', description
='some description',
205 frequency
=1001, precision
=171,
206 offset
=bt2
.ClockClassOffset(45, 3003),
207 is_absolute
=True, uuid
=my_uuid
)
208 cc2
= bt2
.ClockClass(name
='name', description
='some description',
209 frequency
=1001, precision
=176,
210 offset
=bt2
.ClockClassOffset(45, 3003),
211 is_absolute
=True, uuid
=my_uuid
)
212 self
.assertNotEqual(cc1
, cc2
)
214 def test_ne_offset(self
):
215 my_uuid
= uuid
.uuid1()
216 cc1
= bt2
.ClockClass(name
='name', description
='some description',
217 frequency
=1001, precision
=176,
218 offset
=bt2
.ClockClassOffset(45, 3001),
219 is_absolute
=True, uuid
=my_uuid
)
220 cc2
= bt2
.ClockClass(name
='name', description
='some description',
221 frequency
=1001, precision
=176,
222 offset
=bt2
.ClockClassOffset(45, 3003),
223 is_absolute
=True, uuid
=my_uuid
)
224 self
.assertNotEqual(cc1
, cc2
)
226 def test_ne_absolute(self
):
227 my_uuid
= uuid
.uuid1()
228 cc1
= bt2
.ClockClass(name
='name', description
='some description',
229 frequency
=1001, precision
=176,
230 offset
=bt2
.ClockClassOffset(45, 3003),
231 is_absolute
=True, uuid
=my_uuid
)
232 cc2
= bt2
.ClockClass(name
='name', description
='some description',
233 frequency
=1001, precision
=176,
234 offset
=bt2
.ClockClassOffset(45, 3003),
235 is_absolute
=False, uuid
=my_uuid
)
236 self
.assertNotEqual(cc1
, cc2
)
238 def test_ne_uuid(self
):
239 cc1
= bt2
.ClockClass(name
='name', description
='some description',
240 frequency
=1001, precision
=176,
241 offset
=bt2
.ClockClassOffset(45, 3003),
242 is_absolute
=True, uuid
=uuid
.uuid1())
243 cc2
= bt2
.ClockClass(name
='name', description
='some description',
244 frequency
=1001, precision
=176,
245 offset
=bt2
.ClockClassOffset(45, 3003),
246 is_absolute
=True, uuid
=uuid
.uuid1())
247 self
.assertNotEqual(cc1
, cc2
)
249 def test_eq_invalid(self
):
250 self
.assertFalse(self
._cc
== 23)
253 @unittest.skip("this is broken")
254 class ClockSnapshotTestCase(unittest
.TestCase
):
256 self
._cc
= bt2
.ClockClass('salut', 1000,
257 offset
=bt2
.ClockClassOffset(45, 354))
258 self
._cs
= self
._cc
(123)
264 def test_create_default(self
):
265 self
.assertEqual(self
._cs
.clock_class
.addr
, self
._cc
.addr
)
266 self
.assertEqual(self
._cs
.cycles
, 123)
268 def test_create_invalid_cycles_type(self
):
269 with self
.assertRaises(TypeError):
272 def test_ns_from_epoch(self
):
273 s_from_epoch
= 45 + ((354 + 123) / 1000)
274 ns_from_epoch
= int(s_from_epoch
* 1e9
)
275 self
.assertEqual(self
._cs
.ns_from_epoch
, ns_from_epoch
)
280 self
.assertEqual(cs1
, cs2
)
282 def test_eq_int(self
):
284 self
.assertEqual(cs1
, 123)
286 def test_ne_clock_class(self
):
287 cc1
= bt2
.ClockClass('yes', 1500)
288 cc2
= bt2
.ClockClass('yes', 1501)
291 self
.assertNotEqual(cs1
, cs2
)
293 def test_ne_cycles(self
):
296 self
.assertNotEqual(cs1
, cs2
)
298 def test_eq_invalid(self
):
299 self
.assertFalse(self
._cs
== 23)
301 def _test_copy(self
, cpy
):
302 self
.assertIsNot(cpy
, self
._cs
)
303 self
.assertNotEqual(cpy
.addr
, self
._cs
.addr
)
304 self
.assertEqual(cpy
, self
._cs
)
307 cpy
= copy
.copy(self
._cs
)
310 def test_deepcopy(self
):
311 cpy
= copy
.deepcopy(self
._cs
)
This page took 0.035758 seconds and 4 git commands to generate.