Skip to content

Commit

Permalink
Fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
currycoder committed Dec 20, 2024
1 parent b4e8f0c commit 48ca460
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from caseworker.advice import services
from caseworker.advice.constants import AdviceSteps
from core import client


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -212,6 +213,66 @@ def test_DESNZ_give_approval_advice_post_valid_add_conditional(
assert add_instructions_response.status_code == 302


@pytest.fixture
def mock_no_provisos(requests_mock):
url = client._build_absolute_uri("/picklist/?type=proviso&page=1&disable_pagination=True&show_deactivated=False")
data = {"results": []}
return requests_mock.get(url=url, json=data)


@mock.patch("caseworker.advice.views.mixins.get_gov_user")
def test_DESNZ_give_approval_advice_post_valid_no_provisos(
mock_get_gov_user,
authorized_client,
data_standard_case,
url,
mock_approval_reason,
mock_no_provisos,
mock_footnote_details,
mock_post_advice,
post_to_step,
beautiful_soup,
):
mock_get_gov_user.return_value = (
{
"user": {
"team": {
"id": "56273dd4-4634-4ad7-a782-e480f85a85a9",
"name": "DESNZ Chemical",
"alias": services.DESNZ_CHEMICAL,
}
}
},
None,
)
response = post_to_step(
AdviceSteps.RECOMMEND_APPROVAL,
{"approval_reasons": "reason", "add_licence_conditions": True},
)
assert response.status_code == 200
soup = beautiful_soup(response.content)
# redirected to next form
header = soup.find("h1")
assert header.text == "Add licence conditions (optional)"

add_LC_response = post_to_step(
AdviceSteps.LICENCE_CONDITIONS,
{"proviso": "proviso"},
)
assert add_LC_response.status_code == 200
soup = beautiful_soup(add_LC_response.content)
# redirected to next form
header = soup.find("h1")
assert header.text == "Add instructions to the exporter, or a reporting footnote (optional)"

add_instructions_response = post_to_step(
AdviceSteps.LICENCE_FOOTNOTES,
{"instructions_to_exporter": "instructions", "footnote_details": "footnotes"},
)
assert add_instructions_response.status_code == 302
assert len(mock_post_advice.request_history) == 1


@mock.patch("caseworker.advice.views.mixins.get_gov_user")
def test_DESNZ_give_approval_advice_post_valid_add_conditional_optional(
mock_get_gov_user,
Expand Down

0 comments on commit 48ca460

Please sign in to comment.