def test_bad_fields_value_type():
    with pytest.raises(
        ValueError, match="field value must be a dict, got <class 'str'>"
    ):
        validate_info_response(
            {"fields": {"transaction": {"field": "should be a dict"}}}
        )
示例#2
0
def test_empty_fields_and_types():
    validate_info_response({
        "fields": {},
        "sep12": {
            "sender": {},
            "receiver": {}
        }
    })
示例#3
0
def test_bad_sender_type():
    with pytest.raises(ValueError, match="types key value must be an dict"):
        validate_info_response({
            "fields": {},
            "sep12": {
                "receiver": {},
                "sender": {
                    "types": "not a dict"
                }
            }
        })
示例#4
0
def test_bad_category_value():
    with pytest.raises(ValueError, match="fields key value must be a dict"):
        validate_info_response({
            "fields": {
                "transaction": "not a dict"
            },
            "sep12": {
                "sender": {},
                "receiver": {}
            },
        })
def test_bad_choices_type():
    with pytest.raises(ValueError, match="'choices' must be a list"):
        validate_info_response(
            {
                "fields": {
                    "transaction": {
                        "field": {"description": "description", "choices": "not a list"}
                    }
                },
            }
        )
def test_bad_optional_type():
    with pytest.raises(ValueError, match="'optional' must be a boolean"):
        validate_info_response(
            {
                "fields": {
                    "transaction": {
                        "field": {"description": "description", "optional": "not bool"}
                    }
                }
            }
        )
def test_extra_fields_key():
    with pytest.raises(ValueError, match="unexpected keys in 'fields' dict"):
        validate_info_response(
            {
                "fields": {
                    "transaction": {
                        "field": {"description": "description", "extra": "value"}
                    }
                }
            }
        )
示例#8
0
def test_bad_sender_type_missing_description():
    with pytest.raises(ValueError,
                       match="sep31-sender dict must contain a description"):
        validate_info_response({
            "fields": {},
            "sep12": {
                "receiver": {},
                "sender": {
                    "types": {
                        "sep31-sender": {}
                    }
                }
            },
        })
示例#9
0
def test_bad_sender_type_value():
    with pytest.raises(
            ValueError,
            match="sep31-sender value must be a dict, got <class 'str'>"):
        validate_info_response({
            "fields": {},
            "sep12": {
                "receiver": {},
                "sender": {
                    "types": {
                        "sep31-sender": "test"
                    }
                },
            },
        })
示例#10
0
def test_missing_description_key():
    with pytest.raises(ValueError,
                       match="'fields' dict must contain 'description'"):
        validate_info_response({
            "fields": {
                "transaction": {
                    "field": {
                        "not description": "value"
                    }
                }
            },
            "sep12": {
                "sender": {},
                "receiver": {}
            },
        })
示例#11
0
def test_bad_sender_type_description_type():
    with pytest.raises(
            ValueError,
            match="sep31-sender description must be a human-readable string"):
        validate_info_response({
            "fields": {},
            "sep12": {
                "receiver": {},
                "sender": {
                    "types": {
                        "sep31-sender": {
                            "description": {}
                        }
                    }
                },
            },
        })
示例#12
0
def test_extra_category():
    with pytest.raises(ValueError,
                       match="unrecognized key in info integration response"):
        validate_info_response({"bad category": 1})
示例#13
0
def test_empty_fields():
    # this should pass
    validate_info_response({"fields": {}})
示例#14
0
def test_empty_response():
    with pytest.raises(ValueError,
                       match="missing fields object in info response"):
        validate_info_response({})
示例#15
0
def test_bad_type_response():
    with pytest.raises(ValueError,
                       match="info integration must return a dictionary"):
        validate_info_response(None)
示例#16
0
def test_sender_sep12_type_still_supported():
    validate_info_response({"fields": {}, "sender_sep12_type": "test"})
示例#17
0
def test_missing_sender_key():
    with pytest.raises(
            ValueError,
            match="sender and/or receiver object missing in sep12 object"):
        validate_info_response({"fields": {}, "sep12": {"receiver": {}}})
示例#18
0
def test_missing_sep12_object():
    with pytest.raises(ValueError,
                       match="missing sep12 object in info response"):
        validate_info_response({"fields": {}})
示例#19
0
def test_bad_category_value():
    with pytest.raises(ValueError, match="bad type in info response"):
        validate_info_response({"fields": {"transaction": "not a dict"}})