Пример #1
0
    def test_frame_meta_properties(self):
        frame1 = Frame()
        assert frame1.space is None
        assert frame1.source is None
        assert frame1.target is None
        assert frame1.timestamp is not None
        frame1.space = 'sandbox'
        assert frame1.space == 'sandbox'

        frame2 = Frame.build('test',
                             data={
                                 'yet': 'another',
                                 'test': 'eh'
                             },
                             meta={
                                 'space': 'zentropia',
                                 'source': 'stranger',
                                 'target': 'me',
                                 'timestamp': 'Just a string, really'
                             })
        assert frame2.space == 'zentropia'
        assert frame2.source == 'stranger'
        assert frame2.target == 'me'
        assert frame2.timestamp == 'Just a string, really'
        frame2.space = 'home'
        assert frame2.space == 'home'
        frame2.target = 'unknown'
        assert frame2.target == 'unknown'

        frame3 = Frame()
        frame3.target = 'test'
        assert frame3.target == 'test'
Пример #2
0
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'