| 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 | 6 |
| 7 from third_party.testing_utils import testing | 7 from third_party.testing_utils import testing |
| 8 | 8 |
| 9 from webtest.app import AppError |
| 10 |
| 9 import main | 11 import main |
| 10 | |
| 11 from model.password import Password | 12 from model.password import Password |
| 12 from model.record import Record | 13 from model.record import Record |
| 13 from shared.config import CQ_BOT_PASSWORD_KEY | 14 from shared.config import CQ_BOT_PASSWORD_KEY |
| 14 from shared import utils | 15 from shared import utils |
| 15 | 16 |
| 16 from webtest.app import AppError | |
| 17 | 17 |
| 18 class TestPost(testing.AppengineTestCase): | 18 class TestPost(testing.AppengineTestCase): |
| 19 app_module = main.app | 19 app_module = main.app |
| 20 | 20 |
| 21 def test_post_disallowed(self): | 21 def test_post_disallowed(self): |
| 22 self.mock_current_user(is_admin=False) | 22 self.mock_current_user(is_admin=False) |
| 23 | 23 |
| 24 # 403 status response crashes webtest. | 24 # 403 status response crashes webtest. |
| 25 self.assertRaises(AppError, lambda: self.test_app.post('/post')) | 25 self.assertRaises(AppError, lambda: self.test_app.post('/post')) |
| 26 | 26 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 def test_post_project_missing(self): | 150 def test_post_project_missing(self): |
| 151 self.mock_current_user(is_admin=True) | 151 self.mock_current_user(is_admin=True) |
| 152 response = self.test_app.get('/post', params={ | 152 response = self.test_app.get('/post', params={ |
| 153 'key': 'single_packet', | 153 'key': 'single_packet', |
| 154 'fields': '{"some": "random"}', | 154 'fields': '{"some": "random"}', |
| 155 }) | 155 }) |
| 156 self.assertEquals('"Project" field missing', response.body) | 156 self.assertEquals('"Project" field missing', response.body) |
| 157 record = Record.get_by_id('single_packet') | 157 record = Record.get_by_id('single_packet') |
| 158 self.assertIsNone(record) | 158 self.assertIsNone(record) |
| OLD | NEW |