Skip to content

Commit

Permalink
added tests for greater than and less than metadata operators and add…
Browse files Browse the repository at this point in the history
…ed negative tests w/ burnettk
  • Loading branch information
jasquat committed Oct 20, 2023
1 parent 611e124 commit 7e0eaae
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def assert_report_with_process_metadata_operator_includes_instance(
process_instance: ProcessInstanceModel,
operator: str,
filter_field_value: str = "",
expect_to_find_instance: bool = True,
) -> None:
report_metadata: ReportMetadata = {
"columns": [
Expand All @@ -506,8 +507,17 @@ def assert_report_with_process_metadata_operator_includes_instance(
response = self.post_to_process_instance_list(
client, user, report_metadata=process_instance_report.get_report_metadata()
)
assert len(response.json["results"]) == 1
assert response.json["results"][0]["id"] == process_instance.id

if expect_to_find_instance is True:
assert len(response.json["results"]) == 1
assert response.json["results"][0]["id"] == process_instance.id
else:
if len(response.json["results"]) == 1:
assert (
response.json["results"][0]["id"] != process_instance.id
), "expected not to find a specific process instance, but we found it"
else:
assert len(response.json["results"]) == 0
db.session.delete(process_instance_report)
db.session.commit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2937,10 +2937,102 @@ def test_can_get_process_instance_list_with_report_metadata_using_different_oper
operator="not_equals",
filter_field_value="hey",
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="less_than",
filter_field_value="value4",
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="greater_than_or_equal_to",
filter_field_value="value1",
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client, user=with_super_admin_user, process_instance=process_instance_two, operator="is_empty"
)

def test_can_get_process_instance_list_with_report_metadata_using_different_operators_when_no_matches(
self,
app: Flask,
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
with_super_admin_user: UserModel,
) -> None:
process_model = load_test_spec(
process_model_id="save_process_instance_metadata/save_process_instance_metadata",
bpmn_file_name="save_process_instance_metadata.bpmn",
process_model_source_directory="save_process_instance_metadata",
)

process_instance_one_metadata = {"key1": "value1"}
process_instance_one = self.create_process_instance_with_synthetic_metadata(
process_model=process_model, process_instance_metadata_dict=process_instance_one_metadata
)

process_instance_two_metadata = {"key2": "value2"}
process_instance_two = self.create_process_instance_with_synthetic_metadata(
process_model=process_model, process_instance_metadata_dict=process_instance_two_metadata
)

self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_two,
operator="is_not_empty",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="equals",
filter_field_value="value2",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="contains",
filter_field_value="alunooo",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="not_equals",
filter_field_value="value1",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="less_than",
filter_field_value="value1",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="greater_than_or_equal_to",
filter_field_value="value2",
expect_to_find_instance=False,
)
self.assert_report_with_process_metadata_operator_includes_instance(
client=client,
user=with_super_admin_user,
process_instance=process_instance_one,
operator="is_empty",
expect_to_find_instance=False,
)

def test_can_get_process_instance_list_with_report_metadata_and_process_initiator(
self,
app: Flask,
Expand Down

0 comments on commit 7e0eaae

Please sign in to comment.