Coverage for django_napse/core/models/bots/managers/plugin.py: 82%
11 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django.db import models
3from django_napse.utils.constants import PLUGIN_CATEGORIES
4from django_napse.utils.errors import PluginError
7class PluginManager(models.Manager):
8 def create(self, strategy):
9 if self.model.plugin_category() not in PLUGIN_CATEGORIES:
10 error_msg = f"Invalid plugin category: {self.model.plugin_category()}"
11 raise PluginError.InvalidPluginCategory(error_msg)
12 plugin = self.model(strategy=strategy, category=self.model.plugin_category())
13 plugin.save()
14 return plugin