Пример #1
0
def test_reset_all():
    settings_before = settings_list()
    settings_set("example.bool", False)
    settings_set("example.int", 21)
    settings_set("example.string", "pif paf pouf")
    settings_set("example.enum", "c")
    assert settings_before != settings_list()
    settings_reset_all()
    if settings_before != settings_list():
        for i in settings_before:
            assert settings_before[i] == settings_list()[i]
Пример #2
0
def test_unknown_keys():
    unknown_settings_path = SETTINGS_PATH_OTHER_LOCATION % "unknown"
    unknown_setting = {
        "unkown_key": {
            "value": 42,
            "default": 31,
            "type": "int"
        },
    }
    open(SETTINGS_PATH, "w").write(json.dumps(unknown_setting))

    # stimulate a write
    settings_reset_all()

    assert unknown_setting == json.load(open(unknown_settings_path, "r"))
Пример #3
0
def test_reset_all_backup():
    settings_before = settings_list()
    settings_set("example.bool", False)
    settings_set("example.int", 21)
    settings_set("example.string", "pif paf pouf")
    settings_set("example.enum", "c")
    settings_after_modification = settings_list()
    assert settings_before != settings_after_modification
    old_settings_backup_path = settings_reset_all()["old_settings_backup_path"]

    for i in settings_after_modification:
        del settings_after_modification[i]["description"]

    assert settings_after_modification == json.load(
        open(old_settings_backup_path, "r"))