def test_regex_version_filter(self): _skip_on_pypy() with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) main([ client.server_url, TEST_USER, 'delete_me', '--version-filter', r'\.post\d+', '--batch', '--password', TEST_PASSWORD ]) indices = client.list_indices(user=TEST_USER) for index in indices: client.use(index) self.assertListEqual([], _filter_redirect_entry( client.list('delete_me==0.2.post1'))) self.assertNotEqual( 0, len( _filter_redirect_entry( client.list('delete_me==0.2.dev2')))) self.assertNotEqual( 0, len(_filter_redirect_entry(client.list('delete_me==0.1')))) self.assertNotEqual( 0, len(_filter_redirect_entry( client.list('delete_me==0.2a1')))) self.assertNotEqual( 0, len(_filter_redirect_entry(client.list('delete_me==0.2'))))
def test_force_removal_on_non_volatile(self): _skip_on_pypy() with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) indices = client.list_indices(user=TEST_USER) client.modify_index('user/index1', 'volatile=False') main([ client.server_url, TEST_USER, 'delete_me', '--force', '--batch', '--password', TEST_PASSWORD ]) for index in indices: client.use(index) self.assertListEqual([], _filter_redirect_entry( client.list('delete_me==0.1'))) self.assertListEqual([], _filter_redirect_entry( client.list('delete_me==0.2.dev2'))) self.assertListEqual([], _filter_redirect_entry( client.list('delete_me==0.2a1'))) self.assertListEqual([], _filter_redirect_entry( client.list('delete_me==0.2'))) self.assertIn('volatile=False', client.modify_index('user/index1')) self.assertIn('volatile=True', client.modify_index('user/index2'))
def test_other_users_indices(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) main([client.server_url, TEST_USER, 'delete_me==0.2', '--batch', '--login', 'root', '--password', '']) indices = client.list_indices(user=TEST_USER) for index in indices: client.use(index) self.assertListEqual([], _filter_redirect_entry(client.list('delete_me==0.2')))
def test_abort_unless_yes(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) # noinspection PyCallingNonCallable with mock.patch('sys.stdin', six.StringIO('\n')): # press enter on verification prompt main([client.server_url, TEST_USER, 'delete_me==0.2', '--password', TEST_PASSWORD]) indices = client.list_indices(user=TEST_USER) for index in indices: client.use(index) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2'))))
def test_removes_on_specified_index(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) main([client.server_url, TEST_INDEX_TWO, 'delete_me==0.2', '--password', TEST_PASSWORD, '--batch']) client.use(TEST_INDEX_ONE) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2')))) client.use(TEST_INDEX_TWO) self.assertListEqual([], [ package for package in _filter_redirect_entry(client.list('delete_me==0.2')) if 'index2' in package ])
def test_remove_only_dev_packages(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) main([client.server_url, TEST_USER, 'delete_me<=0.2', '--dev-only', '--batch', '--password', TEST_PASSWORD]) indices = client.list_indices(user=TEST_USER) for index in indices: client.use(index) self.assertListEqual([], _filter_redirect_entry(client.list('delete_me==0.2.dev2'))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.1')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2a1')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2.post1'))))
def test_removes_specified_packages(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) with mock.patch('getpass.getpass') as getpass: getpass.return_value = TEST_PASSWORD # noinspection PyCallingNonCallable with mock.patch('sys.stdin', six.StringIO('yes\n')): main([client.server_url, TEST_USER, 'delete_me==0.2']) indices = client.list_indices(user=TEST_USER) for index in indices: client.use(index) self.assertListEqual([], _filter_redirect_entry(client.list('delete_me==0.2'))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2.dev2'))))
def test_fails_on_non_volatile_by_default(self): with TestServer(users=TEST_USERS, indices=TEST_INDICES) as client: _bootstrap_test_user(client) indices = client.list_indices(user=TEST_USER) for index in indices: client.modify_index(index, 'volatile=False') with mock.patch('sys.stderr', new_callable=six.StringIO) as error_output: with self.assertRaises(SystemExit) as exit_code_catcher: main([client.server_url, TEST_USER, 'delete_me', '--batch', '--password', TEST_PASSWORD]) self.assertEquals(1, exit_code_catcher.exception.code) self.assertIn('not volatile', error_output.getvalue()) for index in indices: client.use(index) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.1')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2.dev2')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2a1')))) self.assertNotEqual(0, len(_filter_redirect_entry(client.list('delete_me==0.2'))))