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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
from datetime import timedelta, datetime
from typing import TYPE_CHECKING, Optional, Callable
from generalresearch.pg_helper import PostgresConfig
import pytest
from test_utils.incite.conftest import mnt_filepath
from test_utils.conftest import clear_directory
if TYPE_CHECKING:
from generalresearch.incite.collections import DFCollection
from generalresearch.incite.base import GRLDatasets, DFCollectionType
from generalresearch.incite.collections.thl_web import LedgerDFCollection
from generalresearch.incite.collections.thl_web import (
WallDFCollection,
SessionDFCollection,
TaskAdjustmentDFCollection,
UserDFCollection,
AuditLogDFCollection,
)
@pytest.fixture(scope="function")
def user_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: timedelta,
start: datetime,
thl_web_rr: PostgresConfig,
) -> "UserDFCollection":
from generalresearch.incite.collections.thl_web import (
UserDFCollection,
DFCollectionType,
)
return UserDFCollection(
start=start,
finished=start + duration,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.USER),
)
@pytest.fixture(scope="function")
def wall_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: timedelta,
start: datetime,
thl_web_rr: PostgresConfig,
) -> "WallDFCollection":
from generalresearch.incite.collections.thl_web import (
WallDFCollection,
DFCollectionType,
)
return WallDFCollection(
start=start,
finished=start + duration if duration else None,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.WALL),
)
@pytest.fixture(scope="function")
def session_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: timedelta,
start: datetime,
thl_web_rr: PostgresConfig,
) -> "SessionDFCollection":
from generalresearch.incite.collections.thl_web import (
SessionDFCollection,
DFCollectionType,
)
return SessionDFCollection(
start=start,
finished=start + duration if duration else None,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.SESSION),
)
# IPInfoDFCollection
# IPHistoryDFCollection
# IPHistoryWSDFCollection
# @pytest.fixture
# def ip_history_collection(mnt_filepath, offset, duration, start,
# thl_web_rw) -> IPHistoryDFCollection:
# return IPHistoryDFCollection(
# start=start,
# finished=start + duration,
# offset=offset,
# pg_config=thl_web_rw,
# archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.IP_HISTORY),
# )
@pytest.fixture(scope="function")
def task_adj_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: Optional[timedelta],
start: datetime,
thl_web_rr,
) -> "TaskAdjustmentDFCollection":
from generalresearch.incite.collections.thl_web import (
TaskAdjustmentDFCollection,
DFCollectionType,
)
return TaskAdjustmentDFCollection(
start=start,
finished=start + duration if duration else duration,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(
enum_type=DFCollectionType.TASK_ADJUSTMENT
),
)
@pytest.fixture(scope="function")
def auditlog_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: timedelta,
start: datetime,
thl_web_rr,
) -> "AuditLogDFCollection":
from generalresearch.incite.collections.thl_web import (
AuditLogDFCollection,
DFCollectionType,
)
return AuditLogDFCollection(
start=start,
finished=start + duration,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.LEDGER),
)
@pytest.fixture(scope="function")
def ledger_collection(
mnt_filepath: "GRLDatasets",
offset: str,
duration: timedelta,
start: datetime,
thl_web_rr: PostgresConfig,
) -> "LedgerDFCollection":
from generalresearch.incite.collections.thl_web import (
LedgerDFCollection,
DFCollectionType,
)
return LedgerDFCollection(
start=start,
finished=start + duration if duration else duration,
offset=offset,
pg_config=thl_web_rr,
archive_path=mnt_filepath.archive_path(enum_type=DFCollectionType.LEDGER),
)
@pytest.fixture(scope="function")
def rm_ledger_collection(ledger_collection: "LedgerDFCollection") -> Callable:
def _inner():
clear_directory(ledger_collection.archive_path)
return _inner
# --------------------------
# Generic / Base
# --------------------------
@pytest.fixture(scope="function")
def df_collection(
mnt_filepath: "GRLDatasets",
df_collection_data_type: "DFCollectionType",
offset: str,
duration: timedelta,
utc_90days_ago: datetime,
thl_web_rr: PostgresConfig,
) -> "DFCollection":
from generalresearch.incite.collections import DFCollection
start = utc_90days_ago.replace(microsecond=0)
return DFCollection(
data_type=df_collection_data_type,
archive_path=mnt_filepath.archive_path(enum_type=df_collection_data_type),
offset=offset,
pg_config=thl_web_rr,
start=start,
finished=start + duration,
)
|