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

Test and officially bless generic views for use by plugins #474

Merged
merged 6 commits into from
May 24, 2021

Conversation

jathanism
Copy link
Contributor

@jathanism jathanism commented May 20, 2021

Fixes: #14

Moved dummy_plugin to examples/dummy_plugin at project root

  • Added a README.md and a pyproject.toml for it
  • Added it as a dev dependency to nautobot's root pyproject.toml
  • Add a version string to the plugin
  • Added a to_csv() method to DummyModel
  • Asserted that unit tests ran
  • Implemented generic views for DummyModel
    • Added URLs and everything
    • Added a detail view template
    • Added tables, filters, forms, search, changelog
  • Updated plugin code quite a bit to use correct bases for API serializers/views to get all tests passing
  • Changed base of API DummyModelViewSet to use nautobot.core.api.views.ModelViewSet
  • Changed base of API DummyModelSerializer to use nautobot.core.api.serializers.ValidatedModelSerializer
  • Added url field to API DummyModelSerializer
  • Switched API urls to use nautobot.core.api.OrderedDefaultRouter to get bulk update/delete working correctly.
  • Updated Invoke tasks to also run black/flake8 on examples/
  • Added a poetry.lock file for dummy_plugin

- Added a `README.md` and a `pyproject.toml` for it
- Added it as a dev dependency to nautobot's root `pyproject.toml`
- Asserted that unit tests ran:

```
Creating test database for alias 'default'...

System check identified no issues (0 silenced).
.....................
----------------------------------------------------------------------
Ran 21 tests in 0.134s

OK
Destroying test database for alias 'default'...
```
- Added URLs and everything
- Added a detail view template
- Added tables, filters, forms, search, changelog
@jathanism jathanism marked this pull request as draft May 20, 2021 23:14
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

This looks like a great start!

verbose_name = "Dummy plugin"
version = "0.0"
description = "For testing purposes only"
base_url = "dummy-plugin"
min_version = "0.9"
max_version = "9.0"
middleware = ["nautobot.extras.tests.dummy_plugin.middleware.DummyMiddleware"]
middleware = ["dummy_plugin.middleware.DummyMiddleware"]
installed_apps = ["nautobot.extras.tests.dummy_plugin_dependency"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the installed_app going to get moved to examples as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am on the fence about the dummy dependency moving.

examples/dummy_plugin/dummy_plugin/__init__.py Outdated Show resolved Hide resolved
- Add a version string to the plugin
- Added a `to_csv()` method to `DummyModel`
- Updated plugin code quite a bit to use correct bases for API serializers/views to get all tests passing
- Changed base of API `DummyModelViewSet` to use `nautobot.core.api.views.ModelViewSet`
- Changed base of API `DummyModelSerializer` to use `nautobot.core.api.serializers.ValidatedModelSerializer`
- Added `url` field to API `DummyModelSerializer`
- Switched API urls to use `nautobot.core.api.OrderedDefaultRouter` to get bulk update/delete working correctly.
- Updated Invoke tasks to also run black/flake8 on `examples/`
- Added a `poetry.lock` file for `dummy_plugin`
@jathanism jathanism marked this pull request as ready for review May 23, 2021 23:17
@jathanism jathanism changed the title Jathanism generic blessings Test and officially bless generic views for use by plugins May 24, 2021
- Got rid of relative imports just for the sake of clarity and consistency
- Made sure that bulk edit/delete UI operations are properly tested.
- Added a nested API serializer
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Nice work! Would it make sense to add anything in nautobot/docs that points to the dummy plugin? Maybe not since the docs are hosted separately from the repository, but wanted to see what you think.

@jathanism
Copy link
Contributor Author

Nice work! Would it make sense to add anything in nautobot/docs that points to the dummy plugin? Maybe not since the docs are hosted separately from the repository, but wanted to see what you think.

I think it would make sense to include such documentation along side the plugin development docs maybe?

@jathanism jathanism merged commit 84b9dd8 into nautobot:develop May 24, 2021
@jathanism jathanism deleted the jathanism-generic-blessings branch May 24, 2021 18:34
glennmatthews added a commit that referenced this pull request May 25, 2021
glennmatthews added a commit that referenced this pull request May 25, 2021
* Bring changelog up to date

* Update changelog to include #436

* Update changelog for #14, #474, #396
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.

Add support to use generic views and templates when developing plugins
2 participants