Exemple #1
0
 def test_validation_error(self, _mock):
     _mock.side_effect = Exception
     eq_(self.upload.task_error, None)
     tasks.validator(self.upload.pk)
     error = self.get_upload().task_error
     assert error is not None
     assert error.startswith('Traceback (most recent call last)'), error
Exemple #2
0
 def test_validation_error(self, _mock):
     _mock.side_effect = Exception
     eq_(self.upload.task_error, None)
     tasks.validator(self.upload.pk)
     error = self.get_upload().task_error
     assert error is not None
     assert error.startswith('Traceback (most recent call last)'), error
Exemple #3
0
 def test_validate_packaged_app(self, _zipfile, _mock):
     _zipfile.return_value = True
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #4
0
 def test_validate_manifest(self, _open, _mock):
     _open.return_value = tempfile.TemporaryFile()
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #5
0
 def test_fail_validation(self, _mock):
     _mock.return_value = '{"errors": 2}'
     tasks.validator(self.upload.pk)
     assert not self.get_upload().valid
Exemple #6
0
        return

    # Check hash.
    if check_hash:
        hash_ = _get_content_hash(content)
        if file_.hash == hash_:
            _log(webapp, u'Manifest the same')
            return
        _log(webapp, u'Manifest different')

    # Validate the new manifest.
    upload = FileUpload.objects.create()
    upload.add_file([content], webapp.manifest_url, len(content),
                    is_webapp=True)

    validator(upload.pk)

    upload = FileUpload.objects.get(pk=upload.pk)
    if upload.validation:
        v8n = json.loads(upload.validation)
        if v8n['errors']:
            v8n_url = absolutify(reverse(
                'mkt.developers.upload_detail', args=[upload.uuid]))
            msg = u'Validation errors:\n'
            for m in v8n['messages']:
                if m['type'] == u'error':
                    msg += u'* %s\n' % m['message']
            msg += u'\nValidation Result:\n%s' % v8n_url
            _log(webapp, msg, rereview=True)
            if webapp.status in amo.WEBAPPS_APPROVED_STATUSES:
                notify_developers_of_failure(webapp, msg, has_link=True)
Exemple #7
0
 def test_validate_packaged_app(self, _zipfile, _mock):
     self.get_upload().update(is_webapp=True)
     _zipfile.return_value = True
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #8
0
 def test_validate_manifest(self, _open, _mock):
     self.get_upload().update(is_webapp=True)
     _open.return_value = StringIO('')
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #9
0
 def test_fail_validation(self, _mock):
     _mock.return_value = '{"errors": 2}'
     tasks.validator(self.upload.pk)
     assert not self.get_upload().valid
Exemple #10
0
 def test_validate_manifest(self, _open, _mock):
     _open.return_value = StringIO('')
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #11
0
 def test_validate_manifest(self, _open, _mock):
     self.get_upload().update(is_webapp=True)
     _open.return_value = StringIO('')
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #12
0
 def test_validate_manifest(self, _open, _mock):
     _open.return_value = tempfile.TemporaryFile()
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     assert _mock.called
Exemple #13
0
 def test_validate_any_package(self, _mock):
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     # Let validator determine by file extension.
     eq_(_mock.call_args[1]['expectation'], validator.constants.PACKAGE_ANY)
Exemple #14
0
 def test_validate_manifest(self, _mock):
     self.get_upload().update(is_webapp=True)
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     eq_(_mock.call_args[1]['expectation'],
         validator.constants.PACKAGE_WEBAPP)
Exemple #15
0
 def test_validate_any_package(self, _mock):
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     # Let validator determine by file extension.
     eq_(_mock.call_args[1]['expectation'], validator.constants.PACKAGE_ANY)
Exemple #16
0
 def test_validate_manifest(self, _mock):
     self.get_upload().update(is_webapp=True)
     _mock.return_value = '{"errors": 0}'
     tasks.validator(self.upload.pk)
     eq_(_mock.call_args[1]['expectation'],
         validator.constants.PACKAGE_WEBAPP)