This repository has been archived by the owner on Jul 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
51 lines (41 loc) · 1.63 KB
/
__init__.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
from typing import List, Dict
from unittest import mock
import pytest
from resonances.datamining.librations.finder import CirculationYearsFinder, NoPhaseException
PHASES = [
{'year': 0.0, 'value': -0.51},
{'year': 3.0, 'value': 0.87},
{'year': 6.0, 'value': 2.37},
{'year': 9.0, 'value': -2.51}
]
MORE_PHASES = [
{'year': 12.0, 'value': 1.51},
{'year': 15.0, 'value': -1.},
{'year': 18.0, 'value': 3.1},
]
RESONANCE_ID = 1
VALUES = [
([], None, False),
([{'year': 0.0, 'value': 1.32}], [], False),
(PHASES, [PHASES[2]['year']], False),
(PHASES + [{'year': 12.0, 'value': 0.01}], [PHASES[2]['year']], False),
(PHASES + [MORE_PHASES[0]], [PHASES[3]['year']], False),
(PHASES + MORE_PHASES, [PHASES[3]['year'], 15.], False),
([], None, True),
([{'year': 0.0, 'value': 1.32}], [], True),
(PHASES, [PHASES[0]['year']], True),
(PHASES + [MORE_PHASES[0]], [PHASES[0]['year']], True),
(PHASES + MORE_PHASES, [MORE_PHASES[0]['year']], True),
(PHASES + [{'year': 12.0, 'value': 0.01}], [PHASES[0]['year'], PHASES[3]['year']], True),
]
@pytest.mark.parametrize('phase_arguments, result_years, for_apocentric', VALUES,
ids=VALUES)
@mock.patch('resonances.entities.Phase')
def test_getting_years(Phase, phase_arguments: List[Dict],
result_years: List[float], for_apocentric: bool):
finder = CirculationYearsFinder(RESONANCE_ID, for_apocentric, phase_arguments)
if result_years is None:
with pytest.raises(NoPhaseException):
finder.get_time_breaks()
else:
assert finder.get_time_breaks() == result_years