Skip to content

Commit

Permalink
Added new tests to verify the automatic addition of 'Machine,' 'Start…
Browse files Browse the repository at this point in the history
… Time,' and 'End Time' tags to the queried columns
  • Loading branch information
JMkrish committed Oct 25, 2023
1 parent ca2145a commit afa0dcb
Showing 1 changed file with 211 additions and 0 deletions.
211 changes: 211 additions & 0 deletions tests/cycle/test_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,219 @@ def test_get_cycles(get_client):
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": columns,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(columns))


def test_get_cycles_machine_tag(get_client):
machines = get_client.get_machine_names(source_type=MACHINE_TYPE)
machine = machines[MACHINE_INDEX]
columns = get_client.get_machine_schema(machine)["display"].to_list()

select_columns = [
# "Machine",
"Cycle Start Time",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape != (NUM_ROWS, len(select_columns))

select_columns = [
"machine__source",
"Cycle Start Time",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(select_columns))


def test_get_cycles_starttime_tag(get_client):
machines = get_client.get_machine_names(source_type=MACHINE_TYPE)
machine = machines[MACHINE_INDEX]
columns = get_client.get_machine_schema(machine)["display"].to_list()

select_columns = [
"Machine",
# "Cycle Start Time",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape != (NUM_ROWS, len(select_columns))

select_columns = [
"Machine",
"starttime",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(select_columns))

select_columns = [
"Machine",
"Start Time",
"Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(select_columns))


def test_get_cycles_endtime_tag(get_client):
machines = get_client.get_machine_names(source_type=MACHINE_TYPE)
machine = machines[MACHINE_INDEX]
columns = get_client.get_machine_schema(machine)["display"].to_list()

select_columns = [
"Machine",
"Cycle Start Time",
# "Cycle End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape != (NUM_ROWS, len(select_columns))

select_columns = [
"Machine",
"Cycle Start Time",
"endtime",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(select_columns))

select_columns = [
"Machine",
"Cycle Start Time",
"End Time",
"Production Day",
"Cycle Time (Net)",
"Cycle Time (Gross)",
]

col = select_columns.copy()

query = {
"Machine": machine,
"End Time__gte": START_DATETIME,
"End Time__lte": END_DATETIME,
"_order_by": "-End Time",
"_limit": NUM_ROWS,
"_only": col,
}

df = get_client.get_cycles(**query)

assert df.shape == (NUM_ROWS, len(select_columns))

0 comments on commit afa0dcb

Please sign in to comment.