def test_spec_distributions_latest(self): package_page = mock.Mock(content=self.pkgsync_links) self.requests.get.return_value = package_page repo = Repository('http://pypi.python.org') dists = list(repo.distributions('pkgsync>=0.0.0')) self.assertEqual(len(dists), 3) dists = list(repo.distributions('pkgsync>=0.0.0', latest=True)) self.assertEqual(len(dists), 1) self.assertEqual(dists[0].version, '0.0.1')
def test_no_links_latest_spec(self): response = mock.Mock(status_code=404) self.requests.get.return_value = response repo = Repository('http://pypi.python.org') dists = repo.distributions('example<2.1.4', latest=True) with self.assertRaises(StopIteration): dists.next()
def test_spec_exclude_entire_package(self): package_page = mock.Mock(content=self.pkgsync_links) self.requests.get.return_value = package_page repo = Repository('https://pypi.python.org') dists = list(repo.distributions('pkgsync<0.0.1', exclude=['pkgsync'])) self.assertEqual(len(dists), 0)