Skip to content

Commit

Permalink
Move common fixtures to conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindio committed Sep 8, 2017
1 parent ae549c9 commit 52fa5b3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 45 deletions.
31 changes: 31 additions & 0 deletions tests/k8s/conftest.py
Expand Up @@ -4,6 +4,7 @@
import logging

import pytest
import mock

from k8s import config

Expand All @@ -27,3 +28,33 @@ def k8s_config(monkeypatch):
monkeypatch.setattr(config, "api_server", "https://10.0.0.1")
monkeypatch.setattr(config, "api_token", "password")
monkeypatch.setattr(config, "verify_ssl", False)


@pytest.fixture
def post():
with mock.patch('k8s.client.Client.post') as m:
yield m


@pytest.fixture
def put():
with mock.patch('k8s.client.Client.put') as m:
yield m


@pytest.fixture
def get():
with mock.patch('k8s.client.Client.get') as m:
yield m


@pytest.fixture
def delete():
with mock.patch('k8s.client.Client.delete') as m:
yield m


@pytest.fixture
def api_get():
with mock.patch('k8s.base.ApiMixIn.get') as m:
yield m
25 changes: 0 additions & 25 deletions tests/k8s/test_deployer.py
Expand Up @@ -17,31 +17,6 @@

@pytest.mark.usefixtures("k8s_config")
class TestDeployer(object):
@pytest.fixture
def post(self):
with mock.patch('k8s.client.Client.post') as m:
yield m

@pytest.fixture
def put(self):
with mock.patch('k8s.client.Client.put') as m:
yield m

@pytest.fixture
def get(self):
with mock.patch('k8s.client.Client.get') as m:
yield m

@pytest.fixture
def delete(self):
with mock.patch('k8s.client.Client.delete') as m:
yield m

@pytest.fixture
def api_get(self):
with mock.patch('k8s.base.ApiMixIn.get') as m:
yield m

def test_create_blank_deployment(self):
object_meta = ObjectMeta(name=NAME, namespace=NAMESPACE)
deployment = Deployment(metadata=object_meta)
Expand Down
20 changes: 0 additions & 20 deletions tests/k8s/test_ingress.py
Expand Up @@ -14,26 +14,6 @@

@pytest.mark.usefixtures("k8s_config")
class TestIngress(object):
@pytest.fixture
def post(self):
with mock.patch('k8s.client.Client.post') as m:
yield m

@pytest.fixture
def put(self):
with mock.patch('k8s.client.Client.put') as m:
yield m

@pytest.fixture
def get(self):
with mock.patch('k8s.client.Client.get') as m:
yield m

@pytest.fixture
def api_get(self):
with mock.patch('k8s.base.ApiMixIn.get') as m:
yield m

def test_create_blank(self):
object_meta = ObjectMeta(name=NAME, namespace=NAMESPACE, labels={"test": "true"})
ingress = Ingress(metadata=object_meta)
Expand Down

0 comments on commit 52fa5b3

Please sign in to comment.