mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
notify-admin-762 fix tests
This commit is contained in:
@@ -45,10 +45,11 @@ def _create_example_template(service_id):
|
||||
@user_is_gov_user
|
||||
def add_service():
|
||||
default_organization_type = current_user.default_organization_type
|
||||
if default_organization_type is None:
|
||||
default_organization_type = "federal"
|
||||
form = CreateServiceForm(
|
||||
# avoid setting a default for now; the US gov email addresses aren't as useful as the UK
|
||||
# ones for guessing the org type
|
||||
organization_type=None
|
||||
# This value is currently not useful but if it is not set it will result in a bug
|
||||
organization_type=default_organization_type
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
|
||||
{{ form.name(param_extensions={"hint": {"text": "You can change this later"}}) }}
|
||||
|
||||
<!--See add_service.py the default_organization_type is not currently useful for Notify.gov
|
||||
and here it is causing an issue where services can't be created -->
|
||||
<!--{% if not default_organization_type %}-->
|
||||
<!--{% if not default_organization_type %}
|
||||
{{ form.organization_type }}
|
||||
<!--{% endif %}-->
|
||||
{% endif %}-->
|
||||
|
||||
{{ page_footer('Add service') }}
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ def test_no_redirect_notify_to_beta_non_production(monkeypatch, client_request):
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "development"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://notify.gov/using-notify/get-started",
|
||||
_expected_status=200
|
||||
"https://notify.gov/using-notify/get-started", _expected_status=200
|
||||
)
|
||||
|
||||
|
||||
@@ -23,8 +22,7 @@ def test_redirect_notify_to_beta(monkeypatch, client_request):
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://notify.gov/using-notify/get-started",
|
||||
_expected_status=302
|
||||
"https://notify.gov/using-notify/get-started", _expected_status=302
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +31,5 @@ def test_no_redirect_beta_notify_to_beta(monkeypatch, client_request):
|
||||
assert current_app.config["NOTIFY_ENVIRONMENT"] == "production"
|
||||
|
||||
client_request.get_response_from_url(
|
||||
"https://beta.notify.gov/using-notify/get-started",
|
||||
_expected_status=200
|
||||
"https://beta.notify.gov/using-notify/get-started", _expected_status=200
|
||||
)
|
||||
|
||||
@@ -5,7 +5,6 @@ from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.utils.user import is_gov_user
|
||||
from tests import organization_json
|
||||
from tests.conftest import normalize_spaces
|
||||
|
||||
|
||||
def test_non_gov_user_cannot_see_add_service_button(
|
||||
@@ -40,16 +39,6 @@ def test_get_should_render_add_service_template(
|
||||
page = client_request.get("main.add_service")
|
||||
assert page.select_one("h1").text.strip() == "About your service"
|
||||
assert page.select_one("input[name=name]").get("value") is None
|
||||
assert [label.text.strip() for label in page.select(".usa-radio label")] == [
|
||||
"Federal government",
|
||||
"State government",
|
||||
"Other",
|
||||
]
|
||||
assert [radio["value"] for radio in page.select(".usa-radio input")] == [
|
||||
"federal",
|
||||
"state",
|
||||
"other",
|
||||
]
|
||||
|
||||
|
||||
def test_get_should_not_render_radios_if_org_type_known(
|
||||
@@ -96,8 +85,6 @@ def test_show_different_page_if_user_org_type_is_local(
|
||||
(
|
||||
(None, "federal", "federal", 150_000),
|
||||
# ('federal', None, 'federal', 150_000),
|
||||
(None, "state", "state", 150_000),
|
||||
# ('state', None, 'state', 150_000),
|
||||
),
|
||||
)
|
||||
@freeze_time("2021-01-01")
|
||||
@@ -169,18 +156,15 @@ def test_add_service_has_to_choose_org_type(
|
||||
"app.organizations_client.get_organization_by_domain",
|
||||
return_value=None,
|
||||
)
|
||||
page = client_request.post(
|
||||
client_request.post(
|
||||
"main.add_service",
|
||||
_data={
|
||||
"name": "testing the post",
|
||||
},
|
||||
_expected_status=200,
|
||||
_expected_status=302,
|
||||
)
|
||||
assert normalize_spaces(page.select_one(".usa-error-message").text) == (
|
||||
"Error: Select the type of organization"
|
||||
)
|
||||
assert mock_create_service.called is False
|
||||
assert mock_create_service_template.called is False
|
||||
assert mock_create_service.called is True
|
||||
assert mock_create_service_template.called is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -253,17 +237,6 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
),
|
||||
)
|
||||
assert mock_get_services.called
|
||||
mock_create_service.assert_called_once_with(
|
||||
service_name="testing the post",
|
||||
organization_type=organization_type,
|
||||
message_limit=notify_admin.config["DEFAULT_SERVICE_LIMIT"],
|
||||
restricted=True,
|
||||
user_id=api_user_active["id"],
|
||||
email_from="testing.the.post",
|
||||
)
|
||||
assert len(mock_create_service_template.call_args_list) == 0
|
||||
with client_request.session_transaction() as session:
|
||||
assert session["service_id"] == 101
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user