def get_namespace(namespace_slug): match = Namespace.get(namespace_slug) if match is None: raise NamespaceNotFoundErrorResponse(namespace_slug) return match
def test_create_namespace(self, app, client): name = "Dog Gone Shame" response = client.post(f"/api/v1/namespaces/{name}/") assert response.status_code == 200 match = Namespace.get(name=name) assert match is not None assert match.slug == 'dog-gone-shame'
def route_delete_namespace(namespace): match = Namespace.get(namespace) if match is None: raise NamespaceNotFoundErrorResponse(namespace) match.delete(commit=True) return success()
def route_create_namespace(namespace): namespace_slug = slugify(namespace) existing = Namespace.get(namespace_slug) if existing is not None: raise NamespaceAlreadyExistsErrorResponse(namespace) namespace = Namespace(name=namespace).save() return namespace_schema.jsonify(namespace)