def test_exported_json(asset_manager: AssetManager):
    entry_dict = export_advanced_info_as_entry_dict(asset_manager)

    for entries in entry_dict.values():
        for entry in entries:
            is_json_schema_match(AdvancedInfoEntryBase.json_schema,
                                 entry.to_json_entry())
Beispiel #2
0
def test_invalid_schema_is_not_dict():
    schema = [7]
    body = {
        "num": 7,
    }

    with pytest.raises(SchemaIsNotDictError):
        # noinspection PyTypeChecker
        is_json_schema_match(schema, body)
Beispiel #3
0
def test_invalid_schema_array_no_value():
    schema = {
        "num": [],
    }
    body = {
        "num": [7],
    }

    with pytest.raises(ArrayLengthInvalidError):
        is_json_schema_match(schema, body)
Beispiel #4
0
def test_invalid_schema_type_not_allowed():
    schema = {
        "num": object,
    }
    body = {
        "num": 7,
    }

    with pytest.raises(TypeNotAllowedError):
        is_json_schema_match(schema, body)
Beispiel #5
0
def test_invalid_schema_key_not_string():
    schema = {
        7: int,
    }
    body = {
        7: 7,
    }

    with pytest.raises(KeyNotStringError):
        # noinspection PyTypeChecker
        is_json_schema_match(schema, body)
Beispiel #6
0
def test_match_complex_all_types():
    schema = {
        "num": int,
        "text": str,
        "decimal": float,
        "boolean": bool,
        "map": {
            "inner": int,
            "something": str,
            "exponential": float,
            "flag": bool
        },
        "array": [str]
    }
    body = {
        "num": 7,
        "text": "a",
        "decimal": 8.7,
        "boolean": True,
        "map": {
            "inner": 9,
            "something": "b",
            "exponential": 3.33,
            "flag": False
        },
        "array": ["c", "d"]
    }

    assert is_json_schema_match(schema, body)
Beispiel #7
0
def test_invalid_additional_key_in_body():
    schema = {"num": int}
    body = {
        "num": 7,
        "text": "s",
    }

    assert not is_json_schema_match(schema, body)
Beispiel #8
0
def test_match_one_of_listed_type_first():
    schema = {
        "num": [int, str],
    }
    body = {
        "num": 7,
    }

    assert is_json_schema_match(schema, body)
Beispiel #9
0
def test_match_one_of_listed_type_second():
    schema = {
        "num": [int, str],
    }
    body = {
        "num": "7",
    }

    assert is_json_schema_match(schema, body)
def test_exported_simple_info_json(asset_manager: AssetManager):
    entries = export_simple_info_as_entry_dict(asset_manager)

    for entry in entries.values():
        is_json_schema_match(SimpleUnitInfoEntry.json_schema,
                             entry.to_json_entry())
def test_exported_json(asset_manager: AssetManager):
    entries = export_atk_skills_as_entries(asset_manager)

    for entry in entries:
        is_json_schema_match(AttackingSkillEntry.json_schema, entry.to_json_entry())
def test_exported_dragon_json(asset_manager: AssetManager):
    entries = export_dragon_info_as_entries(asset_manager)

    for entry in entries:
        is_json_schema_match(DragonInfoEntry.json_schema,
                             entry.to_json_entry())
Beispiel #13
0
def test_match_simple():
    schema = {"num": int}
    body = {"num": 7}

    assert is_json_schema_match(schema, body)
Beispiel #14
0
def test_not_match_in_list_complex():
    schema = {"num": int, "array": [int], "map": {"inner": int}}
    body = {"num": 7, "array": [7, "a"], "map": {"inner": 9}}

    assert not is_json_schema_match(schema, body)
Beispiel #15
0
def test_not_match_in_dict_complex():
    schema = {"num": int, "array": [int], "map": {"inner": int}}
    body = {"num": "not a num", "array": [7, 8], "map": {"inner": "a"}}

    assert not is_json_schema_match(schema, body)
Beispiel #16
0
def test_one_of_not_match_simple_all_types():
    schema = {"num": int, "text": str, "decimal": float, "boolean": bool}
    body = {"num": 7, "text": 7, "decimal": 8.7, "boolean": True}

    assert not is_json_schema_match(schema, body)
def test_exported_chara_json(asset_manager: AssetManager):
    entries = export_chara_info_as_entries(asset_manager)

    for entry in entries:
        is_json_schema_match(CharaInfoEntry.json_schema, entry.to_json_entry())
Beispiel #18
0
def test_exported_json(asset_manager: AssetManager):
    entry_dict = export_normal_attack_info_as_entry_dict(asset_manager)

    for entries in entry_dict.values():
        for entry in entries:
            is_json_schema_match(NormalAttackChainEntry.json_schema, entry.to_json_entry())
def test_exported_json(asset_manager: AssetManager):
    entries = export_ex_abilities_as_entries(asset_manager)

    for entry in entries:
        is_json_schema_match(CharaExAbiltiesEntry.json_schema,
                             entry.to_json_entry())
Beispiel #20
0
def test_not_match_simple():
    schema = {"num": int}
    body = {"num": "string"}

    assert not is_json_schema_match(schema, body)