コード例 #1
0
 async def test_vlob_read_wrong_seed(self, component, vlob):
     intent = EVlobRead(vlob.id, 'dummy-seed')
     with pytest.raises(TrustSeedError):
         eff = component.perform_vlob_read(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
     intent = EVlobRead(vlob.id, vlob.write_trust_seed)
     with pytest.raises(TrustSeedError):
         eff = component.perform_vlob_read(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
コード例 #2
0
 def test_read_bad_version(self):
     msg = {'id': '123', 'trust_seed': 'TS42', 'version': 2}
     eff = execute_cmd('vlob_read', msg)
     sequence = [(EVlobRead('123', 'TS42',
                            2), conste(VlobNotFound('Vlob not found.')))]
     ret = perform_sequence(sequence, eff)
     assert ret['status'] == 'vlob_not_found'
コード例 #3
0
 async def test_vlob_read_previous_version(self, component, vlob):
     # Update vlob
     intent = EVlobUpdate(vlob.id, 2, vlob.write_trust_seed,
                          b'Next version.')
     eff = component.perform_vlob_update(intent)
     sequence = [(EEvent('vlob_updated', vlob.id), noop)]
     await asyncio_perform_sequence(sequence, eff)
     # Read previous version
     intent = EVlobRead(vlob.id, vlob.read_trust_seed, version=1)
     eff = component.perform_vlob_read(intent)
     sequence = []
     ret = await asyncio_perform_sequence(sequence, eff)
     assert ret == vlob
コード例 #4
0
 def test_vlob_read_ok(self):
     eff = execute_cmd('vlob_read', {'id': '1234', 'trust_seed': 'TS4242'})
     sequence = [
         (EVlobRead('1234', 'TS4242'),
          const(VlobAtom('1234', 'TS4242', 'WTS4242', b'content v42', 42)))
     ]
     ret = perform_sequence(sequence, eff)
     assert ret == {
         'status': 'ok',
         'id': '1234',
         'blob': to_jsonb64(b'content v42'),
         'version': 42
     }
コード例 #5
0
 async def test_vlob_update_ok(self, component, vlob):
     intent = EVlobUpdate(vlob.id, 2, vlob.write_trust_seed,
                          b'Next version.')
     eff = component.perform_vlob_update(intent)
     sequence = [(EEvent('vlob_updated', vlob.id), noop)]
     await asyncio_perform_sequence(sequence, eff)
     # Check back the value
     intent = EVlobRead(vlob.id, vlob.read_trust_seed, version=2)
     eff = component.perform_vlob_read(intent)
     ret = await asyncio_perform_sequence([], eff)
     assert ret.id == vlob.id
     assert ret.version == 2
     assert ret.blob == b'Next version.'
コード例 #6
0
 async def test_vlob_read_missing(self, component, vlob):
     intent = EVlobRead('dummy-id', vlob.read_trust_seed)
     with pytest.raises(VlobNotFound):
         eff = component.perform_vlob_read(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
コード例 #7
0
 async def test_vlob_read_ok(self, component, vlob):
     intent = EVlobRead(vlob.id, vlob.read_trust_seed)
     eff = component.perform_vlob_read(intent)
     sequence = []
     ret = await asyncio_perform_sequence(sequence, eff)
     assert ret == vlob
コード例 #8
0
 def test_vlob_read_not_found(self):
     eff = execute_cmd('vlob_read', {'id': '1234', 'trust_seed': 'TS4242'})
     sequence = [(EVlobRead('1234', 'TS4242'),
                  conste(VlobNotFound('Vlob not found.')))]
     ret = perform_sequence(sequence, eff)
     assert ret == {'status': 'vlob_not_found', 'label': 'Vlob not found.'}
コード例 #9
0
 async def test_vlob_read_wrong_version(self, component, vlob):
     intent = EVlobRead(vlob.id, vlob.read_trust_seed, version=42)
     with pytest.raises(VlobNotFound):
         eff = component.perform_vlob_read(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)