Change spacing from 4 spaces to 2 spaces
This commit is contained in:
parent
ec14007268
commit
efa66d84e4
28 changed files with 936 additions and 913 deletions
|
@ -1,23 +1,25 @@
|
|||
import pytest
|
||||
import re
|
||||
|
||||
from httmock import urlmatch, HTTMock, response
|
||||
|
||||
from config_app.config_util.k8saccessor import KubernetesAccessorSingleton
|
||||
from config_app.config_util.k8sconfig import KubernetesConfig
|
||||
|
||||
|
||||
@pytest.mark.parametrize('kube_config, expected_api, expected_query', [
|
||||
({'api_host':'www.customhost.com'},
|
||||
({'api_host': 'www.customhost.com'},
|
||||
'/apis/extensions/v1beta1/namespaces/quay-enterprise/deployments', 'labelSelector=quay-enterprise-component%3Dapp'),
|
||||
|
||||
({'api_host':'www.customhost.com', 'qe_deployment_selector':'custom-selector'},
|
||||
'/apis/extensions/v1beta1/namespaces/quay-enterprise/deployments', 'labelSelector=quay-enterprise-component%3Dcustom-selector'),
|
||||
({'api_host': 'www.customhost.com', 'qe_deployment_selector': 'custom-selector'},
|
||||
'/apis/extensions/v1beta1/namespaces/quay-enterprise/deployments',
|
||||
'labelSelector=quay-enterprise-component%3Dcustom-selector'),
|
||||
|
||||
({'api_host':'www.customhost.com', 'qe_namespace':'custom-namespace'},
|
||||
({'api_host': 'www.customhost.com', 'qe_namespace': 'custom-namespace'},
|
||||
'/apis/extensions/v1beta1/namespaces/custom-namespace/deployments', 'labelSelector=quay-enterprise-component%3Dapp'),
|
||||
|
||||
({'api_host':'www.customhost.com', 'qe_namespace':'custom-namespace', 'qe_deployment_selector':'custom-selector'},
|
||||
'/apis/extensions/v1beta1/namespaces/custom-namespace/deployments', 'labelSelector=quay-enterprise-component%3Dcustom-selector'),
|
||||
({'api_host': 'www.customhost.com', 'qe_namespace': 'custom-namespace', 'qe_deployment_selector': 'custom-selector'},
|
||||
'/apis/extensions/v1beta1/namespaces/custom-namespace/deployments',
|
||||
'labelSelector=quay-enterprise-component%3Dcustom-selector'),
|
||||
])
|
||||
def test_get_qe_deployments(kube_config, expected_api, expected_query):
|
||||
config = KubernetesConfig(**kube_config)
|
||||
|
@ -36,12 +38,15 @@ def test_get_qe_deployments(kube_config, expected_api, expected_query):
|
|||
|
||||
assert url_hit[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('kube_config, deployment_names, expected_api_hits', [
|
||||
({'api_host':'www.customhost.com'}, [], []),
|
||||
({'api_host':'www.customhost.com'}, ['myDeployment'], ['/apis/extensions/v1beta1/namespaces/quay-enterprise/deployments/myDeployment']),
|
||||
({'api_host':'www.customhost.com', 'qe_namespace':'custom-namespace'},
|
||||
({'api_host': 'www.customhost.com'}, [], []),
|
||||
({'api_host': 'www.customhost.com'}, ['myDeployment'],
|
||||
['/apis/extensions/v1beta1/namespaces/quay-enterprise/deployments/myDeployment']),
|
||||
({'api_host': 'www.customhost.com', 'qe_namespace': 'custom-namespace'},
|
||||
['myDeployment', 'otherDeployment'],
|
||||
['/apis/extensions/v1beta1/namespaces/custom-namespace/deployments/myDeployment', '/apis/extensions/v1beta1/namespaces/custom-namespace/deployments/otherDeployment']),
|
||||
['/apis/extensions/v1beta1/namespaces/custom-namespace/deployments/myDeployment',
|
||||
'/apis/extensions/v1beta1/namespaces/custom-namespace/deployments/otherDeployment']),
|
||||
])
|
||||
def test_cycle_qe_deployments(kube_config, deployment_names, expected_api_hits):
|
||||
KubernetesAccessorSingleton._instance = None
|
||||
|
|
|
@ -6,24 +6,27 @@ from util.config.validator import EXTRA_CA_DIRECTORY
|
|||
|
||||
from test.fixtures import *
|
||||
|
||||
class MockTarInfo:
|
||||
def __init__(self, name, isdir):
|
||||
self.name = name
|
||||
self.isdir = lambda: isdir
|
||||
|
||||
def __eq__(self, other):
|
||||
return other is not None and self.name == other.name
|
||||
class MockTarInfo:
|
||||
def __init__(self, name, isdir):
|
||||
self.name = name
|
||||
self.isdir = lambda: isdir
|
||||
|
||||
def __eq__(self, other):
|
||||
return other is not None and self.name == other.name
|
||||
|
||||
|
||||
@pytest.mark.parametrize('prefix,tarinfo,expected', [
|
||||
# It should handle simple files
|
||||
('Users/sam/', MockTarInfo('Users/sam/config.yaml', False), MockTarInfo('config.yaml', False)),
|
||||
# It should allow the extra CA dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/%s' % EXTRA_CA_DIRECTORY, True), MockTarInfo('%s' % EXTRA_CA_DIRECTORY, True)),
|
||||
# it should allow a file in that extra dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/%s/cert.crt' % EXTRA_CA_DIRECTORY, False), MockTarInfo('%s/cert.crt' % EXTRA_CA_DIRECTORY, False)),
|
||||
# it should not allow a directory that isn't the CA dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/dirignore', True), None),
|
||||
# It should handle simple files
|
||||
('Users/sam/', MockTarInfo('Users/sam/config.yaml', False), MockTarInfo('config.yaml', False)),
|
||||
# It should allow the extra CA dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/%s' % EXTRA_CA_DIRECTORY, True), MockTarInfo('%s' % EXTRA_CA_DIRECTORY, True)),
|
||||
# it should allow a file in that extra dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/%s/cert.crt' % EXTRA_CA_DIRECTORY, False),
|
||||
MockTarInfo('%s/cert.crt' % EXTRA_CA_DIRECTORY, False)),
|
||||
# it should not allow a directory that isn't the CA dir
|
||||
('Users/sam/', MockTarInfo('Users/sam/dirignore', True), None),
|
||||
])
|
||||
def test_tarinfo_filter(prefix, tarinfo, expected):
|
||||
partial = tarinfo_filter_partial(prefix)
|
||||
assert partial(tarinfo) == expected
|
||||
partial = tarinfo_filter_partial(prefix)
|
||||
assert partial(tarinfo) == expected
|
||||
|
|
Reference in a new issue