-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_analyze.py
More file actions
75 lines (65 loc) · 2.9 KB
/
Copy pathtest_analyze.py
File metadata and controls
75 lines (65 loc) · 2.9 KB
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
'tests for analyze module'
import os
import sys
from unittest.mock import call
sys.path.insert(0, os.path.abspath( # This should be the path back to the root directory.
os.path.join(os.path.dirname(__file__), '..', '..')))
from internal.analyze import analyze # pylint: disable=wrong-import-position
def test_analyze(mocker):
'test for the main analyze function'
spy_pandas = mocker.patch('pandas.read_csv', return_value={})
spy_build_results = mocker.patch(
'internal.analyze.build_results', return_value={})
spy_build_md = mocker.patch(
'internal.analyze.build_markdown', return_value=None)
spy_build_csv = mocker.patch(
'internal.analyze.build_csv', return_value=None)
spy_build_json = mocker.patch(
'internal.analyze.build_json', return_value=None)
# Not dungeon run
analyze("talent", "gear", False, "weights", "timestamp", "covenant")
spy_pandas.assert_called_once_with(
os.path.join('gear', 'output', 'talent', 'covenant', 'statweights.csv'),
usecols=['profile', 'actor', 'DD', 'DPS',
'int', 'haste', 'crit', 'mastery', 'vers']
)
spy_build_results.assert_has_calls([
call({}, 'weights', 'Composite', 'gear'),
call({}, 'weights', 'Single', 'gear')
])
spy_build_md.assert_has_calls([
call('Composite', '_talent', {}, 'gear', 'weights', None, '_covenant'),
call('Single', '_talent', {}, 'gear', 'weights', None, '_covenant')
])
spy_build_csv.assert_has_calls([
call('Composite', '_talent', {}, 'gear', 'weights', None, '_covenant'),
call('Single', '_talent', {}, 'gear', 'weights', None, '_covenant')
])
spy_build_json.assert_not_called()
def test_analyze_dungeon_run(mocker):
'tests running analyze with the dungeon flag set true'
spy_pandas = mocker.patch('pandas.read_csv', return_value={})
spy_build_results = mocker.patch(
'internal.analyze.build_results', return_value={})
spy_build_md = mocker.patch(
'internal.analyze.build_markdown', return_value=None)
spy_build_csv = mocker.patch(
'internal.analyze.build_csv', return_value=None)
spy_build_json = mocker.patch(
'internal.analyze.build_json', return_value=None)
# Dungeon run
analyze("talent", "gear", True, "weights", "timestamp", "covenant")
spy_pandas.assert_called_once_with(
os.path.join('gear', 'output', 'talent', 'covenant', 'statweights.csv'),
usecols=['profile', 'actor', 'DD', 'DPS',
'int', 'haste', 'crit', 'mastery', 'vers']
)
spy_build_results.assert_called_once_with(
{}, 'weights', 'Dungeons', 'gear')
spy_build_md.assert_called_once_with(
'Dungeons', '_talent', {}, 'gear', 'weights', None, '_covenant'
)
spy_build_csv.assert_called_once_with(
'Dungeons', '_talent', {}, 'gear', 'weights', None, '_covenant'
)
spy_build_json.assert_not_called()