def build_state_hacked(request, file_state, file_state_hacked): return BuildState( 1, file_state.package_tag, file_state.package_version_tag, file_state.abi_tag, True, 300, 'Built successfully', { file_state.filename: file_state, file_state_hacked.filename: file_state_hacked, })
def test_slave_says_built_succeeded(task, db_queue, fs_queue, slave_queue, builds_queue, index_queue, master_config, file_state, file_state_hacked): task.logger = mock.Mock() slave_queue.send_pyobj( ['HELLO', 300, 'cp34', 'cp34m', 'linux_armv7l', 'piwheels1']) task.poll() assert slave_queue.recv_pyobj() == ['HELLO', 1, master_config.pypi_simple] builds_queue.send_pyobj(['cp34m', 'foo', '0.1']) task.poll() slave_queue.send_pyobj(['IDLE']) task.poll() assert slave_queue.recv_pyobj() == ['BUILD', 'foo', '0.1'] slave_queue.send_pyobj( ['BUILT', True, 5, 'Woohoo!', { file_state.filename: file_state[1:8] }]) db_queue.expect([ 'LOGBUILD', BuildState( 1, 'foo', '0.1', 'cp34m', True, 5, 'Woohoo!', { file_state.filename: file_state, file_state_hacked.filename: file_state_hacked }) ]) db_queue.send(['OK', 1]) fs_queue.expect(['EXPECT', 1, file_state]) fs_queue.send(['OK', None]) task.poll() assert task.logger.info.call_count == 3 assert slave_queue.recv_pyobj() == ['SEND', file_state.filename] db_queue.check() fs_queue.check()
def test_build_state_from_db(master_config, with_build, with_files, build_state_hacked): db = Database(master_config.dsn) build_state_hacked.logged(with_build.build_id) for file_state in build_state_hacked.files.values(): file_state.verified() assert BuildState.from_db(db, with_build.build_id) == build_state_hacked
def test_slave_says_built_failed(task, db_queue, slave_queue, builds_queue, index_queue, master_config): task.logger = mock.Mock() slave_queue.send_pyobj(['HELLO', 300, 'cp34', 'cp34m', 'linux_armv7l', 'piwheels1']) task.poll() assert slave_queue.recv_pyobj() == ['HELLO', 1, master_config.pypi_simple] builds_queue.send_pyobj(['cp34m', 'foo', '0.1']) task.poll() slave_queue.send_pyobj(['IDLE']) task.poll() assert slave_queue.recv_pyobj() == ['BUILD', 'foo', '0.1'] slave_queue.send_pyobj(['BUILT', False, 5, '', {}]) db_queue.expect(['LOGBUILD', BuildState(1, 'foo', '0.1', 'cp34m', False, 5, '', {})]) db_queue.send(['OK', 1]) task.poll() assert task.logger.info.call_count == 2 assert index_queue.recv_pyobj() == ['PKG', 'foo'] assert slave_queue.recv_pyobj() == ['DONE'] db_queue.check()
def test_build_state_from_db_unknown_build(master_config, with_build): db = Database(master_config.dsn) assert with_build.build_id != 1000 with pytest.raises(ValueError): BuildState.from_db(db, 1000)