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

Side by Side Diff: app_test.py

Issue 143263025: Add support to change the status header for gatekeeper-ng. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Rename to use status_header instead of status. Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gatekeeper_mailer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 hashlib 8 import hashlib
9 import hmac 9 import hmac
10 import json 10 import json
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 _, html_content, _ = template.genMessageContent(self.build_data) 521 _, html_content, _ = template.genMessageContent(self.build_data)
522 522
523 with open(os.path.join(self.test_dir, 'expected.html')) as f: 523 with open(os.path.join(self.test_dir, 'expected.html')) as f:
524 expected_html = ' '.join(f.read().splitlines()) 524 expected_html = ' '.join(f.read().splitlines())
525 525
526 saw = str(BeautifulSoup(html_content)).split() 526 saw = str(BeautifulSoup(html_content)).split()
527 expected = str(BeautifulSoup(expected_html)).split() 527 expected = str(BeautifulSoup(expected_html)).split()
528 528
529 self.assertEqual(saw, expected) 529 self.assertEqual(saw, expected)
530 530
531 def test_html_format_status(self):
532 import gatekeeper_mailer
533 status_header = ('Perf alert for "%(steps)s" on "%(builder_name)s"')
534 template = gatekeeper_mailer.MailTemplate(self.build_data['waterfall_url'],
535 self.build_data['build_url'],
536 self.build_data['project_name'],
537 'test@chromium.org',
538 status_header=status_header)
539
540 _, html_content, _ = template.genMessageContent(self.build_data)
541
542 with open(os.path.join(self.test_dir, 'expected_status.html')) as f:
543 expected_html = ' '.join(f.read().splitlines())
544
545 saw = str(BeautifulSoup(html_content)).split()
546 expected = str(BeautifulSoup(expected_html)).split()
547
548 self.assertEqual(saw, expected)
549
531 def test_hmac_validation(self): 550 def test_hmac_validation(self):
532 from mailer import Email 551 from mailer import Email
533 message = self.input_json['message'] 552 message = self.input_json['message']
534 url = 'http://invalid.chromium.org' 553 url = 'http://invalid.chromium.org'
535 secret = 'pajamas' 554 secret = 'pajamas'
536 555
537 test_json = self._hash_message(time.time(), message, url, secret) 556 test_json = self._hash_message(time.time(), message, url, secret)
538 # pylint: disable=W0212 557 # pylint: disable=W0212
539 self.assertTrue(Email._validate_message(test_json, url, secret)) 558 self.assertTrue(Email._validate_message(test_json, url, secret))
540 559
(...skipping 10 matching lines...) Expand all
551 ] 570 ]
552 571
553 for test_json in tests: 572 for test_json in tests:
554 # pylint: disable=W0212 573 # pylint: disable=W0212
555 self.assertFalse(Email._validate_message(test_json, url, secret)) 574 self.assertFalse(Email._validate_message(test_json, url, secret))
556 575
557 test_json = self._hash_message(time.time(), message, url, secret) 576 test_json = self._hash_message(time.time(), message, url, secret)
558 test_json['message'] = test_json['message'] + 'hey' 577 test_json['message'] = test_json['message'] + 'hey'
559 # pylint: disable=W0212 578 # pylint: disable=W0212
560 self.assertFalse(Email._validate_message(test_json, url, secret)) 579 self.assertFalse(Email._validate_message(test_json, url, secret))
OLDNEW
« no previous file with comments | « no previous file | gatekeeper_mailer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698