Example #1
0
 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')
Example #2
0
 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')
Example #3
0
 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')
Example #4
0
 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')
Example #5
0
 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')
Example #6
0
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))
Example #7
0
 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')
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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]
Example #11
0
 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]
Example #12
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
Example #13
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
Example #14
0
 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
Example #15
0
 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
Example #16
0
 def test_pkginfo_from_no_ext(self):
     """
     .pkginfo_from_file with no extension
     """
     from cheeseprism.index import IndexManager
     IndexManager.pkginfo_from_file('adfasdkfha')
Example #17
0
 def test_pkginfo_from_bad_ext(self):
     """
     .pkginfo_from_file with unrecognized extension
     """
     from cheeseprism.index import IndexManager
     IndexManager.pkginfo_from_file('adfasdkfha.adkfhalsdk')
Example #18
0
 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'
Example #19
0
 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
Example #20
0
 def test_pkginfo_from_no_ext(self):
     from cheeseprism.index import IndexManager
     IndexManager.pkginfo_from_file('adfasdkfha')        
Example #21
0
 def test_pkginfo_from_file_egg(self):
     from cheeseprism.index import IndexManager
     assert IndexManager.pkginfo_from_file('blah.egg') is True
Example #22
0
 def index(request):
     return IndexManager.from_registry(request.registry)
Example #23
0
 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'
Example #24
0
 def test_pkginfo_from_no_ext(self):
     """
     .pkginfo_from_file with no extension
     """
     from cheeseprism.index import IndexManager
     IndexManager.pkginfo_from_file('adfasdkfha')        
Example #25
0
 def test_pkginfo_from_bad_ext(self):
     """
     .pkginfo_from_file with unrecognized extension
     """
     from cheeseprism.index import IndexManager
     IndexManager.pkginfo_from_file('adfasdkfha.adkfhalsdk')
Example #26
0
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)