diff --git a/ops-sunbeam/.github/workflows/tox.yaml b/ops-sunbeam/.github/workflows/tox.yaml index ddfeff1e..e9fab591 100644 --- a/ops-sunbeam/.github/workflows/tox.yaml +++ b/ops-sunbeam/.github/workflows/tox.yaml @@ -9,8 +9,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9] - + python-version: + - "3.8" + - "3.9" + - "3.10" steps: - uses: actions/checkout@v1 - name: Set up Python ${{ matrix.python-version }} diff --git a/ops-sunbeam/advanced_sunbeam_openstack/test_utils.py b/ops-sunbeam/advanced_sunbeam_openstack/test_utils.py index 1630f7aa..a58ca5d9 100644 --- a/ops-sunbeam/advanced_sunbeam_openstack/test_utils.py +++ b/ops-sunbeam/advanced_sunbeam_openstack/test_utils.py @@ -35,7 +35,12 @@ sys.path.append("src") # noqa from ops import framework, model -from ops.testing import Harness, _TestingModelBackend, _TestingPebbleClient +from ops.testing import ( + Harness, + _TestingModelBackend, + _TestingPebbleClient, + SIMULATE_CAN_CONNECT, +) TEST_CA = '''-----BEGIN CERTIFICATE----- @@ -552,6 +557,7 @@ def get_harness( # /charm/containers/placement-api/pebble.socket client.container_name = socket_path.split('/')[3] self._pebble_clients[socket_path] = client + self._pebble_clients_can_connect[client] = not SIMULATE_CAN_CONNECT return client def network_get( diff --git a/ops-sunbeam/tox.ini b/ops-sunbeam/tox.ini index 4ee19f10..6174d833 100644 --- a/ops-sunbeam/tox.ini +++ b/ops-sunbeam/tox.ini @@ -47,17 +47,17 @@ basepython = python3 deps = -r{toxinidir}/cookie-requirements.txt commands = /bin/true -[testenv:py38] +[testenv:py3.8] basepython = python3.8 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -[testenv:py39] +[testenv:py3.9] basepython = python3.9 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -[testenv:py310] +[testenv:py3.10] basepython = python3.10 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt diff --git a/ops-sunbeam/unit_tests/__init__.py b/ops-sunbeam/unit_tests/__init__.py index 4b1a87f1..7824f6c5 100644 --- a/ops-sunbeam/unit_tests/__init__.py +++ b/ops-sunbeam/unit_tests/__init__.py @@ -13,3 +13,5 @@ # limitations under the License. """Unit tests for aso.""" +import ops.testing +ops.testing.SIMULATE_CAN_CONNECT = True diff --git a/ops-sunbeam/unit_tests/test_core.py b/ops-sunbeam/unit_tests/test_core.py index 849e5ab9..4d93a835 100644 --- a/ops-sunbeam/unit_tests/test_core.py +++ b/ops-sunbeam/unit_tests/test_core.py @@ -47,9 +47,7 @@ class TestOSBaseOperatorCharm(test_utils.CharmTestCase): def set_pebble_ready(self) -> None: """Set pebble ready event.""" - container = self.harness.model.unit.get_container("my-service") - # Emit the PebbleReadyEvent - self.harness.charm.on.my_service_pebble_ready.emit(container) + self.harness.container_pebble_ready('my-service') def test_pebble_ready_handler(self) -> None: """Test is raised and observed."""