예제 #1
0
async def test_saving_loading(data, opp):
    """Test saving and loading JSON."""
    data.add_auth("test-user", "test-pass")
    data.add_auth("second-user", "second-pass")
    await data.async_save()

    data = opp_auth.Data(opp)
    await data.async_load()
    data.validate_login("test-user ", "test-pass")
    data.validate_login("second-user ", "second-pass")
예제 #2
0
async def test_legacy_saving_loading(legacy_data, opp):
    """Test in legacy mode saving and loading JSON."""
    legacy_data.add_auth("test-user", "test-pass")
    legacy_data.add_auth("second-user", "second-pass")
    await legacy_data.async_save()

    legacy_data = opp_auth.Data(opp)
    await legacy_data.async_load()
    legacy_data.is_legacy = True
    legacy_data.validate_login("test-user", "test-pass")
    legacy_data.validate_login("second-user", "second-pass")

    with pytest.raises(opp_auth.InvalidAuth):
        legacy_data.validate_login("test-user ", "test-pass")
예제 #3
0
def legacy_data(opp):
    """Create a loaded legacy data class."""
    data = opp_auth.Data(opp)
    opp.loop.run_until_complete(data.async_load())
    data.is_legacy = True
    return data
예제 #4
0
def data(opp):
    """Create a loaded data class."""
    data = opp_auth.Data(opp)
    opp.loop.run_until_complete(data.async_load())
    return data