Merge branch 'main' into avm99963-monorail
Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266
GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/tracker/test/issueattachmenttext_test.py b/tracker/test/issueattachmenttext_test.py
index f7dda8d..f6a2447 100644
--- a/tracker/test/issueattachmenttext_test.py
+++ b/tracker/test/issueattachmenttext_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2016 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Tests for issueattachmenttext."""
from __future__ import print_function
@@ -15,10 +14,8 @@
from google.appengine.ext import testbed
from google.cloud import storage
-import webapp2
-
from framework import permissions
-from proto import tracker_pb2
+from mrproto import tracker_pb2
from services import service_manager
from testing import fake
from testing import testing_helpers
@@ -38,8 +35,7 @@
issue=fake.IssueService(),
user=fake.UserService())
self.project = services.project.TestAddProject('proj')
- self.servlet = issueattachmenttext.AttachmentText(
- 'req', 'res', services=services)
+ self.servlet = issueattachmenttext.AttachmentText(services=services)
services.user.TestAddUser('commenter@example.com', 111)
@@ -88,7 +84,7 @@
self.blob = mock.MagicMock()
self.client.get_bucket = mock.MagicMock(return_value=self.bucket)
self.bucket.get_blob = mock.MagicMock(return_value=self.blob)
- self.blob.download_as_bytes = mock.MagicMock()
+ self.blob.download_as_bytes = mock.MagicMock(return_value=b'')
mock.patch.object(storage, 'Client', return_value=self.client).start()
def tearDown(self):
@@ -142,7 +138,7 @@
project=self.project,
path='/p/proj/issues/attachmentText?aid=9999',
perms=permissions.READ_ONLY_PERMISSIONSET)
- with self.assertRaises(webapp2.HTTPException) as cm:
+ with self.assertRaises(Exception) as cm:
self.servlet.GatherPageData(mr)
self.assertEqual(404, cm.exception.code)
@@ -153,13 +149,13 @@
path='/p/proj/issues/attachmentText?aid=1234',
perms=permissions.READ_ONLY_PERMISSIONSET)
self.attach1.deleted = True
- with self.assertRaises(webapp2.HTTPException) as cm:
+ with self.assertRaises(Exception) as cm:
self.servlet.GatherPageData(mr)
- self.assertEqual(404, cm.exception.code)
+ self.assertEqual(404, cm.exception.code)
def testGatherPageData_Normal(self):
self.blob.download_as_bytes = mock.MagicMock(
- return_value='/app_default_bucket/pid/attachments/abcdefg')
+ return_value=b'/app_default_bucket/pid/attachments/abcdefg')
_request, mr = testing_helpers.GetRequestObjects(
project=self.project,
@@ -176,8 +172,8 @@
file_lines = page_data['file_lines']
self.assertEqual(1, len(file_lines))
self.assertEqual(1, file_lines[0].num)
- self.assertEqual('/app_default_bucket/pid/attachments/abcdefg',
- file_lines[0].line)
+ self.assertEqual(
+ '/app_default_bucket/pid/attachments/abcdefg', file_lines[0].line)
self.assertEqual(None, page_data['code_reviews'])