-
Notifications
You must be signed in to change notification settings - Fork 49
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
test: mock pypandoc.convert_text when testing export views #1117
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
How should I test render_to_format? With a single project from the database and once for every export format, meaning number of tests = number of export formats. It could also be number of rdmo models * number of export formats. Both is better than running pypandoc for each user in multiple parametrized tests. |
I think it should suffice to run pandoc with one html output for each format. For some reason |
This comment was marked as resolved.
This comment was marked as resolved.
I think of a dedicated test like this:
I wonder if we ever would ever look at the outputs. I think just checking if the render_to_format runs without error is enough. |
I still need to add the "one" test, but the mocking shaved off a couple of minutes of ci runtime. It is now under 30 minutes. |
|
||
@pytest.mark.django_db() | ||
@pytest.mark.parametrize("export_format", export_formats) | ||
def test_render_to_format(rf, context, export_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render_to_format
, export_format xml
and project don't play along. xml
was not tested previously. This kind of data can not be exportes as xml?
Is the test still alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xml
is not using render_to_format
so it does not need to be tested here. It should also stay in the regular tests and not be mocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine otherwise, thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
Okay, thanks for the hint. Only pypandoc.convert_text
is mocked.
I removed multiple checks of the generated XML. Should these checks stay then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the xml serializers/renderers stuff is pretty unique and also fast, please keep it in
|
||
@pytest.mark.django_db() | ||
@pytest.mark.parametrize("export_format", export_formats) | ||
def test_render_to_format(rf, context, export_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xml
is not using render_to_format
so it does not need to be tested here. It should also stay in the regular tests and not be mocked.
|
||
@pytest.mark.django_db() | ||
@pytest.mark.parametrize("export_format", export_formats) | ||
def test_render_to_format(rf, context, export_format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine otherwise, thanks a lot!
I am confused. What is the next target branch for PRs? release-2.3.0 or 2.3.0? |
Hi @afuetterer , the new development branch is |
Description
Resolves #1092 and #1113
Tasks
mocked_convert_text
fixture, which should be used in combination withexport_format
fixture, when testing export viewsmocked_convert_text
to all export view test functionsassert root.tag == 'rdmo'
)Types of Changes
Checklist