コード例 #1
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_link_add_conflict(_link):
    assert Link.add('id', 'feature', 'idf', 'topic')
    assert Link.select() == {('id', 'feature', 'idf'): 'topic'}

    with pytest.raises(ValueError) as err:
        Link.add('id', 'feature', 'idf', 'topic')

    assert 'exists' in str(err)
コード例 #2
0
ファイル: graph.py プロジェクト: IoTtalk/iottalk-core
    def add_link(self, payload):
        '''
        This add link command will send a ``CONNECT`` control message
        to device application.

        We will check the device feature lock as first.
        Then, record the link to ``Link`` for future lookup.
        '''
        da_id = UUID(payload['da_id'])
        mode = self.get_mode(payload.keys())
        feature = payload[mode]

        if Link.select(payload['da_id'], feature, mode):
            return self.send_error(payload, reason='Link already exists')
        elif payload.get('func') and not UserFunction.select(payload['func']):
            return self.send_error(
                payload, reason='Function unknown. Please add it first.')
        return self._add_link(da_id, mode, feature, payload)
コード例 #3
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_link_pop_key(_link):
    assert Link.add('id', 'feature', 'idf', 'topic')
    assert Link.select('id', 'feature', 'idf') == 'topic'
    assert Link.pop('id', 'feature', 'idf') == 'topic'
    assert Link.select('id', 'feature', 'idf') is None
コード例 #4
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def test_link_add(_link):
    assert Link.add('id', 'feature', 'idf', 'topic')
    assert Link.select() == {('id', 'feature', 'idf'): 'topic'}
コード例 #5
0
ファイル: test_storage.py プロジェクト: IoTtalk/iottalk-core
def _link():
    assert Link.clear()
    assert Link.select() == {}
    yield
    assert Link.clear()
    assert Link.select() == {}