Skip to content

Commit

Permalink
Fixed test for controlpanel.kubeapi.views
Browse files Browse the repository at this point in the history
It's now using `controlpanel.api.kubertetes.get_config()` but the mock
was still mocking the old kubernetes functions
  • Loading branch information
xoen committed Oct 3, 2019
1 parent dcece6c commit 7f820c0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/kubeapi/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
from rest_framework import status


TEST_K8S_API_URL = 'https://k8s.example.com'


@pytest.yield_fixture(autouse=True)
def k8s():
with patch('controlpanel.kubeapi.views.kubernetes') as k8s:
config = k8s.client.Configuration.return_value
config.host = TEST_K8S_API_URL
config.api_key = {
"authorization": "Bearer test-token",
}
yield k8s
def k8s_get_config():
with patch('controlpanel.kubeapi.views.api.kubernetes.get_config') as get_config:
config = MagicMock("k8s config")

config.host = "http://api.k8s.localhost"
config.ssl_ca_cert = "test ssl_ca_cert"

config.api_key_prefix = {"authorization": "Bearer"}
config.api_key = {"authorization": "test-token"}

get_config.return_value = config
yield get_config


@pytest.yield_fixture(autouse=True)
Expand Down

0 comments on commit 7f820c0

Please sign in to comment.