Browse Source

Add a test case for auto labeling config creation

pull/1413/head
Hironsan 3 years ago
parent
commit
7992092c83
2 changed files with 23 additions and 2 deletions
  1. 21
      backend/api/tests/api/test_auto_labeling.py
  2. 4
      backend/api/views/auto_labeling.py

21
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)

4
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,

Loading…
Cancel
Save