Пример #1
0
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": {}
            },
        })
Пример #5
0
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"}
                    }
                },
            }
        )
Пример #6
0
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"}
                    }
                }
            }
        )
Пример #7
0
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"}})