Skip to content

Commit

Permalink
fmt: run source code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Dec 16, 2020
1 parent fa29fff commit 844c143
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion kubetest/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
from .secret import Secret
from .service import Service
from .serviceaccount import ServiceAccount
from .statefulset import StatefulSet
from .statefulset import StatefulSet
34 changes: 17 additions & 17 deletions kubetest/objects/networkpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class NetworkPolicy(ApiObject):
obj_type = client.V1NetworkPolicy

api_clients = {
'preffered': client.NetworkingV1Api,
'networking.k8s.io/v1': client.NetworkingV1Api,
}
'preffered': client.NetworkingV1Api,
'networking.k8s.io/v1': client.NetworkingV1Api,
}

def __str__(self):
return str(self.obj)
Expand All @@ -48,16 +48,16 @@ def create(self, namespace: str = None) -> None:
namespace = self.namespace

log.info(
'creating networkpolicy "%s" in namespace "%s"',
self.name,
self.namespace
)
'creating networkpolicy "%s" in namespace "%s"',
self.name,
self.namespace
)
log.debug('network_policy: %s', self.obj)

self.obj = self.api_client.create_namespaced_network_policy(
namespace=namespace,
body=self.obj,
)
namespace=namespace,
body=self.obj,
)

def delete(self, options: client.V1DeleteOptions = None) -> client.V1Status:
"""Delete the NetworkPolicy.
Expand All @@ -80,17 +80,17 @@ def delete(self, options: client.V1DeleteOptions = None) -> client.V1Status:
log.debug('network_policy: %s', self.obj)

return self.api_client.delete_namespaced_network_policy(
name=self.name,
namespace=self.namespace,
body=options,
)
name=self.name,
namespace=self.namespace,
body=options,
)

def refresh(self) -> None:
"""Refresh the underlying Kubernetes NetworkPolicy resource."""
self.obj = self.api_client.read_namespaced_network_policy(
name=self.name,
namespace=self.namespace,
)
name=self.name,
namespace=self.namespace,
)

def is_ready(self) -> None:
"""Check if the NetworkPolicy is in the ready state.
Expand Down
8 changes: 4 additions & 4 deletions kubetest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
import logging
import os
import warnings
from typing import Optional

import kubernetes
import pytest
import urllib3

from typing import Optional

from kubetest import errors, markers
from kubetest.client import TestClient
from kubetest.manager import KubetestManager
Expand Down Expand Up @@ -434,14 +433,15 @@ def kubeconfig(request) -> Optional[str]:

@pytest.fixture
def kubecontext(request) -> Optional[str]:
"""Return the context in the kubeconfig to use for the tests.
"""Return the context in the kubeconfig to use for the tests.
When None, use the current context as set in the kubeconfig.
"""

context = request.session.config.getoption('kube_context')
return context


@pytest.fixture()
def kube(kubeconfig, kubecontext, request) -> TestClient:
"""Return a client for managing a Kubernetes cluster for testing."""
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,5 @@ def simple_networkpolicy():
spec=client.V1NetworkPolicySpec(
pod_selector=client.V1LabelSelector(),
policy_types=["Egress", "Ingress"],
)
)
)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ commands=
[testenv:format]
description=
run basic formatting tools against the source code
basepython=python3
deps=
isort>=5.0.0
autopep8
Expand Down

0 comments on commit 844c143

Please sign in to comment.