aboutsummaryrefslogtreecommitdiff
path: root/tests/incite/collections/test_df_collection_thl_web.py
blob: 51ca128912292e38f9fd2339f7a6311942389d3a (plain)
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
from datetime import datetime
from itertools import product
from typing import TYPE_CHECKING

import dask.dataframe as dd
import pandas as pd
import pytest
from pandera import DataFrameSchema

from generalresearch.incite.collections import DFCollection, DFCollectionType

if TYPE_CHECKING:
    from generalresearch.incite.base import GRLDatasets


def combo_object():
    for x in product(
        [
            DFCollectionType.USER,
            DFCollectionType.WALL,
            DFCollectionType.SESSION,
            DFCollectionType.TASK_ADJUSTMENT,
            DFCollectionType.AUDIT_LOG,
            DFCollectionType.LEDGER,
        ],
        ["30min", "1H"],
    ):
        yield x


@pytest.mark.parametrize(
    argnames="df_collection_data_type, offset", argvalues=combo_object()
)
class TestDFCollection_thl_web:

    def test_init(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection_data_type, DFCollectionType)
        assert isinstance(df_collection, DFCollection)


@pytest.mark.parametrize(
    argnames="df_collection_data_type, offset", argvalues=combo_object()
)
class TestDFCollection_thl_web_Properties:

    def test_items(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection.items, list)
        for i in df_collection.items:
            assert i._collection == df_collection

    def test__schema(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection._schema, DataFrameSchema)


@pytest.mark.parametrize(
    argnames="df_collection_data_type, offset", argvalues=combo_object()
)
class TestDFCollection_thl_web_BaseProperties:

    @pytest.mark.skip
    def test__interval_range(self, df_collection_data_type, offset: str, df_collection):
        pass

    def test_interval_start(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection.interval_start, datetime)

    def test_interval_range(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection.interval_range, list)

    def test_progress(self, df_collection_data_type, offset: str, df_collection):
        assert isinstance(df_collection.progress, pd.DataFrame)


@pytest.mark.parametrize(
    argnames="df_collection_data_type, offset", argvalues=combo_object()
)
class TestDFCollection_thl_web_Methods:

    @pytest.mark.skip
    def test_initial_loads(self, df_collection_data_type, df_collection, offset):
        pass

    @pytest.mark.skip
    def test_fetch_force_rr_latest(
        self, df_collection_data_type, df_collection, offset: str
    ):
        pass

    @pytest.mark.skip
    def test_force_rr_latest(self, df_collection_data_type, df_collection, offset):
        pass


@pytest.mark.parametrize(
    argnames="df_collection_data_type, offset", argvalues=combo_object()
)
class TestDFCollection_thl_web_BaseMethods:

    def test_fetch_all_paths(self, df_collection_data_type, offset: str, df_collection):
        res = df_collection.fetch_all_paths(
            items=None, force_rr_latest=False, include_partial=False
        )
        assert isinstance(res, list)

    @pytest.mark.skip
    def test_ddf(self, df_collection_data_type, offset: str, df_collection):
        res = df_collection.ddf()
        assert isinstance(res, dd.DataFrame)

    # -- cleanup --
    @pytest.mark.skip
    def test_schedule_cleanup(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_cleanup(self, df_collection_data_type, offset: str, df_collection):
        pass

    @pytest.mark.skip
    def test_cleanup_partials(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_clear_tmp_archives(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_clear_corrupt_archives(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_rebuild_symlinks(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    # -- Source timing --
    @pytest.mark.skip
    def test_get_item(self, df_collection_data_type, offset: str, df_collection):
        pass

    @pytest.mark.skip
    def test_get_item_start(self, df_collection_data_type, offset: str, df_collection):
        pass

    @pytest.mark.skip
    def test_get_items(self, df_collection_data_type, offset: str, df_collection):
        # If we get all the items from the start of the collection, it
        #   should include all the items!
        res1 = df_collection.items
        res2 = df_collection.get_items(since=df_collection.start)
        assert len(res1) == len(res2)

    @pytest.mark.skip
    def test_get_items_from_year(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_get_items_last90(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass

    @pytest.mark.skip
    def test_get_items_last365(
        self, df_collection_data_type, offset: str, df_collection
    ):
        pass