Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'sdk_mass_switch'
Browse files Browse the repository at this point in the history
  • Loading branch information
zalun committed Jun 20, 2011
2 parents cc1afc5 + ff1b5c4 commit b2051ac
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
38 changes: 38 additions & 0 deletions apps/jetpack/fixtures/old_packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"pk": 401,
"model": "jetpack.package",
"fields": {
"name": "",
"author": 4,
"id_number": "1000401",
"lib_dir": null,
"jid": "abc",
"version": 401,
"full_name": "",
"version_name": null,
"type": "a",
"public_permission": 1,
"description": "",
"latest": 401
}
},
{
"pk": 401,
"model": "jetpack.packagerevision",
"fields": {
"origin": null,
"contributors": "",
"name": "",
"full_name": "",
"author": 4,
"package": 401,
"module_main": "main",
"revision_number": 1,
"dependencies": [],
"version_name": null,
"message": "",
"sdk": null
}
}
]
7 changes: 5 additions & 2 deletions apps/jetpack/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def update_full_name(self):
if not self.package.full_name:
# fixing package
log.debug('Full name not set for Package %d' % self.package.pk)
self.package.set_full_name()
self.package.save()
self.full_name = self.package.full_name

Expand Down Expand Up @@ -1347,7 +1346,11 @@ def update_full_name(self):
if not self.full_name:
log.warning('Full name was empty %d' % self.pk)
self.set_full_name()
super(Package, self).save()

def update_name(self):
if not self.full_name:
self.set_full_name()
self.name = make_name(self.full_name)


def __unicode__(self):
Expand Down
12 changes: 11 additions & 1 deletion apps/jetpack/tests/revision_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class PackageRevisionTest(TestCase):
fixtures = ['mozilla_user', 'users', 'core_sdk', 'packages']
fixtures = ['mozilla_user', 'users', 'core_sdk', 'packages', 'old_packages']

def setUp(self):
self.author = User.objects.get(username='john')
Expand Down Expand Up @@ -363,6 +363,16 @@ def test_force_sdk(self):
eq_(len(addon.revisions.all()), 1)
eq_(addon.latest.commit_message.count('SDK'), 2)

def test_fix_old_packages(self):
old_rev = PackageRevision.objects.get(pk=401)
assert not old_rev.full_name
old_rev.force_sdk(self.addon.latest.sdk)
old_package = Package.objects.get(pk=401)
assert old_rev.full_name
assert old_rev.name
assert old_package.full_name
assert old_package.name

"""
Althought not supported on view and front-end,
there is no harm in these two
Expand Down

0 comments on commit b2051ac

Please sign in to comment.