def test_pkginfo_from_no_ext(self): """ .pkginfo_from_file with no extension """ from cheeseprism.index import IndexManager with self.assertRaises(RuntimeError): IndexManager.pkginfo_from_file('adfasdkfha')
def test_pkginfo_from_bad_ext(self): """ .pkginfo_from_file with unrecognized extension """ from cheeseprism.index import IndexManager with self.assertRaises(RuntimeError): IndexManager.pkginfo_from_file('adfasdkfha.adkfhalsdk')
def test_pkginfo_from_file_exc(self): """ .pkginfo_from_file with exception and no handler """ from cheeseprism.index import IndexManager exc = ValueError("BOOM") with patch('pkginfo.bdist.BDist', side_effect=exc): IndexManager.pkginfo_from_file('bad.egg')
def test_group_by_magnitude(): from cheeseprism.index import IndexManager fiver = list(range(5)) assert IndexManager.group_by_magnitude(fiver)[0] == fiver assert next(IndexManager.group_by_magnitude(list(range(101)))) == list( range(10)) assert next(IndexManager.group_by_magnitude(list(range(1001)))) == list( range(100))
def test_pkginfo_from_bad_ext_handled(self): """ .pkginfo_from_file with unrecognized extension """ from cheeseprism.index import IndexManager handler = Mock(name='handler') IndexManager.pkginfo_from_file('adfasdkfha.adkfhalsdk', handle_error=handler) assert handler.call_args[0][1] == 'adfasdkfha.adkfhalsdk' assert isinstance(handler.call_args[0][0], RuntimeError)
def test_pkginfo_from_file_exc_and_handler(self): """ .pkginfo_from_file with exception and handler """ from cheeseprism.index import IndexManager exc = Exception("BOOM") with patch('pkginfo.bdist.BDist', side_effect=exc): eh = Mock(name='error_handler') IndexManager.pkginfo_from_file('bad.egg', handle_error=eh) assert eh.called assert eh.call_args[0] == (exc, 'bad.egg'), eh.call_args[0]
def test_pkginfo_from_file_whl(self): """ .pkginfo_from_file: wheel """ from cheeseprism.index import IndexManager with patch('pkginfo.wheel.Wheel', new=Mock(return_value=True)): assert IndexManager.pkginfo_from_file('blah.whl') is True
def test_pkginfo_from_file_sdist(self): """ .pkginfo_from_file: sdist """ from cheeseprism.index import IndexManager for ext in ('.gz','.tgz', '.bz2', '.zip'): assert IndexManager.pkginfo_from_file('blah.%s' %ext) is True
def test_pkginfo_from_file_sdist(self): """ .pkginfo_from_file: sdist """ from cheeseprism.index import IndexManager for ext in ('.gz', '.tgz', '.bz2', '.zip'): assert IndexManager.pkginfo_from_file('blah.%s' % ext) is True
def test_pkginfo_from_no_ext(self): """ .pkginfo_from_file with no extension """ from cheeseprism.index import IndexManager IndexManager.pkginfo_from_file('adfasdkfha')
def test_pkginfo_from_bad_ext(self): """ .pkginfo_from_file with unrecognized extension """ from cheeseprism.index import IndexManager IndexManager.pkginfo_from_file('adfasdkfha.adkfhalsdk')
def test_move_on_error(self): from cheeseprism.index import IndexManager exc, path = Mock(), Mock() IndexManager.move_on_error('errors', exc, path) assert path.rename.called assert path.rename.call_args[0][0] == 'errors'
def test_pkginfo_from_file_egg(self): """ .pkginfo_from_file: bdist """ from cheeseprism.index import IndexManager assert IndexManager.pkginfo_from_file('blah.egg') is True
def test_pkginfo_from_no_ext(self): from cheeseprism.index import IndexManager IndexManager.pkginfo_from_file('adfasdkfha')
def test_pkginfo_from_file_egg(self): from cheeseprism.index import IndexManager assert IndexManager.pkginfo_from_file('blah.egg') is True
def index(request): return IndexManager.from_registry(request.registry)
def test_group_by_magnitude(): from cheeseprism.index import IndexManager fiver = range(5) assert IndexManager.group_by_magnitude(fiver)[0] == fiver assert next(IndexManager.group_by_magnitude(range(101))) == range(10) assert next(IndexManager.group_by_magnitude(range(1001))) == range(100)