Skip to content

[tests | unit] test_all_api_sections_initialized only covers 10 of 22 registered categories #497

Description

@priyavrat7

Describe how you confirmed the issue is with the library, and not with the API itself, or a server-side issue of some other kind.

This is a test coverage issue in the library and is not related to the Meraki API or any server-side behavior.

I confirmed this entirely locally without making any API calls. I compared the API category registrations in meraki/__init__.py with the assertions in test_all_api_sections_initialized in tests/unit/test_dashboard_api_init.py.

There are 22 API categories registered in DashboardAPI, but the initialization test only checks 10 of them.

Python version installed

3.13.5

Meraki library version installed

4.5.0b4
API v1.74.0-beta.4

Have you reproduced the issue with the latest version of this library? And with the latest version of Python?

Yes. Reproduced on the current beta branch with Python 3.13.5.

OS Platform

macOS 26.5.1

This is not platform specific since the issue is in the Python test coverage.

Describe the bug

test_all_api_sections_initialized currently checks only 10 of the 22 API categories registered in meraki/__init__.py.

The 10 categories currently covered by the test are:

assert d.organizations is not None
assert d.networks is not None
assert d.devices is not None
assert d.appliance is not None
assert d.wireless is not None
assert d.nac is not None
assert d.secureConnect is not None
assert d.support is not None
assert d.users is not None
assert d.assistant is not None

This leaves 12 registered categories without an explicit assertion in the initialization test:

administered
batch
camera
campusGateway
cellularGateway
insight
licensing
sensor
sm
spaces
switch
wirelessController

I checked these 12 categories individually.

administered has incidental coverage because it is used by tests/unit/test_mock_integration.py:

me = dashboard.administered.getAdministeredIdentitiesMe()

The purpose of that test is to test getAdministeredIdentitiesMe(), not specifically to verify that administered is initialized. However, the test depends on dashboard.administered existing. If administered was no longer registered in DashboardAPI, the test would fail with an AttributeError.

The other 11 categories do not have test coverage in tests/unit/ that would detect if their registration was removed or broken.

For example, if this line was accidentally removed or commented:

self.camera = Camera(self._session)

the current initialization test would still pass because it does not check d.camera for as one of the examples.

This means a future change could break the registration of one of these categories while the unit test suite still passes.

This is a follow up to the registration issue addressed in #472 and PR #485. PR #485 added initialization coverage for five categories and identified the remaining categories as a possible follow up.

How can we replicate the problem you're reporting?

  1. Open meraki/__init__.py.
  2. Comment out one of the categories that does not have explicit initialization coverage. For example:
# self.camera = Camera(self._session)
  1. Run the unit test suite:
uv run pytest tests/unit -q
  1. The current unit test suite still passes because there is no test checking whether d.camera exists.

The same applies to the other categories without coverage.

For comparison, administered is different because test_mock_integration.py already uses:

dashboard.administered.getAdministeredIdentitiesMe()

If administered is not registered, that test fails with:

AttributeError: 'DashboardAPI' object has no attribute 'administered'

This means administered has incidental coverage, while the other 11 categories do not have coverage that would detect a broken registration.

Expected behavior

test_all_api_sections_initialized should explicitly check all 22 categories registered by DashboardAPI.

The missing assertions are:

assert d.administered is not None
assert d.batch is not None
assert d.camera is not None
assert d.campusGateway is not None
assert d.cellularGateway is not None
assert d.insight is not None
assert d.licensing is not None
assert d.sensor is not None
assert d.sm is not None
assert d.spaces is not None
assert d.switch is not None
assert d.wirelessController is not None

This would make the initialization test directly verify every registered API category.

If a category is accidentally removed or no longer initialized in DashboardAPI, the unit test would fail immediately.

Code snippets

Current test:

assert d.organizations is not None
assert d.networks is not None
assert d.devices is not None
assert d.appliance is not None
assert d.wireless is not None
assert d.nac is not None
assert d.secureConnect is not None
assert d.support is not None
assert d.users is not None
assert d.assistant is not None

Missing assertions:

assert d.administered is not None
assert d.batch is not None
assert d.camera is not None
assert d.campusGateway is not None
assert d.cellularGateway is not None
assert d.insight is not None
assert d.licensing is not None
assert d.sensor is not None
assert d.sm is not None
assert d.spaces is not None
assert d.switch is not None
assert d.wirelessController is not None

Additional context

This is a follow up to #472 and PR #485, which was merged into beta.

PR #485 fixed missing initialization for five API categories and identified the remaining categories as a possible follow up.

I would be happy to submit a PR for this issue. The change should be straightforward as just to add the missing assertions using the same pattern as the existing test, along with the appropriate changelog entry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions