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

Set up CI API test framework to check database state #1880

Closed
Tracked by #765
svenseeberg opened this issue Nov 19, 2022 · 5 comments · Fixed by #2070
Closed
Tracked by #765

Set up CI API test framework to check database state #1880

svenseeberg opened this issue Nov 19, 2022 · 5 comments · Fixed by #2070
Assignees
Labels
💡 feature New feature or request ⁉️ prio: low Not urgent, can be resolved in the distant future. ❓ question Further information is requested 😅 effort: medium Should be doable in <12h
Milestone

Comments

@svenseeberg
Copy link
Member

Motivation

In our CI API tests we only check for response codes and return values. In some cases, for example feedback, we have currently have no way of verifying if the feedback has actually been saved to the database.

Proposed Solution

Add a new parameter to to our API (and potentially other tests) that allows checking the state of the database. One option for implementing this would be to have two additional parameters in our list of tests:

  • A raw(?) SQL query that is run
  • An expected output/return value of the query

Alternatives

Find better alternatives to check if a database manipulation was actually successful.

Additional Context

Design Requirements

@svenseeberg svenseeberg added 💡 feature New feature or request ❓ question Further information is requested 😅 effort: medium Should be doable in <12h labels Nov 19, 2022
@svenseeberg svenseeberg added this to the 23Q1 milestone Nov 19, 2022
@svenseeberg svenseeberg changed the title Set upCI test framework to check database state Set up CI test framework to check database state Nov 19, 2022
@svenseeberg svenseeberg mentioned this issue Nov 19, 2022
33 tasks
@timobrembeck
Copy link
Member

timobrembeck commented Nov 19, 2022

I think for all those views, the one-fits-all approach doesn't quite work.
Instead, I suggest to add single test functions where not only the database state can be tested, but also the return html can be inspected for e.g. the error/success messages, the logging output can be traced, different form inputs can be checked to ensure that invalid input correctly throws an error etc... similar tests which are already implemented are e.g.:

@svenseeberg
Copy link
Member Author

I agree that there there is not one solution for all tests. But I think for the API calls we could extend https://github.com/digitalfabrik/integreat-cms/blob/develop/tests/api/api_config.py#L6 additional parameters to check the database state. That would potentially allow us to merge the Push Content API tests with the other API tests. Alternatively, we could split between read only and writable API endpoints?

In regards to front end view I think you're totally right. These are too diverse for reducing this to a common list of parameters.

I'll adjust the title of the issue.

@svenseeberg svenseeberg changed the title Set up CI test framework to check database state Set up CI API test framework to check database state Nov 21, 2022
@seluianova
Copy link
Contributor

Find better alternatives to check if a database manipulation was actually successful.

I would suggest checking changes through models. I.e. query data into a model object and validate its fields.

@seluianova
Copy link
Contributor

Added checks for cms_feedback table. Also need to cover tables for different feedback types, like cms_pagefeedback, cms_poifeedback etc.

@seluianova seluianova reopened this Feb 22, 2023
@timobrembeck timobrembeck modified the milestones: 23Q1, 23Q2 Mar 22, 2023
@timobrembeck timobrembeck added the ⁉️ prio: low Not urgent, can be resolved in the distant future. label Mar 22, 2023
@timobrembeck timobrembeck modified the milestones: 23Q2, 23Q3 Jul 2, 2023
@svenseeberg svenseeberg modified the milestones: 23Q3, 23Q4 Oct 4, 2023
@seluianova
Copy link
Contributor

Added checks for cms_feedback table. Also need to cover tables for different feedback types, like cms_pagefeedback, cms_poifeedback etc.

I think an existing type check might be actually enough here...

assert isinstance(feedback, feedback_type_dict[view_name])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 feature New feature or request ⁉️ prio: low Not urgent, can be resolved in the distant future. ❓ question Further information is requested 😅 effort: medium Should be doable in <12h
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants