ansible / django-ansible-base

Apache License 2.0
11 stars 43 forks source link

Fix incorrect mock object calls #518

Closed AlanCoding closed 1 month ago

AlanCoding commented 1 month ago

The problem with mocked objects is that any properties will return a "fake" method. So mockeddecode.called_with just gives you a made-up method that does nothing. If you assert mocked_obj.called_with('foo'), then the fake method says "ok", returns some other made-up thing, and test passes.

I don't know what the consequence of these failures are, but I want to identify them and hopefully assign someone to either fix them or do something else.

AlanCoding commented 1 month ago

logging failures

FAILED test_app/tests/authentication/authenticator_plugins/test_radius.py::test_authenticator_plugin

E           AssertionError: expected call not found.
E           Expected: authenticate(username='user-73aa1c', password='radius_password-4aa69d')
E           Actual: authenticate(None, 'user-73aa1c', 'radius_password-4aa69d')

FAILED test_app/tests/authentication/authenticator_plugins/test_oidc.py::test_user_data

E           AssertionError: expected call not found.
E           Expected: decode('token', 'VALUE', 'VALUE', 'VALUE')
E           Actual: decode('token', key='-----BEGIN PUBLIC KEY-----\nVALUE\n-----END PUBLIC KEY-----', algorithms='VALUE', audience='VALUE')
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud