Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1993)

Unified Diff: app_test.py

Issue 19878007: Add build mailer capability to support gatekeeper_ng. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/chromium-build@master
Patch Set: Adds datastore-based auth. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: app_test.py
diff --git a/app_test.py b/app_test.py
index 5aaaf4d5d47bcffdf8fb350265c59b07b86c3f10..664fec6f464ee14cea57d63f039680ac77f55a3b 100644
--- a/app_test.py
+++ b/app_test.py
@@ -5,10 +5,12 @@
import ast
import datetime
+import json
import os
import unittest
import app
+from third_party.BeautifulSoup.BeautifulSoup import BeautifulSoup
TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests')
@@ -473,3 +475,38 @@ class FetchTestCase(GaeTestCase):
'http://build.chromium.org/p/chromium/console/../',
page['offsite_base'])
self.assertEquals('BuildBot: Chromium', page['title'])
+
+
+class MailTestCase(GaeTestCase):
+ def test_html_format(self):
+ import gatekeeper_mailer
+ test_dir = os.path.join(TEST_DIR, 'test_mailer')
+ with open(os.path.join(test_dir, 'input.json')) as f:
+ input_json = json.load(f)
+ build_data = json.loads(input_json['message'])
+ template = gatekeeper_mailer.MailTemplate(build_data['waterfall_url'],
+ build_data['build_url'],
+ build_data['project_name'],
+ 'test@chromium.org')
+
+ _, html_content, _ = template.genMessageContent(build_data)
+
+ with open(os.path.join(test_dir, 'expected.html')) as f:
+ expected_html = ' '.join(f.read().splitlines())
+
+ self.assertEquals(' '.join(str(BeautifulSoup(html_content)).split()),
+ ' '.join(str(BeautifulSoup(expected_html)).split()))
+
+ def test_hmac_validation(self):
+ pass
+
+ def test_blob(self):
+ from webtest import TestApp
+ import handler
+ localpath = 'test' # The app prepends /p/.
+ content = 'Test.'
+ self.save_page(localpath=localpath, content=content)
+ testapp = TestApp(handler.application)
+ response = testapp.get('/p/test')
+ self.assertEquals('200 OK', response.status)
+ self.assertEquals('Test.', response.body)

Powered by Google App Engine
This is Rietveld 408576698