Skip to content

Commit 800dca6

Browse files
authored
Merge pull request #12 from sabanawaf/jobstats-pytest
Testing for JobStats class is complete
2 parents 00bac2c + 3da821e commit 800dca6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_helper.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import re
12
import os
23
import pytest
34
import user_sync.helper
5+
from user_sync.helper import JobStats
46
from conftest import compare_list
57

68

@@ -74,3 +76,27 @@ def write_users_to_file(filename, field_names, user_list):
7476
line += ","
7577
file.write(line + "\n")
7678
file.close()
79+
80+
81+
def test_log_start(log_stream):
82+
stream, logger = log_stream
83+
jobstats = JobStats('Test Job Stats')
84+
jobstats.log_start(logger)
85+
stream.flush()
86+
assert stream.getvalue() == '---------- Start Test Job Stats ----------------------------\n'
87+
88+
89+
def test_log_end(log_stream):
90+
stream, logger = log_stream
91+
jobstats = JobStats('Test Job Stats')
92+
jobstats.log_end(logger)
93+
stream.flush()
94+
output = stream.getvalue()
95+
pattern = '(---------- End Test Job Stats \\(Total time:.*)(\\) --------\\n)'
96+
assert re.search(pattern, output)
97+
98+
99+
def test_create_divider():
100+
jobstats = JobStats('Test Job Stats')
101+
line = jobstats.create_divider('This is a header')
102+
assert line == '----------This is a header----------------------------------'

0 commit comments

Comments
 (0)