bug fix on server side, add log engine, change lib to core

This commit is contained in:
citronneur
2014-07-20 14:59:53 +02:00
parent f51ef15865
commit 67845e50ad
31 changed files with 187 additions and 171 deletions

53
tests/layer.py Normal file
View File

@@ -0,0 +1,53 @@
'''
@author: sylvain
'''
import unittest
import rdpy.network.layer
class LayerCase(unittest.TestCase):
'''
represent test case for all classes and function
present in rdpy.network.layer
'''
class LayerCaseException(Exception):
'''
exception use for event base test
'''
pass
def test_layer_connect_event(self):
'''
test if connect event is send from transport to presentation
'''
class TestConnect(rdpy.network.layer.Layer):
def connect(self):
raise LayerCase.LayerCaseException()
self.assertRaises(LayerCase.LayerCaseException, rdpy.network.layer.Layer(presentation = TestConnect()).connect)
def test_layer_automata_more_than_expected(self):
'''
test layer automata mechanism if data received is more than expected
'''
class TestAutomata(rdpy.network.layer.RawLayer):
def expectedCallBack(self, data):
if data.dataLen() == 4:
raise LayerCase.LayerCaseException()
t = TestAutomata(rdpy.network.layer.LayerMode.NONE)
t.expect(4, t.expectedCallBack)
self.assertRaises(LayerCase.LayerCaseException, t.dataReceived, "\x00\x00\x00\x00\x00")
def test_layer_automata_less_than_expected(self):
'''
test layer automata mechanism
'''
class TestAutomata(rdpy.network.layer.RawLayer):
def expectedCallBack(self, data):
if data.dataLen() == 4:
raise LayerCase.LayerCaseException()
t = TestAutomata(rdpy.network.layer.LayerMode.NONE)
t.expect(4, t.expectedCallBack)
self.assertEqual(t.dataReceived("\x00\x00\x00"), None, "Not enough dada")