forked from ericaltendorf/plotman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporting_test.py
61 lines (50 loc) · 1.9 KB
/
reporting_test.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
#!/usr/bin/python3
from unittest.mock import patch
import os
import pyfakefs
import unittest
import reporting
class TestReporting(unittest.TestCase):
def test_phases_str(self):
self.assertEqual('1:2 2:3 3:4 4:0',
reporting.phases_str([(1,2), (2,3), (3,4), (4,0)]))
self.assertEqual('1:2 [+1] 3:4 4:0',
reporting.phases_str([(1,2), (2,3), (3,4), (4,0)], 3))
self.assertEqual('1:2 [+2] 4:0',
reporting.phases_str([(1,2), (2,3), (3,4), (4,0)], 2))
def test_job_viz_empty(self):
self.assertEqual('1 2 3 4 ',
reporting.job_viz([]) )
@patch('job.Job')
def job_w_phase(self, ph, MockJob):
j = MockJob()
j.progress.return_value = ph
return j
def test_job_viz_positions(self):
jobs = [self.job_w_phase((1, 1)),
self.job_w_phase((2, 0)),
self.job_w_phase((2, 4)),
self.job_w_phase((2, 7)),
self.job_w_phase((4, 0))]
self.assertEqual('1 . 2. . .3 4.',
reporting.job_viz(jobs))
def test_job_viz_counts(self):
jobs = [self.job_w_phase((2, 2)),
self.job_w_phase((2, 3)),
self.job_w_phase((2, 3)),
self.job_w_phase((2, 4)),
self.job_w_phase((2, 4)),
self.job_w_phase((2, 4)),
self.job_w_phase((2, 5)),
self.job_w_phase((2, 5)),
self.job_w_phase((2, 5)),
self.job_w_phase((2, 5)),
self.job_w_phase((3, 1)),
self.job_w_phase((3, 1)),
self.job_w_phase((3, 1)),
self.job_w_phase((3, 1)),
self.job_w_phase((3, 1)),
self.job_w_phase((3, 1)),
]
self.assertEqual('1 2 .:;! 3 ! 4 ',
reporting.job_viz(jobs))