TestSchema.test_schema()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 27
rs 9.376
c 0
b 0
f 0
cc 1
nop 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