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

Unified Diff: dashboard/dashboard/testing_common.py

Issue 1549583002: In /graph_json, check internal_only on Test entity and skip test for all Row entities. (Closed) Base URL: https://github.com/catapult-project/catapult@master
Patch Set: Removed purposeful fail for local debugging Created 5 years 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 side-by-side diff with in-line comments
Download patch
« dashboard/dashboard/graph_revisions.py ('K') | « dashboard/dashboard/mr_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/testing_common.py
diff --git a/dashboard/dashboard/testing_common.py b/dashboard/dashboard/testing_common.py
index 2ab35433aae9d957448bbe70e5204ad9d8210f57..8b791fbc06b12fbddbc96461a419ec57bd72143f 100644
--- a/dashboard/dashboard/testing_common.py
+++ b/dashboard/dashboard/testing_common.py
@@ -6,10 +6,12 @@
import base64
import json
+import mock
import os
import re
import unittest
import urllib
+import webapp2
from google.appengine.ext import deferred
from google.appengine.ext import ndb
@@ -22,6 +24,21 @@ from dashboard.models import graph_data
_QUEUE_YAML_DIR = os.path.join(os.path.dirname(__file__), os.path.pardir)
+class FakeRequestObject(object):
+ """Fake Request object which can be used by datastore_hooks mocks."""
qyearsley 2015/12/28 22:50:56 Could add a blank line before the method definitio
sullivan 2015/12/29 03:36:07 Done.
+ def __init__(self, remote_addr=None):
+ self.registry = {}
+ self.remote_addr = remote_addr
+
+
+class FakeResponseObject(object):
+ """Fake Response Object which can be returned by urlfetch mocks."""
+
+ def __init__(self, status_code, content):
+ self.status_code = status_code
+ self.content = content
+
+
class TestCase(unittest.TestCase):
"""Common base class for test cases."""
@@ -35,6 +52,7 @@ class TestCase(unittest.TestCase):
self.testbed.init_taskqueue_stub(root_path=_QUEUE_YAML_DIR)
self.testbed.init_user_stub()
self.testbed.init_urlfetch_stub()
+ self.mock_get_request = None
def tearDown(self):
self.testbed.deactivate()
@@ -100,6 +118,13 @@ class TestCase(unittest.TestCase):
return None
return None
+ def PatchDatastoreHooksRequest(self, remote_addr=None):
qyearsley 2015/12/28 22:50:56 Could add a docstring, if you think it makes it cl
sullivan 2015/12/29 03:36:07 Done.
+ get_request_patcher = mock.patch(
+ 'webapp2.get_request',
+ mock.MagicMock(return_value=FakeRequestObject(remote_addr)))
+ self.mock_get_request = get_request_patcher.start()
+ self.addCleanup(get_request_patcher.stop)
+
def AddTests(masters, bots, tests_dict):
"""Adds data to the mock datastore.
@@ -177,14 +202,6 @@ def SetSheriffDomains(domains):
stored_object.Set(utils.SHERIFF_DOMAINS_KEY, domains)
-class FakeResponseObject(object):
- """Fake Response Object which can be returned by urlfetch mocks."""
-
- def __init__(self, status_code, content):
- self.status_code = status_code
- self.content = content
-
-
def SetIpWhitelist(ip_addresses):
"""Sets the list of whitelisted IP addresses."""
stored_object.Set(utils.IP_WHITELIST_KEY, ip_addresses)
« dashboard/dashboard/graph_revisions.py ('K') | « dashboard/dashboard/mr_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698