Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mosquito committed Jun 26, 2024
1 parent e570443 commit 111b91d
Show file tree
Hide file tree
Showing 21 changed files with 1,305 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
from typing import Any

import pytest

from tpcp import BaseTpcpObject
from tpcp._base import _BaseTpcpObject


def _get_params_without_nested_class(instance: BaseTpcpObject) -> dict[str, Any]:
return {k: v for k, v in instance.get_params().items() if not isinstance(v, _BaseTpcpObject)}


@pytest.fixture()
def snapshot(request):
from tpcp.testing import PyTestSnapshotTest

with PyTestSnapshotTest(request) as snapshot_test:
yield snapshot_test


def pytest_addoption(parser):
group = parser.getgroup("snapshottest")
group.addoption(
"--snapshot-update",
action="store_true",
default=False,
dest="snapshot_update",
help="Update the snapshots.",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"schema":{
"fields":[
{
"name":"index",
"type":"integer"
},
{
"name":"dummy_index",
"type":"integer"
},
{
"name":"column",
"type":"integer"
}
],
"primaryKey":[
"index"
],
"pandas_version":"1.4.0"
},
"data":[
{
"index":0,
"dummy_index":1,
"column":2
},
{
"index":1,
"dummy_index":1,
"column":2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"schema":{
"fields":[
{
"name":"index_level_a",
"type":"string"
},
{
"name":"index_level_b",
"type":"string"
},
{
"name":"example_col",
"type":"integer"
}
],
"primaryKey":[
"index_level_a",
"index_level_b"
],
"pandas_version":"1.4.0"
},
"data":[
{
"index_level_a":1,
"index_level_b":2,
"example_col":1
},
{
"index_level_a":"a",
"index_level_b":"b",
"example_col":2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"schema":{
"fields":[
{
"name":"index",
"type":"integer"
},
{
"name":"index_level_a",
"type":"integer"
},
{
"name":"index_level_b",
"type":"integer"
},
{
"name":"example_col",
"type":"integer"
}
],
"primaryKey":[
"index"
],
"pandas_version":"1.4.0"
},
"data":[
{
"index":0,
"index_level_a":2,
"index_level_b":2,
"example_col":1
},
{
"index":1,
"index_level_a":2,
"index_level_b":2,
"example_col":2
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"schema":{
"fields":[
{
"name":"dummy_index",
"type":"integer"
},
{
"name":"col_int",
"type":"integer"
},
{
"name":"col_str",
"type":"any",
"extDtype":"string"
},
{
"name":"col_float",
"type":"number"
}
],
"primaryKey":[
"dummy_index"
],
"pandas_version":"1.4.0"
},
"data":[
{
"dummy_index":1,
"col_int":1,
"col_str":"a",
"col_float":2.0
},
{
"dummy_index":2,
"col_int":2,
"col_str":"b",
"col_float":0.3333333433
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"schema":{
"fields":[
{
"name":"dummy_index",
"type":"datetime"
},
{
"name":"col_int",
"type":"integer"
},
{
"name":"col_date",
"type":"datetime"
}
],
"primaryKey":[
"dummy_index"
],
"pandas_version":"1.4.0"
},
"data":[
{
"dummy_index":"2021-01-01T00:00:00.000000000",
"col_int":0,
"col_date":"2021-01-01T00:00:00.000000000"
},
{
"dummy_index":"2021-01-02T00:00:00.000000000",
"col_int":1,
"col_date":"2021-01-02T00:00:00.000000000"
},
{
"dummy_index":"2021-01-03T00:00:00.000000000",
"col_int":2,
"col_date":"2021-01-03T00:00:00.000000000"
},
{
"dummy_index":"2021-01-04T00:00:00.000000000",
"col_int":3,
"col_date":"2021-01-04T00:00:00.000000000"
},
{
"dummy_index":"2021-01-05T00:00:00.000000000",
"col_int":4,
"col_date":"2021-01-05T00:00:00.000000000"
},
{
"dummy_index":"2021-01-06T00:00:00.000000000",
"col_int":5,
"col_date":"2021-01-06T00:00:00.000000000"
},
{
"dummy_index":"2021-01-07T00:00:00.000000000",
"col_int":6,
"col_date":"2021-01-07T00:00:00.000000000"
},
{
"dummy_index":"2021-01-08T00:00:00.000000000",
"col_int":7,
"col_date":"2021-01-08T00:00:00.000000000"
},
{
"dummy_index":"2021-01-09T00:00:00.000000000",
"col_int":8,
"col_date":"2021-01-09T00:00:00.000000000"
},
{
"dummy_index":"2021-01-10T00:00:00.000000000",
"col_int":9,
"col_date":"2021-01-10T00:00:00.000000000"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"schema":{
"fields":[
{
"name":"dummy_index",
"type":"datetime"
},
{
"name":"col_int",
"type":"integer"
},
{
"name":"col_date",
"type":"datetime"
}
],
"primaryKey":[
"dummy_index"
],
"pandas_version":"1.4.0"
},
"data":[
{
"dummy_index":"2021-01-01T00:00:00.000000000",
"col_int":0,
"col_date":"2021-01-01T00:00:00.000000000"
},
{
"dummy_index":"2021-01-01T01:00:00.000000000",
"col_int":1,
"col_date":"2021-01-01T01:00:00.000000000"
},
{
"dummy_index":"2021-01-01T02:00:00.000000000",
"col_int":2,
"col_date":"2021-01-01T02:00:00.000000000"
},
{
"dummy_index":"2021-01-01T03:00:00.000000000",
"col_int":3,
"col_date":"2021-01-01T03:00:00.000000000"
},
{
"dummy_index":"2021-01-01T04:00:00.000000000",
"col_int":4,
"col_date":"2021-01-01T04:00:00.000000000"
},
{
"dummy_index":"2021-01-01T05:00:00.000000000",
"col_int":5,
"col_date":"2021-01-01T05:00:00.000000000"
},
{
"dummy_index":"2021-01-01T06:00:00.000000000",
"col_int":6,
"col_date":"2021-01-01T06:00:00.000000000"
},
{
"dummy_index":"2021-01-01T07:00:00.000000000",
"col_int":7,
"col_date":"2021-01-01T07:00:00.000000000"
},
{
"dummy_index":"2021-01-01T08:00:00.000000000",
"col_int":8,
"col_date":"2021-01-01T08:00:00.000000000"
},
{
"dummy_index":"2021-01-01T09:00:00.000000000",
"col_int":9,
"col_date":"2021-01-01T09:00:00.000000000"
}
]
}
Loading

0 comments on commit 111b91d

Please sign in to comment.