def testPost_ForcesCacheUpdate(self): key = update_test_suites._NamespaceKey( update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, {'foo': 'bar'}) self.assertEqual( {'foo': 'bar'}, update_test_suites.FetchCachedTestSuites()) self._AddSampleData() # Because there is something cached, the cache is # not automatically updated when new data is added. self.assertEqual( {'foo': 'bar'}, update_test_suites.FetchCachedTestSuites()) # Making a request to /udate_test_suites forces an update. self.testapp.post('/update_test_suites') self.assertEqual( { 'dromaeo': { 'mas': {'Chromium': {'mac': False, 'win7': False}}, }, 'scrolling': { 'mas': {'Chromium': {'mac': False, 'win7': False}}, }, 'really': { 'mas': {'Chromium': {'mac': False, 'win7': False}}, }, }, update_test_suites.FetchCachedTestSuites())
def testFetchCachedTestSuites_NotEmpty(self): # If the cache is set, then whatever's there is returned. key = update_test_suites._NamespaceKey( update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, {'foo': 'bar'}) self.assertEqual({'foo': 'bar'}, update_test_suites.FetchCachedTestSuites())
def testFetchCachedTestSuites_NotEmpty(self): # If the cache is set, then whatever's there is returned. key = update_test_suites._NamespaceKey(graph_data.LIST_SUITES_CACHE_KEY) stored_object.Set(key, {'foo': 'bar'}) self.assertEqual( {'foo': 'bar'}, update_test_suites.FetchCachedTestSuites())
def _AddCachedSuites(self): test_suites = { 'sunspider': { 'mas': { 'ChromiumPerf': { 'mac': False, 'linux': False } }, 'mon': ['Total'], }, 'page_cycler': { 'mas': { 'ChromiumPerf': { 'linux': False }, 'CrOS': { 'foo': False } }, 'mon': ['load_time'], }, 'speedometer': { 'mas': { 'CrOS': { 'foo': False } } } } key = update_test_suites._NamespaceKey( update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, test_suites)
def _AddCachedSuites(self): test_suites = { 'sunspider': { 'mas': {'ChromiumPerf': {'mac': False, 'linux': False}}, 'mon': [], }, 'page_cycler': { 'mas': {'ChromiumPerf': {'linux': False}, 'CrOS': {'foo': False}}, 'mon': ['load_time'], }, 'speedometer': { 'mas': {'CrOS': {'foo': False, 'bar': False}}, 'mon': [], } } key = update_test_suites._NamespaceKey( update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, test_suites)
def testPost_ForcesCacheUpdate(self): key = update_test_suites._NamespaceKey(update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, {"foo": "bar"}) self.assertEqual({"foo": "bar"}, update_test_suites.FetchCachedTestSuites()) self._AddSampleData() # Because there is something cached, the cache is # not automatically updated when new data is added. self.assertEqual({"foo": "bar"}, update_test_suites.FetchCachedTestSuites()) # Making a request to /udate_test_suites forces an update. self.testapp.post("/update_test_suites") self.assertEqual( { "dromaeo": {"mas": {"Chromium": {"mac": False, "win7": False}}}, "scrolling": {"mas": {"Chromium": {"mac": False, "win7": False}}}, "really": {"mas": {"Chromium": {"mac": False, "win7": False}}}, }, update_test_suites.FetchCachedTestSuites(), )