| Total Complexity | 1 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |