mirror of https://github.com/doccano/doccano.git
Browse Source
Merge pull request #199 from CatalystCode/enhancement/auto-generate-label-shortkeys
Merge pull request #199 from CatalystCode/enhancement/auto-generate-label-shortkeys
Enhancement/Auto-generate label shortkeys and colors on corpus importpull/202/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 175 additions and 16 deletions
Unified View
Diff Options
-
2app/server/models.py
-
17app/server/serializers.py
-
2app/server/static/js/label.vue
-
1app/server/tests/data/classification.jsonl
-
40app/server/tests/test_api.py
-
22app/server/tests/test_utils.py
-
107app/server/utils.py
@ -1,3 +1,4 @@ |
|||||
{"text": "example", "labels": ["positive"], "meta": {"wikiPageID": 1}} |
{"text": "example", "labels": ["positive"], "meta": {"wikiPageID": 1}} |
||||
{"text": "example", "labels": ["positive", "negative"], "meta": {"wikiPageID": 2}} |
{"text": "example", "labels": ["positive", "negative"], "meta": {"wikiPageID": 2}} |
||||
{"text": "example", "labels": ["negative"], "meta": {"wikiPageID": 3}} |
{"text": "example", "labels": ["negative"], "meta": {"wikiPageID": 3}} |
||||
|
{"text": "example", "labels": ["neutral"], "meta": {"wikiPageID": 4}} |
@ -0,0 +1,22 @@ |
|||||
|
from django.test import TestCase |
||||
|
|
||||
|
from server.utils import Color |
||||
|
|
||||
|
|
||||
|
class TestColor(TestCase): |
||||
|
def test_random_color(self): |
||||
|
color = Color.random() |
||||
|
self.assertTrue(0 <= color.red <= 255) |
||||
|
self.assertTrue(0 <= color.green <= 255) |
||||
|
self.assertTrue(0 <= color.blue <= 255) |
||||
|
|
||||
|
def test_hex(self): |
||||
|
color = Color(red=255, green=192, blue=203) |
||||
|
self.assertEqual(color.hex, '#ffc0cb') |
||||
|
|
||||
|
def test_contrast_color(self): |
||||
|
color = Color(red=255, green=192, blue=203) |
||||
|
self.assertEqual(color.contrast_color.hex, '#000000') |
||||
|
|
||||
|
color = Color(red=199, green=21, blue=133) |
||||
|
self.assertEqual(color.contrast_color.hex, '#ffffff') |
Write
Preview
Loading…
Cancel
Save