def test_data_caching(self): cache.clear() key = pypi.cache_key('django') package = pypi.Package('django') self.assertIsNone(cache.get(key)) self.assertEqual(package.data(), self.test_data) self.assertEqual(cache.get(key), self.package.data())
def available_updates(self, obj: "PackageVersion") -> str: """Print out all versions ahead of the current one.""" from package_monitor import pypi package = pypi.Package(obj.package_name) versions = package.all_versions() return html_list([v for v in versions if v > obj.current_version])
def update_from_pypi(self): """Call get_latest_version and then save the object.""" package = pypi.Package(self.package_name) self.licence = package.licence() if self.is_parseable: self.latest_version = package.latest_version() self.next_version = package.next_version(self.current_version) self.diff_status = pypi.version_diff(self.current_version, self.latest_version) self.checked_pypi_at = tz_now() self.save() return self
def setUp(self): # with mock.patch('requests.get', mock_get): self.package = pypi.Package('django') self.test_data = mock_get('foo').json()