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

Side by Side 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import ast 6 import ast
7 import datetime 7 import datetime
8 import json
8 import os 9 import os
9 import unittest 10 import unittest
10 11
11 import app 12 import app
13 from third_party.BeautifulSoup.BeautifulSoup import BeautifulSoup
12 14
13 15
14 TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests') 16 TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests')
15 17
16 18
17 class GaeTestCase(unittest.TestCase): 19 class GaeTestCase(unittest.TestCase):
18 def setUp(self, *args, **kwargs): 20 def setUp(self, *args, **kwargs):
19 self.clear_datastore() 21 self.clear_datastore()
20 super(GaeTestCase, self).setUp(*args, **kwargs) 22 super(GaeTestCase, self).setUp(*args, **kwargs)
21 23
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 page = app.get_and_cache_pagedata('chromium/console') 468 page = app.get_and_cache_pagedata('chromium/console')
467 # Uncomment if deeper inspection is needed of the returned console. 469 # Uncomment if deeper inspection is needed of the returned console.
468 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh: 470 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh:
469 # fh.write(page['content']) 471 # fh.write(page['content'])
470 self.assertEquals('interface', page['body_class']) 472 self.assertEquals('interface', page['body_class'])
471 self.assertEquals(expected_content, page['content']) 473 self.assertEquals(expected_content, page['content'])
472 self.assertEquals( 474 self.assertEquals(
473 'http://build.chromium.org/p/chromium/console/../', 475 'http://build.chromium.org/p/chromium/console/../',
474 page['offsite_base']) 476 page['offsite_base'])
475 self.assertEquals('BuildBot: Chromium', page['title']) 477 self.assertEquals('BuildBot: Chromium', page['title'])
478
479
480 class MailTestCase(GaeTestCase):
481 def test_html_format(self):
482 import gatekeeper_mailer
483 test_dir = os.path.join(TEST_DIR, 'test_mailer')
484 with open(os.path.join(test_dir, 'input.json')) as f:
485 input_json = json.load(f)
486 build_data = json.loads(input_json['message'])
487 template = gatekeeper_mailer.MailTemplate(build_data['waterfall_url'],
488 build_data['build_url'],
489 build_data['project_name'],
490 'test@chromium.org')
491
492 _, html_content, _ = template.genMessageContent(build_data)
493
494 with open(os.path.join(test_dir, 'expected.html')) as f:
495 expected_html = ' '.join(f.read().splitlines())
496
497 self.assertEquals(' '.join(str(BeautifulSoup(html_content)).split()),
498 ' '.join(str(BeautifulSoup(expected_html)).split()))
499
500 def test_hmac_validation(self):
501 pass
502
503 def test_blob(self):
504 from webtest import TestApp
505 import handler
506 localpath = 'test' # The app prepends /p/.
507 content = 'Test.'
508 self.save_page(localpath=localpath, content=content)
509 testapp = TestApp(handler.application)
510 response = testapp.get('/p/test')
511 self.assertEquals('200 OK', response.status)
512 self.assertEquals('Test.', response.body)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698