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 TestCase | only "models" works as app_label #1457

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

esrehmki
Copy link

- in the current implementation only "models" works as app_label
- there is no way to change that during run time as it's hard coded
- the fix introduces another _APP_LABEL global variable that is set
   in the initializer

Enables testing of apps with other labels than "models" in test classes of tortoise/contrib/test
automagically from the TORTOISE_ORM config dict.

Description

Following the design of the file, a new global variable is introduced that is defined during the
call of the initializer function. Later occurences of the app_label function parameter in _setUpDB
member functions, that don't expose the app_label variable, are provided with _APP_LABEL as
default value.

Motivation and Context

App labels other than 'models' were not correctly propagated to the test functions, as 'models'
was hardcoded as app_label in the _setUpDB member functions.

How Has This Been Tested?

Existing tests of the package pass.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

    - in the current implementation only "models" works as app_label
    - there is no way to change that during run time as it's hard coded
    - the fix introduces another _APP_LABEL global variable that is set
       in the initializer
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.

1 participant