Unit tests fail for KeyError in MagicMock of CompareOpenStackReleases

Bug #2066281 reported by Jadon Naas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Designate-Bind Charm
Status tracked in Trunk
Trunk
In Progress
Undecided
Jadon Naas

Bug Description

When running unit tests against the master branch of the OpenStack Designate Bind charm the 13 tests fail with errors like the following:

unit_tests.test_lib_charm_openstack_designate_bind.TestOpenStackDesignateBind.test_get_sync_time
------------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "./charm-designate-bind/unit_tests/test_lib_charm_openstack_designate_bind.py", line 112, in test_get_sync_time
    designate_bind.DesignateBindCharm.singleton,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "./charm-designate-bind/.tox/py3/lib/python3.11/site-packages/charms_openstack/charm/core.py", line 386, in singleton
    _singleton = get_charm_instance(release=release,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "./charm-designate-bind/.tox/py3/lib/python3.11/site-packages/charms_openstack/charm/core.py", line 199, in get_charm_instance
    return (_get_charm_instance_function or default_get_charm_instance)(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "./charm-designate-bind/.tox/py3/lib/python3.11/site-packages/charms_openstack/charm/core.py", line 163, in default_get_charm_instance
    cls = _releases[known_releases[-1]][package_type]
          ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^

    KeyError: "<MagicMock name='mock.contrib.openstack.utils.CompareOpenStackReleases()' id='135987910273104'>"

This failure is related to this change in charms.openstack - https://github.com/openstack/charms.openstack/commit/760f1257ef11a53e2491fda91ebf6454c1182ad3 - that added support for wrapped release names in OpenStack. That change in charms.openstack changed how obtaining OpenStack release names behaves, and the Designate Bind charm's mocking is incompatible with that change.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-designate-bind (master)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.