From 7992092c83abd6100c30cfd4e2c70653626c1c6d Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 11 Jun 2021 12:01:58 +0900 Subject: [PATCH] Add a test case for auto labeling config creation --- backend/api/tests/api/test_auto_labeling.py | 21 +++++++++++++++++++++ backend/api/views/auto_labeling.py | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/api/tests/api/test_auto_labeling.py b/backend/api/tests/api/test_auto_labeling.py index 41b6c485..e8920f4f 100644 --- a/backend/api/tests/api/test_auto_labeling.py +++ b/backend/api/tests/api/test_auto_labeling.py @@ -87,3 +87,24 @@ class TestLabelMapping(CRUDMixin): response = self.assert_create(self.project.users[0], status.HTTP_200_OK) expected = [{'label': 'Negative'}] self.assertEqual(response.json(), expected) + + +class TestConfigCreation(CRUDMixin): + + def setUp(self): + self.project = prepare_project(task=DOCUMENT_CLASSIFICATION) + self.data = { + 'model_name': 'Amazon Comprehend Sentiment Analysis', + 'model_attrs': { + 'aws_access_key': 'str', + 'aws_secret_access_key': 'str', + 'region_name': 'us-east-1', + 'language_code': 'en' + }, + 'template': AmazonComprehendSentimentTemplate().load(), + 'label_mapping': {'NEGATIVE': 'Negative'} + } + self.url = reverse(viewname='auto_labeling_configs', args=[self.project.item.id]) + + def test_create_config(self): + self.assert_create(self.project.users[0], status.HTTP_201_CREATED) diff --git a/backend/api/views/auto_labeling.py b/backend/api/views/auto_labeling.py index 3d1c6b6a..fd7c832a 100644 --- a/backend/api/views/auto_labeling.py +++ b/backend/api/views/auto_labeling.py @@ -17,8 +17,8 @@ from rest_framework.response import Response from rest_framework.views import APIView from ..exceptions import (AutoLabeliingPermissionDenied, AutoLabelingException, - AWSTokenError, SampleDataException, TemplateMappingError, - URLConnectionError) + AWSTokenError, SampleDataException, + TemplateMappingError, URLConnectionError) from ..models import AutoLabelingConfig, Example, Project from ..permissions import IsInProjectOrAdmin, IsProjectAdmin from ..serializers import (AutoLabelingConfigSerializer,