Page MenuHomeSoftware Heritage

Start writing tests for the scheduler CLI.
ClosedPublic

Authored by vlorentz on Feb 21 2019, 3:08 PM.

Details

Diff Detail

Repository
rDSCH Scheduling utilities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

  • Fix celery test issue with import order.
  • Add tests for list_pending_tasks.
olasd requested changes to this revision.EditedFeb 27 2019, 12:02 PM
olasd added a subscriber: olasd.

Thanks for this, looks like a good starting point.

I think I'd wrap the regular expressions' first line with a backslash to look like this:

    expected = r'''\
\[INFO\] swh.core.config -- Loading config file .*
Found 1 swh-test-ping tasks

[...]
'''

So that the full text can be more easily copy/pasted.

We can also probably use re.fullmatch to drop the need for the start anchor (I think?)

swh/scheduler/cli.py
105

Should probably be updated to say "none set" or something

swh/scheduler/tests/test_cli.py
24–35

Please add a comment to document why we need to jump these hoops. I think I understand it but better be explicit :)

This revision now requires changes to proceed.Feb 27 2019, 12:02 PM
In D1173#25465, @olasd wrote:

I think I'd wrap the regular expressions' first line with a backslash to look like this:

    expected = r'''\
\[INFO\] swh.core.config -- Loading config file .*
Found 1 swh-test-ping tasks

[...]
'''

So that the full text can be more easily copy/pasted.

I tried, it doesn't work.

>>> foo = r'''\
... foo'''
>>> print(foo)
\
foo

We can also probably use re.fullmatch to drop the need for the start anchor (I think?)

TIL

In D1173#25465, @olasd wrote:

I think I'd wrap the regular expressions' first line with a backslash to look like this:

    expected = r'''\
\[INFO\] swh.core.config -- Loading config file .*
Found 1 swh-test-ping tasks

[...]
'''

So that the full text can be more easily copy/pasted.

I tried, it doesn't work.

>>> foo = r'''\
... foo'''
>>> print(foo)
\
foo

Ah, duh.

I guess we can add a leading newline (no escape) and add a .lstrip() to trim it afterwards.

In D1173#25471, @olasd wrote:

I guess we can add a leading newline (no escape) and add a .lstrip() to trim it afterwards.

Good point

  • Add newline at the beginning of regexps and use lstrip().
  • Rebase
  • Exclude wsgi module from collection
  • Squash
This revision is now accepted and ready to land.Feb 27 2019, 1:14 PM
This revision was automatically updated to reflect the committed changes.