Title: [141182] trunk/Tools
Revision
141182
Author
[email protected]
Date
2013-01-29 16:56:46 -0800 (Tue, 29 Jan 2013)

Log Message

MockWeb should be able to serve mock web content
https://bugs.webkit.org/show_bug.cgi?id=108240

Patch by Alan Cutter <[email protected]> on 2013-01-29
Reviewed by Dirk Pranke.

Added the ability to have MockWeb serve mock web data.

* Scripts/webkitpy/common/host_mock.py:
(MockHost.__init__):
* Scripts/webkitpy/common/net/web_mock.py:
(MockWeb.__init__):
(MockWeb.get_binary):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (141181 => 141182)


--- trunk/Tools/ChangeLog	2013-01-30 00:50:01 UTC (rev 141181)
+++ trunk/Tools/ChangeLog	2013-01-30 00:56:46 UTC (rev 141182)
@@ -1,3 +1,18 @@
+2013-01-29  Alan Cutter  <[email protected]>
+
+        MockWeb should be able to serve mock web content
+        https://bugs.webkit.org/show_bug.cgi?id=108240
+
+        Reviewed by Dirk Pranke.
+
+        Added the ability to have MockWeb serve mock web data.
+
+        * Scripts/webkitpy/common/host_mock.py:
+        (MockHost.__init__):
+        * Scripts/webkitpy/common/net/web_mock.py:
+        (MockWeb.__init__):
+        (MockWeb.get_binary):
+
 2013-01-29  Jessie Berlin  <[email protected]>
 
         run-api-tests should have an option to specify root

Modified: trunk/Tools/Scripts/webkitpy/common/host_mock.py (141181 => 141182)


--- trunk/Tools/Scripts/webkitpy/common/host_mock.py	2013-01-30 00:50:01 UTC (rev 141181)
+++ trunk/Tools/Scripts/webkitpy/common/host_mock.py	2013-01-30 00:56:46 UTC (rev 141182)
@@ -40,10 +40,10 @@
 
 
 class MockHost(MockSystemHost):
-    def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True):
+    def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None):
         MockSystemHost.__init__(self, log_executive, executive_throws_when_run)
         add_unit_tests_to_mock_filesystem(self.filesystem)
-        self.web = MockWeb()
+        self.web = web or MockWeb()
 
         self._checkout = MockCheckout()
         self._scm = None

Modified: trunk/Tools/Scripts/webkitpy/common/net/web_mock.py (141181 => 141182)


--- trunk/Tools/Scripts/webkitpy/common/net/web_mock.py	2013-01-30 00:50:01 UTC (rev 141181)
+++ trunk/Tools/Scripts/webkitpy/common/net/web_mock.py	2013-01-30 00:56:46 UTC (rev 141182)
@@ -30,11 +30,14 @@
 
 
 class MockWeb(object):
-    def __init__(self):
+    def __init__(self, urls=None):
+        self.urls = urls or {}
         self.urls_fetched = []
 
     def get_binary(self, url, convert_404_to_None=False):
         self.urls_fetched.append(url)
+        if url in self.urls:
+            return self.urls[url]
         return "MOCK Web result, convert 404 to None=%s" % convert_404_to_None
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to