forked from joeli/challenge
41 lines
902 B
Python
41 lines
902 B
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Acceptance Test
|
|
~~~~~~~~~~~~~~~
|
|
|
|
:Ablauf:
|
|
- Adapter wird erzeugt
|
|
- Daten werden angefordert
|
|
|
|
:Erwartetes Ergebnis:
|
|
- Daten sind korrekt
|
|
"""
|
|
from nose.twistedtools import reactor, deferred
|
|
from nose.tools import assert_equals
|
|
from twisted.internet.defer import Deferred
|
|
from .data import TEST_DATA_DIR
|
|
from .. import Adapter
|
|
|
|
def test_acceptance():
|
|
""" Acceptance test (synchron) """
|
|
|
|
adapter = Adapter(TEST_DATA_DIR)
|
|
data = adapter.retrieve_token("accept")
|
|
assert_equals(data, '{"token": 42}')
|
|
|
|
|
|
@deferred(timeout=2.0)
|
|
def test_acceptance_async():
|
|
""" Acceptance test (asynchron) """
|
|
|
|
adapter = Adapter(TEST_DATA_DIR)
|
|
finish = Deferred()
|
|
defer = adapter.retrieve_token_async("accept")
|
|
|
|
def check(data):
|
|
assert_equals(data, '{"token": 42}')
|
|
finish.callback(None)
|
|
defer.addCallback(check)
|
|
|
|
return finish
|