refactoring
This commit is contained in:
@@ -135,13 +135,13 @@ def test_parse_df_to_results_InvalidData(invalid_results):
|
||||
_ = fc._parse_df_to_results(invalid_results)
|
||||
|
||||
|
||||
def test_preprocess_sales_per_customer_Success(
|
||||
def test_preprocess_sales_Success(
|
||||
exmpl_api_sales_prognosis_resp,
|
||||
feature_map,
|
||||
target_features,
|
||||
):
|
||||
resp = exmpl_api_sales_prognosis_resp
|
||||
pipe = fc._preprocess_sales_per_customer(
|
||||
pipe = fc._preprocess_sales(
|
||||
resp,
|
||||
feature_map=feature_map,
|
||||
target_features=target_features,
|
||||
@@ -153,14 +153,14 @@ def test_preprocess_sales_per_customer_Success(
|
||||
assert any(feat not in df.columns for feat in feature_map.keys())
|
||||
|
||||
|
||||
def test_preprocess_sales_per_customer_FailOnTargetFeature(
|
||||
def test_preprocess_sales_FailOnTargetFeature(
|
||||
exmpl_api_sales_prognosis_resp,
|
||||
feature_map,
|
||||
target_features,
|
||||
):
|
||||
resp = exmpl_api_sales_prognosis_resp
|
||||
target_features = {"not_known_feature", "test2"}
|
||||
pipe = fc._preprocess_sales_per_customer(
|
||||
pipe = fc._preprocess_sales(
|
||||
resp,
|
||||
feature_map=feature_map,
|
||||
target_features=target_features,
|
||||
@@ -170,23 +170,23 @@ def test_preprocess_sales_per_customer_FailOnTargetFeature(
|
||||
assert pipe.results is None
|
||||
|
||||
|
||||
def test_sales_per_customer_Success(sales_data_real_preproc):
|
||||
def test_process_sales_Success(sales_data_real_preproc):
|
||||
data = sales_data_real_preproc.copy()
|
||||
# fc._preprocess_sales_per_customer()
|
||||
pipe = PipeResult(data, STATUS_HANDLER.SUCCESS)
|
||||
pipe = fc._process_sales_per_customer(pipe)
|
||||
pipe = fc._process_sales(pipe)
|
||||
|
||||
assert pipe.status == STATUS_HANDLER.SUCCESS
|
||||
assert pipe.data is not None
|
||||
assert pipe.results is None
|
||||
|
||||
|
||||
def test_sales_per_customer_FailTooFewPoints(sales_data_real_preproc):
|
||||
def test_process_sales_FailTooFewPoints(sales_data_real_preproc):
|
||||
data = sales_data_real_preproc.copy()
|
||||
data = data.iloc[:20, :]
|
||||
# fc._preprocess_sales_per_customer()
|
||||
pipe = PipeResult(data, STATUS_HANDLER.SUCCESS)
|
||||
pipe = fc._process_sales_per_customer(pipe)
|
||||
pipe = fc._process_sales(pipe)
|
||||
|
||||
assert pipe.status != STATUS_HANDLER.SUCCESS
|
||||
assert pipe.status == STATUS_HANDLER.pipe_states.TOO_FEW_POINTS
|
||||
@@ -194,13 +194,13 @@ def test_sales_per_customer_FailTooFewPoints(sales_data_real_preproc):
|
||||
assert pipe.results is None
|
||||
|
||||
|
||||
def test_postprocess_sales_per_customer_Success(
|
||||
def test_postprocess_sales_Success(
|
||||
valid_results,
|
||||
):
|
||||
data = valid_results
|
||||
pipe = PipeResult(data, STATUS_HANDLER.SUCCESS)
|
||||
|
||||
pipe = fc._postprocess_sales_per_customer(
|
||||
pipe = fc._postprocess_sales(
|
||||
pipe,
|
||||
feature_map=DualDict(),
|
||||
)
|
||||
@@ -209,13 +209,13 @@ def test_postprocess_sales_per_customer_Success(
|
||||
assert pipe.results is not None
|
||||
|
||||
|
||||
def test_postprocess_sales_per_customer_FailValidation(
|
||||
def test_postprocess_sales_FailValidation(
|
||||
invalid_results,
|
||||
):
|
||||
data = invalid_results
|
||||
pipe = PipeResult(data, STATUS_HANDLER.SUCCESS)
|
||||
|
||||
pipe = fc._postprocess_sales_per_customer(
|
||||
pipe = fc._postprocess_sales(
|
||||
pipe,
|
||||
feature_map=DualDict(),
|
||||
)
|
||||
@@ -225,7 +225,7 @@ def test_postprocess_sales_per_customer_FailValidation(
|
||||
assert "ValidationError" in pipe.status.description
|
||||
|
||||
|
||||
def test_sales_prognosis_pipeline(exmpl_api_sales_prognosis_resp):
|
||||
def test_pipeline_sales_prognosis(exmpl_api_sales_prognosis_resp):
|
||||
def mock_request(*args, **kwargs):
|
||||
return exmpl_api_sales_prognosis_resp, STATUS_HANDLER.SUCCESS
|
||||
|
||||
@@ -234,7 +234,7 @@ def test_sales_prognosis_pipeline(exmpl_api_sales_prognosis_resp):
|
||||
new=mock_request,
|
||||
):
|
||||
importlib.reload(delta_barth.analysis.forecast)
|
||||
result = fc.pipeline(None) # type: ignore
|
||||
result = fc.pipeline_sales(None) # type: ignore
|
||||
|
||||
assert result.status == STATUS_HANDLER.SUCCESS
|
||||
assert len(result.response.daten) > 0
|
||||
|
||||
@@ -2,14 +2,11 @@ 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
|
||||
|
||||
|
||||
@pytest.mark.new
|
||||
def test_sales_prognosis_pipeline(exmpl_api_sales_prognosis_resp):
|
||||
def mock_request(*args, **kwargs):
|
||||
return exmpl_api_sales_prognosis_resp, STATUS_HANDLER.SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user