def test_skip_package(db_queue, web_queue, skip_queue, task, import_queue, build_state_hacked): bsh = build_state_hacked import_queue.send_msg('REMOVE', [bsh.package, None, 'silly package']) db_queue.expect('PKGEXISTS', bsh.package) db_queue.send('OK', True) db_queue.expect('SKIPPKG', [bsh.package, 'silly package']) db_queue.send('OK', None) web_queue.expect('DELPKG', bsh.package) web_queue.send('DONE') skip_queue.expect('DELPKG', bsh.package) skip_queue.send('OK') db_queue.expect('PROJVERS', bsh.package) db_queue.send('OK', [ ProjectVersionsRow(bsh.version, False, datetime(1970, 1, 1, tzinfo=UTC), '', 'cp34m', ''), ProjectVersionsRow(bsh.version + 'a', False, datetime(1970, 1, 1, tzinfo=UTC), 'cp35m', '', ''), ]) db_queue.expect('DELBUILD', [bsh.package, bsh.version]) db_queue.send('OK', None) task.poll(0) assert import_queue.recv_msg() == ('DONE', None) assert len(task.states) == 0 db_queue.check() web_queue.check() skip_queue.check()
def test_write_pkg_project_with_deps(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) task.once() scribe_queue.send_msg('PROJECT', 'foo') db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.1', 'linux_armv6l', 'cp34m', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef', False, '>=3', ['libfoo']), ProjectFilesRow('0.1', 'linux_armv7l', 'cp34m', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef', False, '>=3', ['libfoo']), ]) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', False, datetime(1970, 1, 1, tzinfo=UTC), '', 'cp34m', ''), ]) db_queue.expect('GETABIS', True) db_queue.send('OK', {'cp34m', 'cp35m'}) db_queue.expect('GETDESC', 'foo') db_queue.send('OK', 'Some description') db_queue.expect('GETPROJNAME', 'foo') db_queue.send('OK', 'foo') db_queue.expect('GETPKGNAMES', 'foo') db_queue.send('OK', []) task.poll(0) db_queue.check() root = Path(master_config.output_path) index = root / 'simple' / 'foo' / 'index.html' assert not index.exists() project = root / 'project' / 'foo' project_page = project / 'index.html' project_json = project / 'json' project_json_file = project_json / 'index.json' assert project_page.exists() and project_page.is_file() assert contains_elem(project_page, 'h2', content='foo') assert contains_elem(project_page, 'p', content='Some description') assert contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef')], 'foo-0.1-cp34-cp34m-linux_armv7l.whl' ) assert contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv6l.whl#sha256=123456abcdef')], 'foo-0.1-cp34-cp34m-linux_armv6l.whl' ) assert contains_elem(project_page, 'pre', content='sudo apt install libfoo\nsudo pip3 install foo') assert project_json_file.exists() and project_json_file.is_file() with open(str(project_json_file.absolute())) as f: data = json.load(f) assert data['package'] == 'foo' assert len(data['releases']) == 1 assert len(data['releases']['0.1']['files']) == 2 assert scribe_queue.recv_msg() == ('DONE', None)
def test_write_pkg_index_with_yanked_files_and_requires_python(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) task.once() scribe_queue.send_msg('BOTH', 'foo') db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.1', 'linux_armv6l', 'cp34m', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef', True, '>=3', ['libfoo']), ProjectFilesRow('0.1', 'linux_armv7l', 'cp34m', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef', True, '>=3', ['libfoo']), ]) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', True, datetime(1970, 1, 1, tzinfo=UTC), '', 'cp34m', ''), ]) db_queue.expect('GETABIS', True) db_queue.send('OK', {'cp34m', 'cp35m'}) db_queue.expect('GETDESC', 'foo') db_queue.send('OK', 'Some description') db_queue.expect('GETPROJNAME', 'foo') db_queue.send('OK', 'foo') db_queue.expect('GETPKGNAMES', 'foo') db_queue.send('OK', []) task.poll(0) db_queue.check() root = Path(master_config.output_path) simple = root / 'simple' / 'index.html' simple_index = root / 'simple' / 'foo' / 'index.html' assert simple.exists() and simple.is_file() assert contains_elem(simple, 'a', [('href', 'foo')]) assert simple_index.exists() and simple_index.is_file() assert contains_elem( simple_index, 'a', [ ('href', 'foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef'), ('data-yanked', ''), ('data-requires-python', '>=3'), ] ) assert contains_elem( simple_index, 'a', [ ('href', 'foo-0.1-cp34-cp34m-linux_armv6l.whl#sha256=123456abcdef'), ('data-yanked', ''), ('data-requires-python', '>=3'), ] ) project = root / 'project' / 'foo' / 'index.html' assert project.exists() and project.is_file() project_json = root / 'project' / 'foo' / 'json' / 'index.json' assert project_json.exists() and project_json.is_file() assert scribe_queue.recv_msg() == ('DONE', None)
def test_delete_version_missing_file(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) task.once() scribe_queue.send_msg('DELVER', ['foo', '0.1']) db_queue.expect('VERFILES', ['foo', '0.1']) db_queue.send('OK', { 'foo-0.1-cp34-cp34m-linux_armv6l.whl': '123456abcdef', 'foo-0.1-cp34-cp34m-linux_armv7l.whl': '123456abcdef', }) db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.2', 'linux_armv6l', 'cp34m', 'cp34m', 'foo-0.2-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef', False, '>=3', ['libfoo']), ProjectFilesRow('0.2', 'linux_armv7l', 'cp34m', 'cp34m', 'foo-0.2-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef', False, '>=3', ['libfoo']), ]) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.2', False, datetime(1970, 1, 1, tzinfo=UTC), '', 'cp34m', ''), ]) db_queue.expect('GETABIS', True) db_queue.send('OK', {'cp34m', 'cp35m'}) db_queue.expect('GETDESC', 'foo') db_queue.send('OK', 'Some description') db_queue.expect('GETPROJNAME', 'foo') db_queue.send('OK', 'foo') db_queue.expect('GETPKGNAMES', 'foo') db_queue.send('OK', []) root = Path(master_config.output_path) index = root / 'simple' / 'foo' index.mkdir(parents=True) wheel_1 = index / 'foo-0.1-cp34-cp34m-linux_armv6l.whl' wheel_2 = index / 'foo-0.1-cp34-cp34m-linux_armv7l.whl' wheel_1.touch() assert wheel_1.exists() assert not wheel_2.exists() project = root / 'project' / 'foo' project.mkdir(parents=True) task.poll(0) db_queue.check() assert index.exists() assert project.exists() assert not wheel_1.exists() assert not wheel_2.exists() assert scribe_queue.recv_msg() == ('DONE', None)
def test_write_new_pkg_index(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) scribe_queue.send_msg('PKGBOTH', 'bar') db_queue.expect('PROJFILES', 'bar') db_queue.send('OK', [ ProjectFilesRow('1.0', 'cp34m', 'bar-1.0-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef'), ProjectFilesRow('1.0', 'cp34m', 'bar-1.0-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef'), ]) db_queue.expect('PROJVERS', 'bar') db_queue.send('OK', [ ProjectVersionsRow('1.0', False, 2, 1), ]) db_queue.expect('PROJFILES', 'bar') db_queue.send('OK', [ ProjectFilesRow('1.0', 'cp34m', 'bar-1.0-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef'), ProjectFilesRow('1.0', 'cp34m', 'bar-1.0-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef'), ]) db_queue.expect('FILEDEPS', 'bar-1.0-cp34-cp34m-linux_armv7l.whl') db_queue.send('OK', {'apt': {'libc6'}}) db_queue.expect('GETPROJDESC', 'bar') db_queue.send('OK', 'Some description') task.once() task.poll() db_queue.check() root = Path(master_config.output_path) root_index = root / 'simple' / 'index.html' pkg_index = root / 'simple' / 'bar' / 'index.html' assert root_index.exists() and root_index.is_file() assert contains_elem(root_index, 'a', [('href', 'bar')]) assert pkg_index.exists() and pkg_index.is_file() assert contains_elem( pkg_index, 'a', [('href', 'bar-1.0-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef')]) assert contains_elem( pkg_index, 'a', [('href', 'bar-1.0-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef')]) project = root / 'project' / 'bar' / 'index.html' assert project.exists() and project.is_file()
def test_write_pkg_project_with_deps(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) scribe_queue.send_msg('PKGPROJ', 'foo') db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', False, 0, 1), ]) db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('1.0', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef'), ProjectFilesRow('1.0', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef'), ]) db_queue.expect('FILEDEPS', 'foo-0.1-cp34-cp34m-linux_armv7l.whl') db_queue.send('OK', {'libfoo'}) db_queue.expect('GETPROJDESC', 'foo') db_queue.send('OK', 'Some description') task.once() task.poll() db_queue.check() root = Path(master_config.output_path) index = root / 'simple' / 'foo' / 'index.html' assert not index.exists() project = root / 'project' / 'foo' / 'index.html' assert project.exists() and project.is_file() assert contains_elem(project, 'h2', content='foo') assert contains_elem(project, 'p', content='Some description') assert contains_elem(project, 'a', [ ('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef') ], 'foo-0.1-cp34-cp34m-linux_armv7l.whl') assert contains_elem(project, 'a', [ ('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv6l.whl#sha256=123456abcdef') ], 'foo-0.1-cp34-cp34m-linux_armv6l.whl') assert contains_elem( project, 'pre', content='sudo apt install libfoo\nsudo pip3 install foo')
def test_write_pkg_project_no_files(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) scribe_queue.send_msg('PKGPROJ', 'foo') db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', False, 0, 1), ]) db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', []) task.once() task.poll() db_queue.check() root = Path(master_config.output_path) index = root / 'simple' / 'foo' / 'index.html' assert not index.exists() project = root / 'project' / 'foo' / 'index.html' assert project.exists() and project.is_file() assert contains_elem(project, 'h2', content='foo') assert contains_elem(project, 'th', content='No files')
def test_write_pkg_project_no_files(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) task.once() scribe_queue.send_msg('PROJECT', 'foo') db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', []) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', False, datetime(1970, 1, 1, tzinfo=UTC), '', '', 'cp34m'), ]) db_queue.expect('GETABIS', True) db_queue.send('OK', {'cp34m', 'cp35m'}) db_queue.expect('GETDESC', 'foo') db_queue.send('OK', 'Some description') db_queue.expect('GETPROJNAME', 'foo') db_queue.send('OK', 'foo') db_queue.expect('GETPKGNAMES', 'foo') db_queue.send('OK', []) task.poll(0) db_queue.check() root = Path(master_config.output_path) index = root / 'simple' / 'foo' / 'index.html' assert not index.exists() project = root / 'project' / 'foo' project_page = project / 'index.html' project_json = project / 'json' project_json_file = project_json / 'index.json' assert project_page.exists() and project_page.is_file() assert contains_elem(project_page, 'h2', content='foo') assert contains_elem(project_page, 'p', content='Some description') assert project_json_file.exists() and project_json_file.is_file() with open(str(project_json_file.absolute())) as f: data = json.load(f) assert data['package'] == 'foo' assert len(data['releases']) == 1 assert len(data['releases']['0.1']['files']) == 0 assert scribe_queue.recv_msg() == ('DONE', None)
def test_write_pkg_index(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) scribe_queue.send_msg('PKGBOTH', 'foo') db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.1', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv6l.whl', 123456, '123456123456'), ProjectFilesRow('0.1', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv7l.whl', 123456, '123456123456'), ]) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.1', False, 2, 0), ]) db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.1', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv6l.whl', 123456, '123456123456'), ProjectFilesRow('0.1', 'cp34m', 'foo-0.1-cp34-cp34m-linux_armv7l.whl', 123456, '123456123456'), ]) db_queue.expect('FILEDEPS', 'foo-0.1-cp34-cp34m-linux_armv7l.whl') db_queue.send('OK', {'apt': {'libc6'}}) task.once() task.poll() db_queue.check() root = Path(master_config.output_path) index = root / 'simple' / 'foo' / 'index.html' assert index.exists() and index.is_file() assert contains_elem( index, 'a', [('href', 'foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456123456')]) assert contains_elem( index, 'a', [('href', 'foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456123456')]) project = root / 'project' / 'foo' / 'index.html' assert project.exists() and project.is_file()
def test_delete_version(db_queue, task, scribe_queue, master_config): db_queue.expect('ALLPKGS') db_queue.send('OK', {'foo'}) task.once() scribe_queue.send_msg('DELVER', ['foo', '0.1']) db_queue.expect('VERFILES', ['foo', '0.1']) db_queue.send('OK', { 'foo-0.1-cp34-cp34m-linux_armv6l.whl': '123456abcdef', 'foo-0.1-cp34-cp34m-linux_armv7l.whl': '123456abcdef', }) db_queue.expect('PROJFILES', 'foo') db_queue.send('OK', [ ProjectFilesRow('0.2', 'linux_armv6l', 'cp34m', 'cp34m', 'foo-0.2-cp34-cp34m-linux_armv6l.whl', 123456, '123456abcdef', False, '>=3', []), ProjectFilesRow('0.2', 'linux_armv7l', 'cp34m', 'cp34m', 'foo-0.2-cp34-cp34m-linux_armv7l.whl', 123456, '123456abcdef', False, '>=3', []), ]) db_queue.expect('PROJVERS', 'foo') db_queue.send('OK', [ ProjectVersionsRow('0.2', False, datetime(1970, 1, 1, tzinfo=UTC), '', 'cp34m', ''), ]) db_queue.expect('GETABIS', True) db_queue.send('OK', {'cp34m', 'cp35m'}) db_queue.expect('GETDESC', 'foo') db_queue.send('OK', 'Some description') db_queue.expect('GETPROJNAME', 'foo') db_queue.send('OK', 'foo') db_queue.expect('GETPKGNAMES', 'foo') db_queue.send('OK', []) root = Path(master_config.output_path) simple = root / 'simple' / 'foo' simple.mkdir(parents=True) wheel_1 = simple / 'foo-0.1-cp34-cp34m-linux_armv6l.whl' wheel_2 = simple / 'foo-0.1-cp34-cp34m-linux_armv7l.whl' wheel_3 = simple / 'foo-0.2-cp34-cp34m-linux_armv6l.whl' wheel_4 = simple / 'foo-0.2-cp34-cp34m-linux_armv7l.whl' wheel_1.touch() wheel_2.touch() wheel_3.touch() wheel_4.touch() project = root / 'project' / 'foo' project.mkdir(parents=True) project_page = project / 'index.html' task.poll(0) db_queue.check() assert simple.exists() assert project.exists() assert project_page.exists() assert not wheel_1.exists() assert not wheel_2.exists() assert wheel_3.exists() assert wheel_4.exists() assert contains_elem(project_page, 'pre', content='sudo pip3 install foo') assert not contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv6l.whl#sha256=123456abcdef')], 'foo-0.1-cp34-cp34m-linux_armv6l.whl' ) assert not contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.1-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef')], 'foo-0.1-cp34-cp34m-linux_armv7l.whl' ) assert contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.2-cp34-cp34m-linux_armv6l.whl#sha256=123456abcdef')], 'foo-0.2-cp34-cp34m-linux_armv6l.whl' ) assert contains_elem( project_page, 'a', [('href', '/simple/foo/foo-0.2-cp34-cp34m-linux_armv7l.whl#sha256=123456abcdef')], 'foo-0.2-cp34-cp34m-linux_armv7l.whl' ) assert scribe_queue.recv_msg() == ('DONE', None)