[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECH-debt] Tasking::get_quotations test coverage fix #684

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

andher1802
Copy link
Contributor

See changelog.

Checklist:

  • Test coverage
  • Version bump
  • Changelog update

@andher1802 andher1802 requested review from up42-eva and a team as code owners October 30, 2024 11:06
up42/tasking.py Outdated
Comment on lines 28 to 29
session = base.Session()
workspace_id = base.WorkspaceId()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, comes from the parent

up42/tasking.py Outdated
"workspaceId": workspace_id,
"id": quotation_id,
"orderId": order_id,
"decision": set(decision) if decision else None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"decision": decision

up42/tasking.py Outdated
"id": quotation_id,
"orderId": order_id,
"decision": set(decision) if decision else None,
"sort": sortby + sort_order,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sort": utils.SortingField(sortby, descending)

up42/tasking.py Outdated
}
quotations = []
current_page = 0
while True:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reuse the approach from Order module

up42/tasking.py Outdated
return self._query_paginated_output(url)
sort_order = ",desc" if descending else ",asc"
query_params = {
key: str(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need str here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually it was an error as desicion is an array.

sortby=sort_by,
descending=descending,
)
assert len(get_quotations) == 10 * total_pages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check its content

query = urllib.parse.urlencode(query_params)
url += query and f"?{query}"
response = {
"content": [{"id": str(uuid.uuid4())} for _ in range(10)],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's switch to "id": f"id{idx}" to be able to check the content

):
total_pages = 4
query_params: dict[str, Any] = {}
sort_order = ",desc" if descending else ",asc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add this to parameterization

Copy link
Contributor Author
@andher1802 andher1802 Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have parametrized descending parameter and set the value according to it. Is that what you meant?

if order_id:
query_params["orderId"] = order_id
if decision:
query_params["decision"] = set(decision)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set is not needed

@pytest.mark.parametrize("workspace_id", [None, constants.WORKSPACE_ID])
@pytest.mark.parametrize("order_id", [None, ORDER_ID])
@pytest.mark.parametrize("decision", [None, ["NOT_DECIDED", "ACCEPTED", "REJECTED"]])
@pytest.mark.parametrize("sort_by", ["updatedAt"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no point in parameterizing this

Copy link
sonarcloud bot commented Nov 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants