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 app configuration in create_app for testing. #5808

Merged
merged 2 commits into from
May 31, 2023

Conversation

Aadesh-Baral
Copy link
Contributor

@Aadesh-Baral Aadesh-Baral commented May 19, 2023

When running tests for the function that involves creating a thread and an associated app context, we encountered an issue with the app configuration. The create_app function, responsible for creating the app context, was using the default EnvironmentConfig class even during testing.

To address this issue, we made a modification in the create_app function. We added a condition that checks if the TM_ENVIRONMENT environment variable is set to "test". If so, the configuration is set to TestEnvironmentConfig instead of the default EnvironmentConfig.

By introducing this conditional logic, it ensures that the create_app function correctly sets the TestEnvironmentConfig for the app created across the project when the test environment is detected.

closes #5691

@eternaltyro
Copy link
Contributor

@Aadesh-Baral can you move the integration test out of this PR and into its own PR?

--------------------------------------------------------------
Modified the create_app function to include a condition that sets the configuration to TestEnvironmentConfig when the TM_ENVIRONMENT environment variable is set to "test".
This change ensures that the  app uses the appropriate configuration, even during testing.
…esting

-------------------------------------------------------------------
Since this function runs on a seperate thread it causes issues while performing database cleanup as soon as the test is complete as the function will still be executing on different thread.
@sonarcloud
Copy link

sonarcloud bot commented May 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@Aadesh-Baral
Copy link
Contributor Author

@Aadesh-Baral can you move the integration test out of this PR and into its own PR?

Done @eternaltyro

Copy link
Contributor

@eternaltyro eternaltyro left a comment

Choose a reason for hiding this comment

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

LGTM

@eternaltyro eternaltyro merged commit d3f645e into develop May 31, 2023
8 checks passed
@eternaltyro eternaltyro deleted the fix/5691-backend-tests branch May 31, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Several errors in Backend CI even though the pipeline seems to pass
2 participants