Skip to content

Commit

Permalink
attempt to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesstottmoj committed Apr 4, 2024
1 parent 880628f commit 4b31610
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions tests/api/cluster/test_user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Standard library
from unittest.mock import MagicMock, call, patch
from unittest.mock import call, patch

# Third-party
import pytest
Expand All @@ -16,6 +16,7 @@ def test_iam_role_name(users):
def test_create(helm, settings, users):
with patch("controlpanel.api.cluster.AWSRole.create_role") as aws_create_role:
user = users["normal_user"]
print(user)
cluster.User(user).create()
aws_create_role.assert_called_with(
user.iam_role_name,
Expand All @@ -37,7 +38,8 @@ def test_create(helm, settings, users):
f"--set=Username={user.slug}",
),
]
helm.upgrade_release.has_calls(expected_calls)
print(helm.upgrade_release.call_args_list)
helm.upgrade_release.assert_has_calls(expected_calls)


def test_reset_home(helm, users):
Expand All @@ -52,6 +54,7 @@ def test_reset_home(helm, users):
f"--set=Username={user.slug}",
),
]
print(helm.upgrade_release.call_args_list)
helm.upgrade_release.assert_has_calls(expected_calls)


Expand All @@ -68,6 +71,7 @@ def test_delete(aws_delete_role, helm, users):
Delete with Helm 3.
"""
user = users["normal_user"]
print(user)
helm.list_releases.return_value = [
"chart-release",
]
Expand All @@ -77,7 +81,8 @@ def test_delete(aws_delete_role, helm, users):
call(f"user-{user.slug}", "chart-release"),
call("cpanel", "chart-release"),
]
helm.delete.has_calls(expected_calls)
print(helm.upgrade_release.call_args_list)
helm.delete.assert_has_calls(expected_calls)


def test_delete_eks_with_no_releases(aws_delete_role, helm, users):
Expand Down
2 changes: 1 addition & 1 deletion tests/api/models/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_helm_create_user(helm):
f"--set=Username={user.slug}",
),
]
helm.upgrade_release.has_calls(expected_calls)
helm.upgrade_release.assert_has_calls(expected_calls)


def test_helm_delete_user(helm, auth0):
Expand Down
4 changes: 2 additions & 2 deletions tests/frontend/views/test_app_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_permission(
client.force_login(users[user])
response = view(client, app, data_input)
assert response.status_code == expected_status
assert fixture_create_update_var.called_once()
assert fixture_delete_var.called_once()
assert fixture_create_update_var.assert_called_once()
assert fixture_delete_var.assert_called_once()
if data_input:
assert fixture_create_update_var.called_once_with(data_input)
2 changes: 1 addition & 1 deletion tests/frontend/views/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from authlib.integrations.base_client import OAuthError
from django.urls import reverse, reverse_lazy
from mock import patch
from unittest.mock import patch
from pytest_django.asserts import assertContains


Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/views/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from django.http import HttpResponse
from django.urls import reverse
from mock import MagicMock, patch
from unittest.mock import MagicMock, patch


class TestAccess:
Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/views/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_delete_secret(
client.force_login(users[user])
response = delete_secret_post(client, app, key, data)
assert response.status_code == expected_status
assert fixture_delete_secret.called_once()
assert fixture_delete_secret.assert_called_once()


def test_add_secret(fixture_create_update_secret,
Expand Down

0 comments on commit 4b31610

Please sign in to comment.