forked from joeli/challenge
3
test/data/accept.xml
Normal file
3
test/data/accept.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<DataReceived xmlns="http://www.boschsecurity.com/2011/09/OpenInterface" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Token>42</Token>
|
||||
</DataReceived>
|
||||
@@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Acceptance Test
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
:Ablauf:
|
||||
- Adapter wird erzeugt
|
||||
- Daten werden angefordert
|
||||
|
||||
:Erwartetes Ergebnis:
|
||||
- Daten sind korrekt
|
||||
"""
|
||||
from nose.tools import assert_equals
|
||||
from .. import Adapter
|
||||
|
||||
def test_acceptance():
|
||||
""" Acceptance Test """
|
||||
|
||||
adapter = Adapter
|
||||
40
test/test_accept.py
Normal file
40
test/test_accept.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- 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
|
||||
Reference in New Issue
Block a user