async def test_delete(app, client): api = mqtt_api.fget(app) await api._create('topic', block_args(app)) await api._delete('topic', { 'serviceId': block_args(app)['serviceId'], 'id': block_args(app)['id'] }) with pytest.raises(exceptions.UnknownId): await read(app, {'id': block_args(app)['id']})
async def test_unknown_service_id(app, client): api = mqtt_api.fget(app) args = block_args(app) args.serviceId = '' await api._create('topic', args.dict()) await api._write('topic', args.dict()) await api._patch('topic', args.dict()) await api._delete('topic', args.dict()) with pytest.raises(exceptions.UnknownId): await read(app, BlockIdentity(id='testobj'))
async def test_delete(app, client): api = mqtt_api.fget(app) await api._create('topic', block_args(app).dict()) await api._delete( 'topic', BlockIdentity( id='testobj', serviceId=app['config']['name'], ).dict()) with pytest.raises(exceptions.UnknownId): await read(app, BlockIdentity(id='testobj'))
async def test_validate_err(app, client): api = mqtt_api.fget(app) await api._create('topic', {}) with pytest.raises(exceptions.UnknownId): await read(app, {'id': block_args(app)['id']}) await api._create('topic', block_args(app)) updated_args = block_args(app) updated_args['groups'] == [0, 1] await api._write('topic', {}) actual = await read(app, {'id': block_args(app)['id']}) assert actual['groups'] == [0] await api._delete('topic', {}) await read(app, {'id': block_args(app)['id']})
async def test_unknown_service_id(app, client): api = mqtt_api.fget(app) def other_args(): return {**block_args(app), 'serviceId': 'timbuktu'} await api._create('topic', other_args()) with pytest.raises(exceptions.UnknownId): await read(app, {'id': block_args(app)['id']}) await api._create('topic', block_args(app)) updated_args = other_args() updated_args['groups'] == [0, 1] await api._write('topic', other_args()) actual = await read(app, {'id': block_args(app)['id']}) assert actual['groups'] == [0] await api._delete('topic', other_args()) await read(app, {'id': block_args(app)['id']})
async def test_patch(app, client): api = mqtt_api.fget(app) await api._create('topic', block_args(app).dict()) await api._patch('topic', block_args(app).dict()) assert await read(app, BlockIdentity(id='testobj'))
async def test_patch(app, client): api = mqtt_api.fget(app) await api._create('topic', block_args(app)) await api._patch('topic', block_args(app)) assert await read(app, {'id': block_args(app)['id']})