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

Move named url init out of Middleware init #15085

Merged

Conversation

chrismeyersfsu
Copy link
Member

SUMMARY
  • Middleware classes can be instantiated multiple times in testing. To make this a non-issue, move the init code for named urls out of the middleware init and into the app init.
  • This makes it easier to use other testing facilities, like LiveServerTestCase, without having to mock the named url middleware init.
ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API
AWX VERSION
devel
ADDITIONAL INFORMATION

@@ -245,6 +244,8 @@ def _generate_configurations(nodes):


def _dfs(configuration, model, graph, dead_ends, new_deadends, parents):
from django.contrib.contenttypes.models import ContentType
Copy link
Member Author

Choose a reason for hiding this comment

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

named_url_graph.py is now imported and used in the app ready path. This is a bootstrapping phase and like any bootstrapping phase all the facilities aren't initialized. We have to be careful of what we import and when.

Delays this import.



def _customize_graph():
from django.contrib.auth.models import User
Copy link
Member Author

Choose a reason for hiding this comment

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

Delay User import.

@chrismeyersfsu chrismeyersfsu enabled auto-merge (rebase) April 10, 2024 19:28
* Middleware classes can be instantiated multiple times in testing. To
  make this a non-issue, move the init code for named urls out of the
  middleware init and into the app init.
* This makes it easier to use other testing facilities, like
  LiveServerTestCase, without having to mock the named url middleware
  init.
@chrismeyersfsu chrismeyersfsu merged commit 61ec03e into ansible:devel Apr 10, 2024
19 of 20 checks passed
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.

2 participants