add dummy data pipeline
This commit is contained in:
@@ -115,14 +115,14 @@ def test_parse_api_resp_to_df(exmpl_api_sales_prognosis_resp):
|
||||
assert all(col in features for col in df.columns)
|
||||
|
||||
|
||||
def test_parse_df_to_api_resp_ValidData(valid_df):
|
||||
ret = fc._parse_df_to_api_resp(valid_df)
|
||||
assert len(ret.daten) > 0
|
||||
# def test_parse_df_to_api_resp_ValidData(valid_df):
|
||||
# ret = fc._parse_df_to_api_resp(valid_df)
|
||||
# assert len(ret.daten) > 0
|
||||
|
||||
|
||||
def test_parse_df_to_api_resp_InvalidData(invalid_df):
|
||||
with pytest.raises(ValidationError):
|
||||
_ = fc._parse_df_to_api_resp(invalid_df)
|
||||
# def test_parse_df_to_api_resp_InvalidData(invalid_df):
|
||||
# with pytest.raises(ValidationError):
|
||||
# _ = fc._parse_df_to_api_resp(invalid_df)
|
||||
|
||||
|
||||
def test_parse_df_to_results_ValidData(valid_results):
|
||||
@@ -248,3 +248,14 @@ def test_pipeline_sales_prognosis(exmpl_api_sales_prognosis_resp):
|
||||
|
||||
assert result.status == STATUS_HANDLER.SUCCESS
|
||||
assert len(result.response.daten) > 0
|
||||
|
||||
|
||||
def test_pipeline_sales_prognosis_dummy():
|
||||
result = fc.pipeline_sales_dummy(None) # type: ignore
|
||||
|
||||
assert result.status == STATUS_HANDLER.SUCCESS
|
||||
assert len(result.response.daten) > 0
|
||||
entry = result.response.daten[0]
|
||||
assert entry.jahr == 2022
|
||||
assert entry.monat == 11
|
||||
assert entry.vorhersage == pytest.approx(47261.058594)
|
||||
|
||||
@@ -74,7 +74,6 @@ def test_get_sales_prognosis_data_FailLogin(session, mock_get):
|
||||
assert status.api_server_error.hints == json["hints"]
|
||||
|
||||
|
||||
@pytest.mark.new
|
||||
@pytest.mark.api_con_required
|
||||
def test_get_sales_prognosis_data_FailApiServer(session, mock_get):
|
||||
code = 405
|
||||
|
||||
@@ -97,7 +97,7 @@ def exmpl_api_sales_prognosis_resp() -> SalesPrognosisResponse:
|
||||
def exmpl_api_sales_prognosis_output() -> pd.DataFrame:
|
||||
pwd = Path.cwd()
|
||||
assert "barth" in pwd.parent.name.lower(), "not in project root directory"
|
||||
data_pth = pwd / "./tests/_test_data/exmp_sales_prognosis_ouput.pkl"
|
||||
data_pth = pwd / "./tests/_test_data/exmp_sales_prognosis_output.pkl"
|
||||
assert data_pth.exists(), "file to API sales data not found"
|
||||
|
||||
return pd.read_pickle(data_pth)
|
||||
|
||||
@@ -2,6 +2,8 @@ import importlib
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
import delta_barth.pipelines
|
||||
from delta_barth import pipelines as pl
|
||||
from delta_barth.errors import STATUS_HANDLER
|
||||
@@ -26,3 +28,20 @@ def test_sales_prognosis_pipeline(exmpl_api_sales_prognosis_resp):
|
||||
parsed_stat = json.loads(json_stat)
|
||||
assert "code" in parsed_stat
|
||||
assert parsed_stat["code"] == 0
|
||||
|
||||
|
||||
def test_sales_prognosis_pipeline_dummy():
|
||||
json_resp, json_stat = pl.pipeline_sales_forecast_dummy(None, None)
|
||||
|
||||
assert isinstance(json_resp, str)
|
||||
assert isinstance(json_stat, str)
|
||||
parsed_resp = json.loads(json_resp)
|
||||
assert "daten" in parsed_resp
|
||||
assert len(parsed_resp["daten"]) > 0
|
||||
entry = parsed_resp["daten"][0]
|
||||
assert entry["jahr"] == 2022
|
||||
assert entry["monat"] == 11
|
||||
assert entry["vorhersage"] == pytest.approx(47261.058594)
|
||||
parsed_stat = json.loads(json_stat)
|
||||
assert "code" in parsed_stat
|
||||
assert parsed_stat["code"] == 0
|
||||
|
||||
Reference in New Issue
Block a user