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

Add name prefixing to BP groups #2727

Merged
merged 7 commits into from Jul 5, 2023
Merged

Add name prefixing to BP groups #2727

merged 7 commits into from Jul 5, 2023

Conversation

ahopkins
Copy link
Member

@ahopkins ahopkins commented Mar 28, 2023

Because of the removal of duplicate route naming, the following is no longer possible. This was a hidden use case that we did not have unit tests to cover, and so the change was not caught.

bp1 = Blueprint("bp1", url_prefix="/bp1")
bp2 = Blueprint("bp2", url_prefix="/bp2")

bp1.add_route(..., "/")
bp2.add_route(..., "/")

group_a = Blueprint.group(bp1, bp2, url_prefix="/group-a")
group_b = Blueprint.group(bp1, bp2, url_prefix="/group-b")

app.blueprint(group_a)
app.blueprint(group_b)

The solution is to add name_prefix to go along with version_prefix and url_prefix to the BlueprintGroup. This will allow proper constructing and nesting of blueprints and groups.


TODO:

  • Tests

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Patch coverage: 100.000% and project coverage change: +0.074 🎉

Comparison is base (f48506d) 88.887% compared to head (b425af0) 88.962%.

❗ Current head b425af0 differs from pull request most recent head 13da6e2. Consider uploading reports for the commit 13da6e2 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2727       +/-   ##
=============================================
+ Coverage   88.887%   88.962%   +0.074%     
=============================================
  Files           92        92               
  Lines         6956      6967       +11     
  Branches      1185      1187        +2     
=============================================
+ Hits          6183      6198       +15     
+ Misses         529       527        -2     
+ Partials       244       242        -2     
Impacted Files Coverage Δ
sanic/app.py 90.152% <100.000%> (+0.050%) ⬆️
sanic/blueprint_group.py 100.000% <100.000%> (ø)
sanic/blueprints.py 91.549% <100.000%> (+0.161%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ahopkins ahopkins changed the base branch from main to current-release March 30, 2023 07:54
@ahopkins ahopkins marked this pull request as ready for review March 30, 2023 08:38
@ahopkins ahopkins requested a review from a team as a code owner March 30, 2023 08:38
ChihweiLHBird
ChihweiLHBird previously approved these changes Jun 19, 2023
@ahopkins ahopkins changed the base branch from current-release to main July 5, 2023 09:23
@ahopkins ahopkins dismissed ChihweiLHBird’s stale review July 5, 2023 09:23

The base branch was changed.

@ahopkins ahopkins merged commit 4068a0d into main Jul 5, 2023
30 checks passed
@ahopkins ahopkins deleted the bp-group-name-prefix branch July 5, 2023 16:31
moshe742 pushed a commit to moshe742/sanic that referenced this pull request Jul 8, 2023
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.

None yet

2 participants