-
Notifications
You must be signed in to change notification settings - Fork 1
✨ [open-zaak/open-notificaties#156] Several changes to Kanalen #14
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc0d1d2
:sparkles: [open-zaak/open-notificaties#156] Pass request as kwarg to…
stevenbal 0b43ac5
:sparkles: [open-zaak/open-notificaties#156] Allow custom help_texts …
stevenbal edd20d1
:white_check_mark: Clean up mock usage in test_register_webhook
stevenbal edf484d
:ok_hand: [open-zaak/open-notificaties#156] Process PR feedback
stevenbal 5f04d30
:sparkles: [open-zaak/open-notificaties#156] Add generate_notificatie…
stevenbal 48b9571
:white_check_mark: [open-zaak/open-notificaties#156] Add/fix tests fo…
stevenbal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
notifications_api_common/management/commands/generate_notificaties.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from django.conf import settings | ||
from django.core.management import BaseCommand | ||
from django.template.loader import render_to_string | ||
|
||
from notifications_api_common.kanalen import KANAAL_REGISTRY | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Generate a markdown file documenting the notification channels of the component | ||
""" | ||
|
||
def add_arguments(self, parser): | ||
super().add_arguments(parser) | ||
|
||
parser.add_argument( | ||
"--output-file", | ||
dest="output_file", | ||
default=None, | ||
help="Name of the output file", | ||
) | ||
|
||
def handle(self, output_file, *args, **options): | ||
kanalen = sorted(KANAAL_REGISTRY, key=lambda s: s.label) | ||
|
||
template = "notifications_api_common/notificaties.md" | ||
markdown = render_to_string( | ||
template, | ||
context={ | ||
"kanalen": kanalen, | ||
"project_name": settings.PROJECT_NAME, | ||
"site_title": settings.SITE_TITLE, | ||
}, | ||
) | ||
|
||
with open(output_file, "w") as f: | ||
f.write(markdown) |
24 changes: 24 additions & 0 deletions
24
notifications_api_common/templates/notifications_api_common/notificaties.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Notificaties | ||
## Berichtkenmerken voor {{ project_name }} API | ||
|
||
Kanalen worden typisch per component gedefinieerd. Producers versturen berichten op bepaalde kanalen, | ||
consumers ontvangen deze. Consumers abonneren zich via een notificatiecomponent (zoals {{ 'https://notificaties-api.vng.cloud/api/v1/schema/'|urlize }}) op berichten. | ||
|
||
Hieronder staan de kanalen beschreven die door deze component gebruikt worden, met de kenmerken bij elk bericht. | ||
|
||
De architectuur van de notificaties staat beschreven op {{ 'https://github.com/VNG-Realisatie/notificaties-api'|urlize }}. | ||
|
||
{% for kanaal in kanalen %} | ||
### {{ kanaal.label }} | ||
|
||
**Kanaal** | ||
`{{ kanaal.label }}` | ||
|
||
{{ kanaal.description|default:""|urlize }} | ||
|
||
**Resources en acties** | ||
|
||
{% for resource, actions in kanaal.get_usage %} | ||
* <code>{{ resource }}</code>: {{ actions|join:", " }} | ||
{% endfor %} | ||
{% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from unittest.mock import mock_open, patch | ||
|
||
from django.test.testcases import call_command | ||
|
||
import pytest | ||
|
||
EXPECTED_OUTPUT = """## Notificaties | ||
## Berichtkenmerken voor Notifications API Common API | ||
|
||
Kanalen worden typisch per component gedefinieerd. Producers versturen berichten op bepaalde kanalen, | ||
consumers ontvangen deze. Consumers abonneren zich via een notificatiecomponent (zoals <a href="https://notificaties-api.vng.cloud/api/v1/schema/" rel="nofollow">https://notificaties-api.vng.cloud/api/v1/schema/</a>) op berichten. | ||
|
||
Hieronder staan de kanalen beschreven die door deze component gebruikt worden, met de kenmerken bij elk bericht. | ||
|
||
De architectuur van de notificaties staat beschreven op <a href="https://github.com/VNG-Realisatie/notificaties-api" rel="nofollow">https://github.com/VNG-Realisatie/notificaties-api</a>. | ||
|
||
|
||
### personen | ||
|
||
**Kanaal** | ||
`personen` | ||
|
||
**Main resource** | ||
|
||
`person` | ||
|
||
|
||
|
||
**Kenmerken** | ||
|
||
* `name`: The name of the person | ||
* `address_street`: custom help text | ||
|
||
**Resources en acties** | ||
|
||
|
||
* <code>person</code>: create, update, destroy | ||
|
||
|
||
""" | ||
|
||
|
||
@pytest.mark.django_db | ||
@patch( | ||
"notifications_api_common.management.commands.generate_notificaties.open", | ||
new_callable=mock_open, | ||
) | ||
def test_generate_notificaties(mock_file): | ||
call_command("generate_notificaties", output_file=["foobar"]) | ||
|
||
mock_file().write.assert_called_once_with(EXPECTED_OUTPUT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.