Skip to content

Commit

Permalink
refactor: update test cases to use unique flow names with UUIDs (#3708)
Browse files Browse the repository at this point in the history
Refactor test cases to use unique flow names with UUIDs
  • Loading branch information
ogabrielluiz authored Sep 6, 2024
1 parent fcf780b commit 19818db
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/backend/tests/unit/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ def test_create_flows(client: TestClient, session: Session, json_flow: str, logg
flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_unique_name = str(uuid4())
flow_2_unique_name = str(uuid4())
flow_list = FlowListCreate(
flows=[
FlowCreate(name="Flow 1", description="description", data=data),
FlowCreate(name="Flow 2", description="description", data=data),
FlowCreate(name=flow_unique_name, description="description", data=data),
FlowCreate(name=flow_2_unique_name, description="description", data=data),
]
)
# Make request to endpoint
Expand All @@ -213,10 +215,10 @@ def test_create_flows(client: TestClient, session: Session, json_flow: str, logg
# Check response data
response_data = response.json()
assert len(response_data) == 2
assert "Flow 1" in response_data[0]["name"]
assert flow_unique_name in response_data[0]["name"]
assert response_data[0]["description"] == "description"
assert response_data[0]["data"] == data
assert response_data[1]["name"] == "Flow 2"
assert response_data[1]["name"] == flow_2_unique_name
assert response_data[1]["description"] == "description"
assert response_data[1]["data"] == data

Expand All @@ -225,10 +227,12 @@ def test_upload_file(client: TestClient, session: Session, json_flow: str, logge
flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_unique_name = str(uuid4())
flow_2_unique_name = str(uuid4())
flow_list = FlowListCreate(
flows=[
FlowCreate(name="Flow 1", description="description", data=data),
FlowCreate(name="Flow 2", description="description", data=data),
FlowCreate(name=flow_unique_name, description="description", data=data),
FlowCreate(name=flow_2_unique_name, description="description", data=data),
]
)
file_contents = orjson_dumps(flow_list.dict())
Expand All @@ -242,10 +246,10 @@ def test_upload_file(client: TestClient, session: Session, json_flow: str, logge
# Check response data
response_data = response.json()
assert len(response_data) == 2
assert "Flow 1" in response_data[0]["name"]
assert flow_unique_name in response_data[0]["name"]
assert response_data[0]["description"] == "description"
assert response_data[0]["data"] == data
assert response_data[1]["name"] == "Flow 2"
assert response_data[1]["name"] == flow_2_unique_name
assert response_data[1]["description"] == "description"
assert response_data[1]["data"] == data

Expand All @@ -260,10 +264,12 @@ def test_download_file(
flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_unique_name = str(uuid4())
flow_2_unique_name = str(uuid4())
flow_list = FlowListCreate(
flows=[
FlowCreate(name="Flow 1", description="description", data=data),
FlowCreate(name="Flow 2", description="description", data=data),
FlowCreate(name=flow_unique_name, description="description", data=data),
FlowCreate(name=flow_2_unique_name, description="description", data=data),
]
)
db_manager = get_db_service()
Expand Down

0 comments on commit 19818db

Please sign in to comment.