diff --git a/src/charm.py b/src/charm.py index 2d1b077..bdc5030 100755 --- a/src/charm.py +++ b/src/charm.py @@ -149,5 +149,6 @@ class OpenstackLoadbalancerCharm(ops_openstack.core.OSBaseCharm): self._configure_haproxy() self._send_loadbalancer_response() + if __name__ == "__main__": main(OpenstackLoadbalancerCharm) diff --git a/tox.ini b/tox.ini index c855061..7bb995e 100644 --- a/tox.ini +++ b/tox.ini @@ -7,22 +7,6 @@ skipsdist = True sitepackages = False # NOTE: Avoid false positives by not skipping missing interpreters. skip_missing_interpreters = False -# NOTES: -# * We avoid the new dependency resolver by pinning pip < 20.3, see -# https://github.com/pypa/pip/issues/9187 -# * Pinning dependencies requires tox >= 3.2.0, see -# https://tox.readthedocs.io/en/latest/config.html#conf-requires -# * It is also necessary to pin virtualenv as a newer virtualenv would still -# lead to fetching the latest pip in the func* tox targets, see -# https://stackoverflow.com/a/38133283 -# * It is necessary to declare setuptools as a dependency otherwise tox will -# fail very early at not being able to load it. The version pinning is in -# line with `pip.sh`. -requires = pip < 20.3 - virtualenv < 20.0 - setuptools < 50.0.0 -# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci -minversion = 3.2.0 [testenv] setenv = VIRTUAL_ENV={envdir} @@ -37,7 +21,12 @@ allowlist_externals = bash charmcraft rename.sh -passenv = HOME TERM CS_* OS_* TEST_* +passenv = + HOME + TERM + CS_* + OS_* + TEST_* deps = -r{toxinidir}/test-requirements.txt [testenv:py35] @@ -77,8 +66,8 @@ deps = -r{toxinidir}/requirements.txt [testenv:pep8] basepython = python3 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = flake8==7.1.1 + git+https://github.com/juju/charm-tools.git commands = flake8 {posargs} src unit_tests tests [testenv:cover] diff --git a/unit_tests/test_openstack_loadbalancer_charm.py b/unit_tests/test_openstack_loadbalancer_charm.py index 746b41a..7f1c6bd 100644 --- a/unit_tests/test_openstack_loadbalancer_charm.py +++ b/unit_tests/test_openstack_loadbalancer_charm.py @@ -16,6 +16,7 @@ import ipaddress import json +import os import re import sys import unittest @@ -25,7 +26,9 @@ sys.path.append('src') # noqa from mock import patch -from ops.testing import Harness, _TestingModelBackend +from ops._private.harness import _TestingModelBackend +from ops.jujucontext import _JujuContext +from ops.testing import Harness from ops import framework, model import charm from unit_tests.manage_test_relations import ( @@ -72,6 +75,8 @@ class TestOpenstackLoadbalancerCharmBase(CharmTestCase): def get_harness(self): initial_config = {} + # dummy juju version + os.environ["JUJU_VERSION"] = "0.0.0" _harness = Harness( _OpenstackLoadbalancerCharm, meta=''' @@ -122,7 +127,10 @@ requires: return network_data[endpoint_name] _harness._backend = _TestingOPSModelBackend( - _harness._unit_name, _harness._meta) + _harness._unit_name, + _harness._meta, + _harness._get_config(None), + _JujuContext.from_dict(os.environ),) _harness._model = model.Model( _harness._meta, _harness._backend)