Skip to content

Commit 26732b9

Browse files
committed
fix already broken unit tests
1 parent cc7cb27 commit 26732b9

8 files changed

Lines changed: 33 additions & 22 deletions

File tree

smsdk/client_v0.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def get_part_schema(self, part_type, types=[], **kwargs):
10331033

10341034
stats = all_parts.loc[
10351035
(all_parts.part_type == pt) | (all_parts.part_type_clean == pt), "stats"
1036-
][0]
1036+
].iloc[0]
10371037

10381038
for machine in stats.keys():
10391039
m_stats = stats[machine]

tests/cycle/test_cycle.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Define all the constants used in the test
1010
MACHINE_TYPE = "Lasercut"
1111
MACHINE_INDEX = 5
12-
START_DATETIME = datetime(2023, 4, 1)
13-
END_DATETIME = datetime(2023, 4, 2)
12+
START_DATETIME = datetime(2026, 3, 1)
13+
END_DATETIME = datetime(2026, 3, 2)
1414
NUM_ROWS = 500
1515
URL_V1 = "/v1/datatab/cycle"
1616

@@ -58,6 +58,8 @@ def test_get_cycles(get_client):
5858
"_only": columns,
5959
}
6060

61+
# breakpoint()
62+
6163
df = get_client.get_cycles(**query)
6264

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

tests/downtime/test_downtime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# Define all the constants used in the test
99
MACHINE_TYPE = "Lasercut"
1010
MACHINE_INDEX = 0
11-
START_DATETIME = datetime(2023, 4, 1)
12-
END_DATETIME = datetime(2023, 4, 2)
13-
EXPECTED_ROWS = 18
11+
START_DATETIME = datetime(2026, 3, 1)
12+
END_DATETIME = datetime(2026, 3, 2)
13+
EXPECTED_ROWS = 11
1414
EXPECTED_COL = 8
1515
URL_V1 = "/v1/datatab/downtime"
1616

tests/lines/test_line.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99
# # Define all the constants used in the test
10-
START_DATETIME = "2023-04-01T08:00:00.000Z"
11-
END_DATETIME = "2023-04-02T23:00:00.000Z"
10+
START_DATETIME = "2026-03-01T08:00:00.000Z"
11+
END_DATETIME = "2026-03-02T23:00:00.000Z"
1212
TIME_ZONE = "America/Los_Angeles"
1313
MAX_ROWS = 50
1414
LINE_INDEX = 0
@@ -19,7 +19,7 @@
1919
FIELD_NAME1 = "stats__BLOCKED__val"
2020
FIELD_NAME2 = "stats__PneumaticPressure__val"
2121
MIN_PRESSURE = 75.25
22-
EXP_NUM_ROWS = 14
22+
EXP_NUM_ROWS = 3
2323
URL_V1 = "/v1/datatab/line"
2424

2525

tests/machine/test_machine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def test_get_machine_schema(get_client):
235235

236236
# Run
237237
df = get_client.get_machine_schema(machine)
238-
assert df.shape == (36, 15)
238+
assert df.shape == (38, 15)
239239

240240
# Run
241241
df = get_client.get_machine_schema(machine, types)

tests/machine_type/test_machine_type.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,33 @@ def test_get_fields_of_machine_type_types(mocked_machines):
105105
def test_get_machines_types(get_client):
106106
machine_types = get_client.get_machine_types()
107107
unique_machine_types = machine_types["source_type"].dropna().unique()
108-
assert unique_machine_types.tolist() == MACHINE_TYPE_NAMES_INTERNAL_EXPECT
108+
assert sorted(unique_machine_types.tolist()) == sorted(
109+
MACHINE_TYPE_NAMES_INTERNAL_EXPECT
110+
)
109111

110112
query = {
111113
"source_type": "Lasercut",
112114
}
113115

114116
machine_types = get_client.get_machine_types(**query)
115-
assert machine_types.shape == (29, 25)
117+
assert machine_types.shape == (45, 27)
116118

117119

118120
def test_get_machines_types_v1(get_client):
119121
machine_types = get_client.get_machine_types()
120-
assert machine_types.shape == (114, 25)
122+
assert machine_types.shape == (178, 27)
121123

122124

123125
def test_get_machines_type_names_v1(get_client):
124126
machine_types_ui_based = get_client.get_machine_type_names()
125-
assert machine_types_ui_based == MACHINE_TYPE_NAMES_UI_BASED_EXPECT
127+
assert sorted(machine_types_ui_based) == sorted(MACHINE_TYPE_NAMES_UI_BASED_EXPECT)
126128

127129
query = {
128130
"clean_strings_out": False,
129131
}
130132

131133
machine_types_internal = get_client.get_machine_type_names(**query)
132-
assert machine_types_internal == MACHINE_TYPE_NAMES_INTERNAL_EXPECT
134+
assert sorted(machine_types_internal) == sorted(MACHINE_TYPE_NAMES_INTERNAL_EXPECT)
133135

134136

135137
def test_get_fields_of_machine_type(get_client):
@@ -138,7 +140,7 @@ def test_get_fields_of_machine_type(get_client):
138140

139141
# Run
140142
fields = get_client.get_fields_of_machine_type(machine_type)
141-
assert len(fields) == 36
143+
assert len(fields) == 38
142144

143145
# Run
144146
fields = get_client.get_fields_of_machine_type(machine_type, types)

tests/parts/test_part.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
# Define all the constants used in the test
99
MACHINE_TYPE = "Lasercut"
1010
PART_TYPE_INDEX = 1
11-
START_DATETIME = datetime(2023, 4, 1)
12-
END_DATETIME = datetime(2023, 4, 2)
11+
START_DATETIME = datetime(2026, 3, 1)
12+
END_DATETIME = datetime(2026, 3, 2)
1313
NUM_ROWS = 10
14-
NUM_COLUMNS_FOR_QUERY = 31
14+
NUM_COLUMNS_FOR_QUERY = 28
1515
URL_V1 = "/v1/datatab/part"
1616

17+
# These columns have never been selectable for datatab parts queries since moving to Postgres
18+
INVALID_PART_TYPE_COLUMNS = [
19+
"Output",
20+
"Machine Sources",
21+
]
22+
1723

1824
def test_get_utilities(get_session):
1925
part = Parts(get_session, TENANT)
@@ -82,14 +88,15 @@ def test_get_parts(get_client):
8288
part_type = part_types[PART_TYPE_INDEX]
8389

8490
columns = get_client.get_part_schema(part_type)["display"].to_list()
91+
columns = [col for col in columns if col not in INVALID_PART_TYPE_COLUMNS]
8592

8693
query = {
8794
"Part": part_type,
8895
"End Time__gte": START_DATETIME,
8996
"End Time__lte": END_DATETIME,
9097
"DefectReason__exists": True,
9198
"_limit": NUM_ROWS,
92-
"_only": columns[: NUM_COLUMNS_FOR_QUERY - 1],
99+
"_only": columns[:NUM_COLUMNS_FOR_QUERY],
93100
}
94101

95102
df = get_client.get_parts(**query)

tests/raw_data/test_raw_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def test_get_raw_data(get_client):
2424
select = []
2525
timeselection = {
2626
"time_type": "absolute",
27-
"start_time": "2023-10-18T18:30:00.000Z",
28-
"end_time": "2023-10-19T18:29:59.999Z",
27+
"start_time": "2026-3-18T18:30:00.000Z",
28+
"end_time": "2026-3-19T18:29:59.999Z",
2929
"time_zone": "America/Los_Angeles",
3030
}
3131
limit = 100

0 commit comments

Comments
 (0)