示例#1
0
def test_repr_format():
    test_response_obj = scaf_dataclass(
        type("_ResponseModel", (BaseResponseModel, ),
             dict.fromkeys(response_methods_list, "test")))(config)
    assert str(test_response_obj) == "_ResponseModel(custom_checkers=test\ndelete_data" \
                                     "=test\nerror_data=test\n" \
                                     "get_data=test\nheaders=test\npatch_data=test\npost_data=test\nput_data=test\n" \
                                     "raw_response=None\nstatus_code=test)"
示例#2
0
def test_all_fields_impl():
    try:
        test_response_class = scaf_dataclass(
            type("_ResponseModel", (BaseResponseModel, ),
                 dict.fromkeys(response_methods_list, None)))
        test_response_class(config)
    except Exception as e:
        pytest.fail(f"DID RAISE {e}")
示例#3
0
def test_extra_args_no_exception():
    test_response_class = scaf_dataclass(
        type("_ResponseModel", (BaseResponseModel, ),
             dict.fromkeys(response_methods_list, None)))
    try:
        test_response_class.test_field = None
        test_response_class(config)
    except Exception as e:
        pytest.fail(f"DID RAISE {e}")
示例#4
0
def test_no_method_impl(field_name):
    with pytest.raises(TypeError) as excinfo:
        list_without_field_name = [
            x for x in response_methods_list if x != field_name
        ]
        test_response_class = scaf_dataclass(
            type("_ResponseModel", (BaseResponseModel, ),
                 dict.fromkeys(list_without_field_name, None)))
        test_response_class()
    assert f"Can't instantiate abstract class _ResponseModel with abstract methods {field_name}" in str(
        excinfo.value)