-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"A":{"0":0.0,"1":1.0,"2":2.0,"3":3.0,"4":4.0},"B":{"0":0.0,"1":1.0,"2":0.0,"3":1.0,"4":0.0},"C":{"0":"foo1","1":"foo2","2":"foo3","3":"foo4","4":"foo5"},"D":{"0":"2009-01-01","1":"2009-01-02","2":"2009-01-05","3":"2009-01-06","4":"2009-01-07"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from lumen.sources import JSONSource | ||
|
||
from .utils import source_filter, source_get_cache_no_query | ||
|
||
|
||
@pytest.fixture | ||
def source(make_jsonsource): | ||
root = os.path.dirname(__file__) | ||
return make_jsonsource(root) | ||
|
||
|
||
@pytest.fixture | ||
def source_tables(): | ||
df = pd._testing.makeMixedDataFrame() | ||
df['D'] = pd.to_datetime(df['D']).dt.date | ||
df = df.astype({'A': int, 'B': int, "D": 'str'}) | ||
return {'local': df} | ||
|
||
|
||
def test_json_source_resolve_module_type(): | ||
assert JSONSource._get_type('lumen.sources.JSONSource') is JSONSource | ||
assert JSONSource.source_type == 'json' | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"table_column_value_type", [ | ||
('local', 'A', 1.0, 'single_value'), | ||
('local', 'A', (1, 3), 'range'), | ||
('local', 'A', [(0, 1), (3, 4)], 'range_list'), | ||
('local', 'C', 'foo2', 'single_value'), | ||
('local', 'C', ['foo1', 'foo3'], 'list'), | ||
] | ||
) | ||
@pytest.mark.parametrize("dask", [True, False]) | ||
def test_json_source_filter(source, table_column_value_type, dask, expected_filtered_df): | ||
assert source_filter(source, table_column_value_type, dask, expected_filtered_df) | ||
|
||
|
||
@pytest.mark.parametrize("dask", [True, False]) | ||
def test_file_source_get_cache_no_query(source, dask, source_tables): | ||
assert source_get_cache_no_query( | ||
source, 'local', source_tables['local'], dask, use_dask=False | ||
) |