Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Assert that sync_versions does not break if no release urls are defined

  • Loading branch information...
commit 450301edcf16faf74e28de0d2791b41f419e448d 1 parent 0726b33
@EnTeQuAk EnTeQuAk authored
Showing with 20 additions and 8 deletions.
  1. +8 −8 folivora/models.py
  2. +12 −0 folivora/tests.py
View
16 folivora/models.py
@@ -50,14 +50,14 @@ def sync_versions(self):
urls = client.get_release_urls(self.name, version)
if urls:
url = urls[0]
- utime = time.mktime(url['upload_time'].timetuple())
- release_date = make_aware(
- datetime.datetime.fromtimestamp(utime),
- pytz.UTC)
- PackageVersion.objects.get_or_create(
- package=self,
- version=version,
- release_date=release_date)
+ utime = time.mktime(url['upload_time'].timetuple())
+ release_date = make_aware(
+ datetime.datetime.fromtimestamp(utime),
+ pytz.UTC)
+ PackageVersion.objects.get_or_create(
+ package=self,
+ version=version,
+ release_date=release_date)
self.initial_sync_done = True
self.save()
View
12 folivora/tests.py
@@ -33,6 +33,8 @@ def get_changelog(self, hours, force=False):
['new_package', '0.1', 1345259834, 'new release']]
def get_release_urls(self, name, version):
+ if name == 'gunicorn':
+ return []
return [{'comment_text': '',
'downloads': 0,
'filename': 'pmxbot-1101.8.1.zip',
@@ -86,6 +88,16 @@ def test_version_sync(self):
self.assertEqual(version.version, '1101.8.1')
self.assertNumQueries(0, pkg.sync_versions)
+ @mock.patch('folivora.models.CheeseShop', CheesyMock)
+ def test_version_sync_without_versions(self):
+ #Bug group/337798
+ pkg = Package.objects.create(name='gunicorn',
+ url='http://pypi.python.org/pypi/gunicorn',
+ provider='pypi')
+ self.assertEqual(pkg.versions.count(), 0)
+ pkg.sync_versions()
+ self.assertEqual(pkg.versions.count(), 0)
+
class TestPackageVersionModel(TestCase):

0 comments on commit 450301e

Please sign in to comment.
Something went wrong with that request. Please try again.