- From now on, black must pass. Jenkins will give a -1 if it doesn't
- Ignore E203 because it is not pep8 compliant, and conflicts with black
https://github.com/psf/black/issues/315#issuecomment-
395457972
- Black fixes and minor fix in unit test
- Fix devops-stages/stage-test.sh: jenkins was not giving a -1 when tox
was failing
Change-Id: Ic7318dcb6d4006a271607cd064a1f36d0936b7b9
Signed-off-by: David Garcia <david.garcia@canonical.com>
# See the License for the specific language governing permissions and
# limitations under the License.
-OUTPUT=$(TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto)
-printf "$OUTPUT"
+tox --parallel=auto
if not await self._namespace_exists(cluster_id, namespace):
err_msg = (
"namespace {} does not exist in cluster_id {} "
- "error message: ".format(
- namespace, e
- )
+ "error message: ".format(namespace, e)
)
self.log.error(err_msg)
raise K8sException(err_msg)
# check embeded chart (file or dir)
if chart_name.startswith("/"):
# extract file or directory name
- chart_name = chart_name[chart_name.rfind("/") + 1:]
+ chart_name = chart_name[chart_name.rfind("/") + 1 :]
# check URL
elif "://" in chart_name:
# extract last portion of URL
- chart_name = chart_name[chart_name.rfind("/") + 1:]
+ chart_name = chart_name[chart_name.rfind("/") + 1 :]
name = ""
for c in chart_name:
delay=1,
fallback=Exception("Failed getting the secret from service account"),
)
- async def get_secret_data(self, name: str, namespace: str = "kube-system") -> (str, str):
+ async def get_secret_data(
+ self, name: str, namespace: str = "kube-system"
+ ) -> (str, str):
"""
Get secret data
+ :param: name: Name of the secret data
+ :param: namespace: Name of the namespace where the secret is stored
+
:return: Tuple with the token and client certificate
"""
v1_core = self.clients[CORE_CLIENT]
if not include_path:
i = filename.rfind("/")
if i > 0:
- filename = filename[i + 1:]
+ filename = filename[i + 1 :]
# datetime
dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
@patch("n2vc.k8s_helm_base_conn.EnvironConfig")
async def setUp(self, mock_env):
- mock_env.return_value = {
- "stablerepourl": "https://charts.helm.sh/stable"
- }
+ mock_env.return_value = {"stablerepourl": "https://charts.helm.sh/stable"}
self.db = Mock(DbMemory())
self.fs = asynctest.Mock(FsLocal())
self.fs.path = "./tmp/"
self.kdu_instance = "stable-openldap-0005399828"
self.helm_conn.generate_kdu_instance_name = Mock(return_value=self.kdu_instance)
self.helm_conn._get_namespaces = asynctest.CoroutineMock(return_value=[])
- self.helm_conn._namespace_exists = asynctest.CoroutineMock(side_effect=self.helm_conn._namespace_exists)
+ self.helm_conn._namespace_exists = asynctest.CoroutineMock(
+ side_effect=self.helm_conn._namespace_exists
+ )
self.helm_conn._create_namespace = asynctest.CoroutineMock()
await self.helm_conn.install(
async def test_namespace_exists(self):
self.helm_conn._get_namespaces = asynctest.CoroutineMock()
- self.helm_conn._get_namespaces.return_value = ['testk8s', 'kube-system']
+ self.helm_conn._get_namespaces.return_value = ["testk8s", "kube-system"]
result = await self.helm_conn._namespace_exists(self.cluster_id, self.namespace)
self.helm_conn._get_namespaces.assert_called_once()
self.assertEqual(result, True)
self.helm_conn._get_namespaces.reset_mock()
- result = await self.helm_conn._namespace_exists(self.cluster_id, 'none-exists-namespace')
+ result = await self.helm_conn._namespace_exists(
+ self.cluster_id, "none-exists-namespace"
+ )
self.helm_conn._get_namespaces.assert_called_once()
self.assertEqual(result, False)
with self.assertRaises(JujuControllerFailedConnecting):
controller = self.loop.run_until_complete(self.libjuju.get_controller())
self.assertIsNone(controller)
- mock_disconnect_controller.assert_called_once()
+ mock_disconnect_controller.assert_called()
def test_same_endpoint_get_controller(self, mock_api_endpoints, mock_connect):
self.libjuju.endpoints = ["127.0.0.1:17070"]
deps = black
skip_install = true
commands =
- - black --check --diff n2vc/
- - black --check --diff setup.py
+ black --check --diff n2vc/
+ black --check --diff setup.py
#######################################################################################
W503,
E123,
E125,
+ E203,
E226,
E241
exclude =