def test_check(): client_name = 'piterprivet' client = checkalias.get_client_from_billing(client_name) result = checkalias.check(client_name) assert result == client_name assert checkalias.alias_cache[client_name] == client client_name2 = 'super-demo' result = checkalias.check(client_name) result2 = checkalias.check(client_name2) assert result == client_name assert result2 == 'online-demo' assert len(checkalias.alias_cache.keys()) == 2
def application(env, start_response): query = parse_qs(env['QUERY_STRING']) alias = checkalias.check(query['client'][0], query['action'][0]) if alias is not None: alias = alias.encode('utf-8') start_response('200 OK', [('Content-Type', 'text/html')]) return [alias]
def test_wrong_alias(): result = checkalias.check('wrong_alias', 'get_alias') assert result == 'error'
def test_no_alias(): result = checkalias.check(None, 'get_alias') assert result == 'error'
def test_invalidate_wrong_alias(): result = checkalias.check('wrong_alias', 'invalidate') assert result == 'error'
def test_invalidate_alias(): result = checkalias.check('piterprivet', 'invalidate') assert result is None
def test_invalidate_no_alias(): result = checkalias.check(None, 'invalidate') assert result == 'error'
def test_alias(): actual_alias = checkalias.check('piterprivet', 'get_alias') assert actual_alias == 'piterprivet'