xenanetworks / open-automation-core

🚀 XOA framework for test execution, tester management, and data subscription.
https://docs.xenanetworks.com/projects/xoa-core
Apache License 2.0
2 stars 0 forks source link

get_test_suite_info not working #24

Closed fpfeng closed 1 year ago

fpfeng commented 1 year ago

Error popup with main branch code

Traceback (most recent call last):
  File "/home/chf/xena/open-automation-test-suites/2889_main.py", line 32, in test_playground
    info = c.get_test_suite_info("RFC-2889")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chf/xena/open-automation-core/xoa_core/controller.py", line 80, in get_test_suite_info
    return self.suites_library.suite_info(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chf/xena/open-automation-core/xoa_core/core/test_suites/controller.py", line 42, in suite_info
    schema=suite.model_class.schema_json(),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pydantic/main.py", line 675, in pydantic.main.BaseModel.schema_json
  File "pydantic/main.py", line 664, in pydantic.main.BaseModel.schema
  File "pydantic/schema.py", line 186, in pydantic.schema.model_schema
  File "pydantic/schema.py", line 580, in pydantic.schema.model_process_schema
  File "pydantic/schema.py", line 621, in pydantic.schema.model_type_schema
  File "pydantic/schema.py", line 254, in pydantic.schema.field_schema
  File "pydantic/schema.py", line 526, in pydantic.schema.field_type_schema
  File "pydantic/schema.py", line 921, in pydantic.schema.field_singleton_schema
  File "<frozen abc>", line 123, in __subclasscheck__
TypeError: issubclass() arg 1 must be a class
fpfeng commented 1 year ago

https://github.com/pydantic/pydantic/issues/1298 I have tried update_forward_refs with my main config model, no luck still got same error.

fpfeng commented 1 year ago

xoa_core/core/test_suites/datasets.py#L89

def build_test_params(_test_config: Type["BaseModel"]) -> Type["TestParameters"]:
    class TP(TestParameters):
        config: _test_config
    TP.update_forward_refs(_test_config=_test_config) # add this line
    return TP

It's working now

ArtemConstantinov commented 1 year ago

OK, Added.