Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Always update app status when uploading a new version (bug 895882)
Browse files Browse the repository at this point in the history
  • Loading branch information
diox committed Aug 5, 2013
1 parent c4cf609 commit ab94f7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
29 changes: 18 additions & 11 deletions mkt/developers/tests/test_views_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def test_rejected_packaged(self):
eq_(doc('#rejection blockquote').text(), comments)


@mock.patch('mkt.webapps.tasks.update_cached_manifests.delay', new=mock.Mock)
class TestAddVersion(BasePackagedAppTest):

def setUp(self):
Expand All @@ -150,9 +151,7 @@ def _post(self, expected_status=200):
eq_(res.status_code, expected_status)
return res

@mock.patch('mkt.webapps.models.Webapp.get_manifest_json')
def test_post(self, _mock):
_mock.return_value = {}
def test_post(self):
self.app.current_version.update(version='0.9',
created=self.days_ago(1))
self._post(302)
Expand All @@ -165,27 +164,22 @@ def test_unique_version(self):
self.assertFormError(res, 'upload_form', 'upload',
'Version 1.0 already exists')

@mock.patch('mkt.webapps.models.Webapp.get_manifest_json')
def test_pending_on_new_version(self, _mock):
def test_pending_on_new_version(self):
# Test app rejection, then new version, updates app status to pending.
_mock.return_value = {}
self.app.current_version.update(version='0.9',
created=self.days_ago(1))
self.app.update(status=amo.STATUS_REJECTED)
files = File.objects.filter(version__addon=self.app)
files.update(status=amo.STATUS_DISABLED)
self._post(302)
self.app.reload()
version = self.app.versions.latest()
eq_(version.version, '1.0')
eq_(version.all_files[0].status, amo.STATUS_PENDING)
self.app.update_status()
eq_(self.app.status, amo.STATUS_PENDING)

@mock.patch('mkt.developers.views.run_validator')
@mock.patch('mkt.webapps.models.Webapp.get_manifest_json')
def test_prefilled_features(self, get_manifest_json_,
run_validator_):
get_manifest_json_.return_value = {}
def test_prefilled_features(self, run_validator_):
run_validator_.return_value = '{"feature_profile": ["apps", "audio"]}'

self.app.current_version.update(version='0.9',
Expand Down Expand Up @@ -219,6 +213,19 @@ def test_blocklist_on_new_version(self):
assert EscalationQueue.objects.filter(addon=self.app).exists(), (
'App not in escalation queue')

def test_new_version_when_incomplete(self):
self.app.current_version.update(version='0.9',
created=self.days_ago(1))
self.app.update(status=amo.STATUS_NULL)
files = File.objects.filter(version__addon=self.app)
files.update(status=amo.STATUS_DISABLED)
self._post(302)
self.app.reload()
version = self.app.versions.latest()
eq_(version.version, '1.0')
eq_(version.all_files[0].status, amo.STATUS_PENDING)
eq_(self.app.status, amo.STATUS_PENDING)


class TestEditVersion(amo.tests.TestCase):
"""
Expand Down
3 changes: 3 additions & 0 deletions mkt/developers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def status(request, addon_id, addon, webapp=False):
ver = Version.from_upload(upload_form.cleaned_data['upload'],
addon, [amo.PLATFORM_ALL])

# Update addon status now that the new version was saved.
addon.update_status()

res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)

Expand Down

0 comments on commit ab94f7f

Please sign in to comment.