/
common_fixtures.py
94 lines (74 loc) · 2.2 KB
/
common_fixtures.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from itertools import permutations
from pathlib import Path
import pytest
from yfs.paths import TEST_DIRECTORY
from requests_html import HTML
def get_data(path: Path) -> HTML:
assert path.exists()
with open(path, mode="r") as file:
return HTML(html=file.read())
@pytest.fixture(
params=[
"aapl",
"amd",
"amzn",
"dia",
"exfo",
"fcel",
"gpro",
"lite",
"msft",
"pavm",
"tsla",
"twtr",
]
)
def summary_page_data_fixture(request):
symbol = request.param
test_response_path = TEST_DIRECTORY / "data" / "summary" / f"{symbol}_summary_page_raw.html"
return symbol, get_data(test_response_path)
symbols = [
"aapl",
"amd",
"amzn",
"dia",
"exfo",
"fcel",
"twtr",
]
input = list(permutations(symbols, r=2))
output = [sorted(c) for c in input]
@pytest.fixture(params=list(zip(input, output)))
def multiple_summary_page_data_fixture(request):
from pprint import pprint
input, output = request.param
symbol_one, symbol_two = input
test_response_path_one = (
TEST_DIRECTORY / "data" / "summary" / f"{symbol_one}_summary_page_raw.html"
)
test_response_path_two = (
TEST_DIRECTORY / "data" / "summary" / f"{symbol_two}_summary_page_raw.html"
)
output = [symbol.upper() for symbol in output]
return (
symbol_one,
symbol_two,
get_data(test_response_path_one),
get_data(test_response_path_two),
output,
)
#
@pytest.fixture
def option_expiration_data_fixture():
test_response_path = TEST_DIRECTORY / "data" / "spy_option_expiration_raw.html"
return get_data(test_response_path)
@pytest.fixture(scope="module", params=["aapl", "exfo", "sar", "tsla"])
def option_page_data_fixture(request):
symbol = request.param
test_response_path = TEST_DIRECTORY / "data" / f"{symbol}_option_page_raw.html"
return get_data(test_response_path)
@pytest.fixture(scope="module", params=["aapl", "fcel"])
def statistics_page_data_fixture(request):
symbol = request.param
test_response_path = TEST_DIRECTORY / "data" / f"{symbol}_statistics_page_raw.html"
return get_data(test_response_path)