Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up unit tests #241

Open
21 tasks
led02 opened this issue Feb 9, 2024 · 1 comment
Open
21 tasks

Fix up unit tests #241

led02 opened this issue Feb 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working Hackathon24 Issues that should be fixed in or until the Hackathon 24 (December) help wanted Extra attention is needed

Comments

@led02
Copy link
Member

led02 commented Feb 9, 2024

During refactoring a lot of stuff tests were failing. During #234 lots of tests got de-activated (using @pytest.skip) due to the changes. These need to be reactivated, refactored or removed.

  • @led02 was too lazy to fix the depositor and repsolver fixtures in hermes_test.deposit.invenio but they should be reasonable to be refactored (maybe now even without the need of monkey patching).
  • @SKernchen was instructed to not put too much effort in the refactoring to push the process forward.

Maybe we could also collect a list of tests that are still to be handled as a first step here:

hermes_test.test_cli

These tests are subject to change in #231

  • hermes_test.test_cli:test_hermes_with_deposit
  • hermes_test.test_cli:test_hermes_with_postprocess
  • hermes_test.test_cli:test_hermes_with_deposit_and_postprocess
  • hermes_test.test_cli:test_hermes_with_deposit_and_path
  • hermes_test.test_cli:test_hermes_with_deposit_and_postprocess_and_path

hermes_test.commands.deposit.test_invenio

These tests use mock-magic to evade a clean, dependency-injection kind interface.
They should also be checked for potential of combining different tests using parametrization...

  • hermes_test.commands.deposit.test_invenio:test_resolve_doi: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_resolve_doi_wrong_host: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_resolve_doi_unknown: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_resolve_record_id: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_resolve_record_id_unknown: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_resolve_record_id_latests_unknown: uses resolver fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_closed: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_embargoed_not_date_no_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_embargoed_no_date_with_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_embargoed_with_date_with_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_embargoed_with_broken_date_with_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_restricted_no_conditions: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_restricted_with_conditions: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_open_no_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_open_with_license: uses depositor fixture
  • hermes_test.commands.deposit.test_invenio:test_get_access_modalities_broken_access_right: uses depositor fixture
@led02 led02 added bug Something isn't working help wanted Extra attention is needed labels Feb 9, 2024
@led02
Copy link
Member Author

led02 commented Feb 9, 2024

Okay, in fact both https://github.com/hermes-hmc/hermes/blob/61470a858de56751213e293e1dbae5531a0598f3/test/hermes_test/commands/deposit/test_invenio.py#L18 and https://github.com/hermes-hmc/hermes/blob/61470a858de56751213e293e1dbae5531a0598f3/test/hermes_test/commands/deposit/test_invenio.py#L30 denote an anti-pattern.

Instead of

with mock.patch(...) as mocked_config:
    mocked_config.returnvalue = {...}
    res = ConfiguredClass()
return res

it should be

mocked_config = ConfigClass()
mocked_config.foo = 'bar'
return ConfiguredClass(mocked_config)

(or at least similer).

I.e., we should check our relevant interface for dependency injection instead of some global state.

@SKernchen SKernchen added the Hackathon24 Issues that should be fixed in or until the Hackathon 24 (December) label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hackathon24 Issues that should be fixed in or until the Hackathon 24 (December) help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants