Skip to content

Add basic integration tests for all endpoints + API Keys tests #1241

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

Merged
merged 14 commits into from
Sep 22, 2023

Conversation

dmytrotsko
Copy link
Contributor

Summary:

Added basic integration tests for all endpoints + API Keys tests

Prerequisites:

  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

@dmytrotsko dmytrotsko requested a review from melange396 July 21, 2023 13:14
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 3 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
1.9% 1.9% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is awesome! You put a lot of work into this PR, and it will be very much worth the time when these tests help someone catch a bug later!

from delphi.epidata.server._limiter import limiter


class BasicIntegrationTest(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class BasicIntegrationTest(unittest.TestCase):
class IntegrationTestBase(unittest.TestCase):

^ name suggestion to hopefully make it obvious that this is a "base" class. (im also a little bit tempted to call it DelphiTestBase, but thats up to you)


this class has a number of things in common with our other unittest.TestCase subclass / test base class helper: CovidcastBase. CovidcastBase would best be redesigned as a subclass of the common IntegrationTestBase that then adds epimetric_* table truncations in setUp() and the additional row helper methods.

would it be difficult to combine them?

NOTE: maybe the suggested changes of combining / refactoring with CovidcastBase could be its own PR (if at all) after this one is merged. also, CovidcastBase has a number of things i think should change, such as changing the name to CovidcastTestBase and relocating the file to src/common/ instead of being under src/acquisition/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that renaming is reasonable.

Yeah, I have also thought about combining this class with CovidcastBase, but it will be better to do that in a separate PR(after this one is merged).

Comment on lines +17 to +18
self.delete_from_tables_list = []
self.truncate_tables_list = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need both DELETE and TRUNCATE? TRUNCATE is faster for bigger tables, but that shouldnt really matter in integration tests. TRUNCATE will also reset AUTO_INCREMENT counters, but hopefully all of our tests are agnostic to any assigned id values and such.

it will be simpler to have only one of these, but if there is a good reason for having both, thats fine too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is unfortunate but yes, we need both of them. There are some tables with relations that can not be truncated(because of that relations) so the only way to clear them is to use DELETE FROM <table> statement.

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, just a few little things i noticed...

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 3 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
2.0% 2.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!

@melange396 melange396 merged commit 94a2551 into dev Sep 22, 2023
@melange396 melange396 deleted the 1068-add-basic-integration-tests-for-all-endpoints branch September 22, 2023 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants