| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import sys | |
| 8 | |
| 9 # App Engine source file imports must be relative to their app's root. | |
| 10 sys.path.append(os.path.dirname(os.path.dirname(__file__))) | |
| 11 | 7 |
| 12 from appengine.utils import testing | 8 from appengine.utils import testing |
| 13 from appengine.chromium_cq_status import main | 9 |
| 14 from appengine.chromium_cq_status.model.record import Record | 10 from appengine.path_mangler_hack import PathMangler |
| 11 with PathMangler(os.path.dirname(os.path.dirname(__file__))): |
| 12 from appengine.chromium_cq_status import main |
| 13 from appengine.chromium_cq_status.model.record import Record |
| 14 |
| 15 from webtest.app import AppError | 15 from webtest.app import AppError |
| 16 | 16 |
| 17 class TestPost(testing.AppengineTestCase): | 17 class TestPost(testing.AppengineTestCase): |
| 18 app_module = main.app | 18 app_module = main.app |
| 19 | 19 |
| 20 def test_post_disallowed(self): | 20 def test_post_disallowed(self): |
| 21 self.mock_current_user(is_admin=False) | 21 self.mock_current_user(is_admin=False) |
| 22 | 22 |
| 23 # 403 status response crashes webtest. | 23 # 403 status response crashes webtest. |
| 24 self.assertRaises(AppError, lambda: self.test_app.post('/post')) | 24 self.assertRaises(AppError, lambda: self.test_app.post('/post')) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 self.assertEquals(set(['hello', 'world']), set(record.tags)) | 127 self.assertEquals(set(['hello', 'world']), set(record.tags)) |
| 128 self.assertEquals({'hello': 'world'}, record.fields) | 128 self.assertEquals({'hello': 'world'}, record.fields) |
| 129 | 129 |
| 130 record = Record.get_by_id('multiple_1') | 130 record = Record.get_by_id('multiple_1') |
| 131 self.assertEquals(['issue=autotagged'], record.tags) | 131 self.assertEquals(['issue=autotagged'], record.tags) |
| 132 self.assertEquals({'issue': 'autotagged'}, record.fields) | 132 self.assertEquals({'issue': 'autotagged'}, record.fields) |
| 133 | 133 |
| 134 record = Record.get_by_id('multiple_2') | 134 record = Record.get_by_id('multiple_2') |
| 135 self.assertEquals(set(['empty', 'fields']), set(record.tags)) | 135 self.assertEquals(set(['empty', 'fields']), set(record.tags)) |
| 136 self.assertEquals({}, record.fields) | 136 self.assertEquals({}, record.fields) |
| OLD | NEW |