Пример #1
0
 async def test_vlob_update_wrong_seed(self, component, vlob):
     intent = EVlobUpdate(vlob.id, 2, 'dummy-seed', b'Next version.')
     with pytest.raises(TrustSeedError):
         eff = component.perform_vlob_update(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
     intent = EVlobUpdate(vlob.id, 2, vlob.read_trust_seed,
                          b'Next version.')
     with pytest.raises(TrustSeedError):
         eff = component.perform_vlob_update(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
Пример #2
0
 async def test_vlob_update_wrong_version(self, component, vlob):
     intent = EVlobUpdate(vlob.id, 42, vlob.write_trust_seed,
                          b'Next version.')
     with pytest.raises(VlobNotFound):
         eff = component.perform_vlob_update(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
Пример #3
0
 async def test_vlob_update_missing(self, component, vlob):
     intent = EVlobUpdate('dummy-id', 2, vlob.read_trust_seed,
                          b'Next version.')
     with pytest.raises(VlobNotFound):
         eff = component.perform_vlob_update(intent)
         sequence = []
         await asyncio_perform_sequence(sequence, eff)
Пример #4
0
 def test_update_bad_seed(self):
     msg = {
         'id': '123',
         'trust_seed': 'dummy_seed',
         'version': 2,
         'blob': to_jsonb64(b'Next version.')
     }
     eff = execute_cmd('vlob_update', msg)
     sequence = [(EVlobUpdate('123', 2, 'dummy_seed', b'Next version.'),
                  conste(TrustSeedError('Bad trust seed.')))]
     ret = perform_sequence(sequence, eff)
     assert ret['status'] == 'trust_seed_error'
Пример #5
0
 def test_update_bad_version(self):
     msg = {
         'id': '123',
         'trust_seed': 'WTS42',
         'version': 2,
         'blob': to_jsonb64(b'Next version.')
     }
     eff = execute_cmd('vlob_update', msg)
     sequence = [(EVlobUpdate('123', 2, 'WTS42', b'Next version.'),
                  conste(VlobNotFound('Vlob not found.')))]
     ret = perform_sequence(sequence, eff)
     assert ret['status'] == 'vlob_not_found'
Пример #6
0
 def test_vlob_update_not_found(self):
     blob = to_jsonb64(b'Next version.')
     eff = execute_cmd('vlob_update', {
         'id': '1234',
         'trust_seed': 'WTS4242',
         'version': 2,
         'blob': blob
     })
     sequence = [(EVlobUpdate('1234', 2, 'WTS4242', b'Next version.'),
                  conste(VlobNotFound('Vlob not found.')))]
     ret = perform_sequence(sequence, eff)
     assert ret == {'status': 'vlob_not_found', 'label': 'Vlob not found.'}
Пример #7
0
 def test_vlob_update_ok(self):
     blob = to_jsonb64(b'Next version.')
     eff = execute_cmd('vlob_update', {
         'id': '1234',
         'trust_seed': 'WTS4242',
         'version': 2,
         'blob': blob
     })
     sequence = [(EVlobUpdate('1234', 2, 'WTS4242',
                              b'Next version.'), noop)]
     ret = perform_sequence(sequence, eff)
     assert ret == {'status': 'ok'}
Пример #8
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
Пример #9
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.'