def test_build(self): frame = Frame.build('test', data={'a': 'test'}, meta={'another': 'test'}) assert frame.name == 'test' assert frame.data == {'a': 'test'} assert 'another' in frame.meta assert frame.kind == KINDS.UNSET
def test_state(self): state = State() assert state.kind == KINDS.STATE del state state = State('a test', data={'another': 'test'}) assert state.id assert state.name == 'a test' assert state.data == {'another': 'test'} assert isinstance(Frame.build(**state.as_dict()), State)
def test_request(self): request = Request() assert request.kind == KINDS.REQUEST del request request = Request('a test', data={'another': 'test'}) assert request.id assert request.name == 'a test' assert request.data == {'another': 'test'} assert isinstance(Frame.build(**request.as_dict()), Request)
def test_message(self): message = Message() assert message.kind == KINDS.MESSAGE del message message = Message('a test', data={'another': 'test'}) assert message.id assert message.name == 'a test' assert message.data == {'another': 'test', 'text': 'a test'} assert isinstance(Frame.build(**message.as_dict()), Message)
def test_event(self): event = Event() assert event.kind == KINDS.EVENT del event event = Event('a test', data={'another': 'test'}) assert event.id assert event.name == 'a test' assert event.data == {'another': 'test'} assert isinstance(Frame.build(**event.as_dict()), Event)
def test_response(self): response = Response() assert response.kind == KINDS.RESPONSE del response response = Response('a test', data={'another': 'test'}) assert response.reply_to is None response.reply_to = 'okaythen' assert response.id assert response.name == 'a test' assert response.data == {'another': 'test'} assert response.reply_to == 'okaythen' assert isinstance(Frame.build(**response.as_dict()), Response)
def test_frame_empty(): frame = Frame() assert frame.id assert frame.name is None assert frame.data == {} assert frame.source is None assert frame.target is None assert frame.space is None assert frame.reply_to is None frame.name = 'test' frame.data = {'a': 'b'} frame.target = 'test-target' frame.space = 'test-space' frame.reply_to = 'test-reply-to' assert frame.name == 'test' assert frame.data == {'a': 'b'} assert frame.target == 'test-target' assert frame.space == 'test-space' assert frame.reply_to == 'test-reply-to'
def test_unset(self): frame = Frame() assert frame.kind == KINDS.UNSET
def test_given_id(self): frame1 = Frame(id='stuff') assert frame1.id == 'stuff'
def test_kind_validation(self): with self.assertRaises(ValueError): _ = Frame(kind=99) with self.assertRaises(ValueError): _ = Frame(kind=-2) # -1 is TIMER
def test_kind(self): frame1 = Frame(kind=KINDS.EVENT) assert frame1.kind == KINDS.EVENT