def test_linkify_validation_messages(self, v): v.return_value = json.dumps({ "errors": 0, "success": True, "warnings": 1, "notices": 0, "message_tree": {}, "messages": [{ "context": ["<code>", None], "description": [ "Something something, see https://bugzilla.mozilla.org/"], "column": 0, "line": 1, "file": "chrome/content/down.html", "tier": 2, "message": "Some warning", "type": "warning", "id": [], "uid": "bb9948b604b111e09dfdc42c0301fe38" }], "metadata": {} }) r = self.client.post(reverse('devhub.json_file_validation', args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) doc = pq(data['validation']['messages'][0]['description'][0]) eq_(doc('a').text(), 'https://bugzilla.mozilla.org/')
def test_lazy_validate(self): r = self.client.post(reverse("devhub.json_file_validation", args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) msg = data["validation"]["messages"][0] eq_(msg["message"], "The value of <em:id> is invalid.")
def test_lazy_validate(self): r = self.client.post(self.json_url, follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) msg = data['validation']['messages'][0] eq_(msg['message'], 'The value of <em:id> is invalid.')
def test_detail_for_free_extension_webapp(self, validator_mock, requests_mock): content = self.file_content('mozball.owa') response_mock = mock.Mock(status_code=200) response_mock.iter_content.return_value = mock.Mock( next=lambda: content) response_mock.headers = {'content-type': self.content_type} yield response_mock requests_mock.return_value = response_mock validator_mock.return_value = json.dumps(self.validation_ok()) self.upload_file('mozball.owa') upload = FileUpload.objects.get() tasks.fetch_manifest('http://xx.com/manifest.owa', upload.pk) r = self.client.get(reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) data = json.loads(r.content) eq_(data['validation']['messages'], []) # no errors assert_no_validation_errors(data) # no exception eq_(r.status_code, 200) eq_(data['url'], reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) eq_(data['full_report_url'], reverse('mkt.developers.upload_detail', args=[upload.uuid]))
def test_fileupload_validation(self): self.post() fu = FileUpload.objects.get(name="mozball.zip") assert_no_validation_errors(fu) assert fu.validation validation = json.loads(fu.validation) eq_(validation["success"], False) # The current interface depends on this JSON structure: eq_(validation["errors"], 0) eq_(validation["warnings"], 2) assert len(validation["messages"]) msg = validation["messages"][0] assert "uid" in msg, "Unexpected: %r" % msg eq_(msg["type"], u"warning") eq_(msg["message"], u"60x60px icon should be provided for Firefox OS.") eq_( msg["description"], [ "An icon of size 60x60 should be provided for the app. Firefox OS " "will look for this icon size before any other.", "http://www.mozilla.org/styleguide/products/firefoxos/icons/", "Node: root > icons", ], )
def test_lazy_validate(self): r = self.client.post(self.json_url, follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) msg = data['validation']['messages'][0] eq_(msg['message'], 'JSON Parse Error')
def test_lazy_validate(self): r = self.client.post(reverse('mkt.developers.json_file_validation', args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) msg = data['validation']['messages'][0] eq_(msg['message'], 'The value of <em:id> is invalid.')
def test_fileupload_validation(self): self.post() fu = FileUpload.objects.get(name='mozball.zip') assert_no_validation_errors(fu) assert fu.validation validation = json.loads(fu.validation) eq_(validation['success'], False) eq_(validation['errors'], 0)
def test_lazy_validate(self): r = self.client.post(reverse('devhub.json_file_validation', args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) msg = data['validation']['messages'][0] eq_(msg['message'], 'The value of <em:id> is invalid.')
def test_detail_json(self): self.post() upload = FileUpload.objects.get() r = self.client.get(reverse("mkt.developers.upload_detail", args=[upload.uuid, "json"])) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) eq_(data["url"], reverse("mkt.developers.upload_detail", args=[upload.uuid, "json"])) eq_(data["full_report_url"], reverse("mkt.developers.upload_detail", args=[upload.uuid])) # We must have tiers assert len(data["validation"]["messages"]) msg = data["validation"]["messages"][0] eq_(msg["tier"], 1)
def test_detail_for_free_extension_webapp(self, validator_mock, urlopen_mock): rs = mock.Mock() rs.read.return_value = self.file_content("mozball.owa") rs.getcode.return_value = 200 rs.headers = {"Content-Type": "application/x-web-app-manifest+json"} urlopen_mock.return_value = rs validator_mock.return_value = json.dumps(self.validation_ok()) self.upload_file("mozball.owa") upload = FileUpload.objects.get() tasks.fetch_manifest("http://xx.com/manifest.owa", upload.pk) r = self.client.get(reverse("mkt.developers.upload_detail", args=[upload.uuid, "json"])) data = json.loads(r.content) eq_(data["validation"]["messages"], []) # no errors assert_no_validation_errors(data) # no exception eq_(r.status_code, 200) eq_(data["url"], reverse("mkt.developers.upload_detail", args=[upload.uuid, "json"])) eq_(data["full_report_url"], reverse("mkt.developers.upload_detail", args=[upload.uuid]))
def test_fileupload_validation(self): self.post() fu = FileUpload.objects.get(name='animated.png') assert_no_validation_errors(fu) assert fu.validation validation = json.loads(fu.validation) eq_(validation['success'], False) # The current interface depends on this JSON structure: eq_(validation['errors'], 1) eq_(validation['warnings'], 0) assert len(validation['messages']) msg = validation['messages'][0] assert 'uid' in msg, "Unexpected: %r" % msg eq_(msg['type'], u'error') eq_(msg['message'], u'JSON Parse Error') eq_(msg['description'], u'The webapp extension could not be parsed' u' due to a syntax error in the JSON.')
def test_detail_json(self): self.post() upload = FileUpload.objects.get() r = self.client.get(reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) eq_(data['url'], reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) eq_(data['full_report_url'], reverse('mkt.developers.upload_detail', args=[upload.uuid])) # We must have tiers assert len(data['validation']['messages']) msg = data['validation']['messages'][0] eq_(msg['tier'], 1)
def test_detail_for_free_extension_webapp(self, validator_mock, urlopen_mock): rs = mock.Mock() rs.read.return_value = self.file_content('mozball.owa') rs.headers = {'Content-Type': 'application/x-web-app-manifest+json'} urlopen_mock.return_value = rs validator_mock.return_value = json.dumps(self.validation_ok()) self.upload_file('mozball.owa') upload = FileUpload.objects.get() tasks.fetch_manifest('http://xx.com/manifest.owa', upload.pk) r = self.client.get(reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) data = json.loads(r.content) eq_(data['validation']['messages'], []) # no errors assert_no_validation_errors(data) # no exception eq_(r.status_code, 200) eq_(data['url'], reverse('mkt.developers.upload_detail', args=[upload.uuid, 'json'])) eq_(data['full_report_url'], reverse('mkt.developers.upload_detail', args=[upload.uuid]))
def test_validate(self): self.start_validation() res = ValidationResult.objects.get() assert close_to_now(res.completed) assert_no_validation_errors(res) eq_(res.errors, 1) # package could not be found eq_(res.valid, False) eq_(res.warnings, 0) eq_(res.notices, 0) v = json.loads(res.validation) eq_(v['errors'], 1) assert close_to_now(res.validation_job.completed) eq_(res.validation_job.stats['total'], 1) eq_(res.validation_job.stats['completed'], 1) eq_(res.validation_job.stats['passing'], 0) eq_(res.validation_job.stats['failing'], 1) eq_(res.validation_job.stats['errors'], 0) eq_(len(mail.outbox), 1) eq_(mail.outbox[0].subject, 'Behold! Validation results for Firefox %s->%s' % (self.curr_max.version, self.new_max.version)) eq_(mail.outbox[0].to, ['*****@*****.**'])
def test_validate(self): self.start_validation() res = ValidationResult.objects.get() assert close_to_now(res.completed) assert_no_validation_errors(res) eq_(res.errors, 1) # package could not be found eq_(res.valid, False) eq_(res.warnings, 0) eq_(res.notices, 0) v = json.loads(res.validation) eq_(v['errors'], 1) assert close_to_now(res.validation_job.completed) eq_(res.validation_job.stats['total'], 1) eq_(res.validation_job.stats['completed'], 1) eq_(res.validation_job.stats['passing'], 0) eq_(res.validation_job.stats['failing'], 1) eq_(res.validation_job.stats['errors'], 0) eq_(len(mail.outbox), 1) eq_( mail.outbox[0].subject, 'Behold! Validation results for Firefox %s->%s' % (self.curr_max.version, self.new_max.version)) eq_(mail.outbox[0].to, ['*****@*****.**'])
def test_validator_sets_binary_flag_for_content(self, v): v.return_value = json.dumps({ "errors": 0, "success": True, "warnings": 0, "notices": 0, "message_tree": {}, "messages": [], "metadata": { "contains_binary_content": True, "version": "1.0", "name": "gK0Bes Bot", "id": "gkobes@gkobes" } }) eq_(self.addon.binary, False) r = self.client.post(reverse('devhub.json_file_validation', args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) addon = Addon.objects.get(pk=self.addon.id) eq_(addon.binary, True)
def test_validator_sets_binary_flag(self, v): v.return_value = json.dumps({ "errors": 0, "success": True, "warnings": 0, "notices": 0, "message_tree": {}, "messages": [], "metadata": { "contains_binary_extension": True, "version": "1.0", "name": "gK0Bes Bot", "id": "gkobes@gkobes" } }) eq_(self.addon.binary, False) r = self.client.post(reverse('devhub.json_file_validation', args=[self.addon.slug, self.file.id]), follow=True) eq_(r.status_code, 200) data = json.loads(r.content) assert_no_validation_errors(data) addon = Addon.objects.get(pk=self.addon.id) eq_(addon.binary, True)