Skip to content

Commit

Permalink
wip: Cenários de BDD usando o modulo behave
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-parana committed Jul 25, 2023
1 parent 2afbe20 commit 992bbd3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions features/01.create_timeserie.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ Value Statement:
Then I have a time series with the `correct` number of rows and columns, schema and time interval
And I have a CSV file in T8S_WORKSPACE/data/csv correctelly formated
And I have a Parquet file in T8S_WORKSPACE/data/parquet correctelly formated with metadata annotations
And I have a text representation for the first time serie like this:
"""
TimeSerie(format=wide, features=3, df=
timestamp temperatura velocidade
0 2022-01-01 00:00:00 25.000000 3000.0
1 2022-01-01 01:00:00 26.000000 1100.0
2 2022-01-01 02:00:00 27.000000 1200.0
3 2022-01-01 03:00:00 23.200001 4000.0) +
types: [<class 'pandas._libs.tslibs.timestamps.Timestamp'>, <class 'numpy.float32'>, <class 'numpy.float32'>]
"""
# Constraint: The first Dataframe doesn't have nulls or invalid values, but the second does
14 changes: 14 additions & 0 deletions features/steps/01.create_timeserie_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ def write_ts_to_parquet_file(ts, parquet_path, filename: str):

# Grava a série temporal ts2 em parquet
# write_ts_to_parquet_file(context.ts2, context.PARQUET_PATH, 'ts_02.parquet')

@then(u'I have a text representation for the first time serie like this:')
def check_text(context):
logger.debug(f'check_text : context.text -> \n{str(context.text)}')
logger.debug(f'\ncheck_text : context.ts1 -> \n{str(context.ts1)}')
def assert_line_by_line(context):
ts1_line = str(context.ts1).splitlines()
for idx, line in enumerate(context.text.splitlines()):
logger.info(f'check_text : line {idx} -> \n"{line}" == "{ts1_line[idx]}"')
msg =f'context.text must be equal to str(ts1). Failed in line {idx} -> "{line}" != "{ts1_line[idx]}"'
assert line.strip() == ts1_line[idx].strip(), msg
assert_line_by_line(context)
logger.info('\ncheck_text passed !')

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies = [
"pyyaml",
"pyarrow",
"pandas",
"behave",
"behave-pandas"
]

[project.optional-dependencies]
Expand Down Expand Up @@ -89,7 +91,7 @@ cov = [
]

[[tool.hatch.envs.all.matrix]]
python = ["3.10", "3.11"]
python = ["3.11"]

[tool.hatch.envs.lint]
detached = true
Expand Down

0 comments on commit 992bbd3

Please sign in to comment.