tests.unit.tools_tests.test_schema   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 25
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestSchema.test_schema() 0 27 1
1
import unittest
2
3
from tabpy.tabpy_tools.schema import generate_schema
4
5
6
class TestSchema(unittest.TestCase):
7
    def test_schema(self):
8
        schema = generate_schema(
9
            input={"x": ["happy", "sad", "neutral"]},
10
            input_description={"x": "text to analyze"},
11
            output=[0.98, -0.99, 0],
12
            output_description="scores for input texts",
13
        )
14
        expected = {
15
            "input": {
16
                "type": "object",
17
                "properties": {
18
                    "x": {
19
                        "type": "array",
20
                        "items": {"type": "string"},
21
                        "description": "text to analyze",
22
                    }
23
                },
24
                "required": ["x"],
25
            },
26
            "sample": {"x": ["happy", "sad", "neutral"]},
27
            "output": {
28
                "type": "array",
29
                "items": {"type": "number"},
30
                "description": "scores for input texts",
31
            },
32
        }
33
        self.assertEqual(schema, expected)
34