Example #1
0
def test_api_key_path_order():
    key_path = ['1', '2', '3']
    val = qs.rand_str()
    api_keys.set(key_path, val)
    assert_equals(api_keys.get(key_path), val)
    with assert_raises(KeyError):
        api_keys.get(['2', '1', '3'])
Example #2
0
def test_remove_api_key():
    key = qs.rand_str()
    val = qs.rand_str()
    api_keys.set(key, val)
    assert_in(key, api_keys._get_db())
    api_keys.remove(key)
    assert_not_in(key, api_keys._get_db())
Example #3
0
def test_api_key_with_str_key():
    key = qs.rand_str()
    val = qs.rand_str()
    api_keys.set(key, val)
    assert_equals(api_keys.get(key), val)
Example #4
0
def test_api_key_with_key_path():
    key_path = [qs.rand_str(), qs.rand_str(), qs.rand_str()]
    val = qs.rand_str()
    api_keys.set(key_path, val)
    assert_equals(api_keys.get(key_path), val)
Example #5
0
def test_set_api_key():
    key = qs.rand_str()
    val = qs.rand_str()
    api_keys.set(key, val)
    with open(api_keys._get_path()) as f:
        assert_equals(json.load(f)[key], val)
Example #6
0
def test_setting_with_bad_key():
    with assert_raises(ValueError):
        api_keys.set('', '12345')