diff options
Diffstat (limited to 'net')
-rwxr-xr-x | net/tools/testserver/chromiumsync.py | 20 | ||||
-rwxr-xr-x | net/tools/testserver/testserver.py | 15 |
2 files changed, 31 insertions, 4 deletions
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py index 8257009..ac50e7d 100755 --- a/net/tools/testserver/chromiumsync.py +++ b/net/tools/testserver/chromiumsync.py @@ -407,8 +407,7 @@ class SyncDataModel(object): # SyncEntity protocol buffer. self._entries = {} - # TODO(nick): uuid.uuid1() is better, but python 2.5 only. - self.store_birthday = '%0.30f' % random.random() + self.ResetStoreBirthday() self.migration_history = MigrationHistory() @@ -560,6 +559,15 @@ class SyncDataModel(object): if spec.sync_type in requested_types: self._CreatePermanentItem(spec) + def ResetStoreBirthday(self): + """Resets the store birthday to a random value.""" + # TODO(nick): uuid.uuid1() is better, but python 2.5 only. + self.store_birthday = '%0.30f' % random.random() + + def StoreBirthday(self): + """Gets the store birthday.""" + return self.store_birthday + def GetChanges(self, sieve): """Get entries which have changed, oldest first. @@ -884,7 +892,7 @@ class TestServer(object): """Raises StoreBirthdayError if the request's birthday is a mismatch.""" if not request.HasField('store_birthday'): return - if self.account.store_birthday != request.store_birthday: + if self.account.StoreBirthday() != request.store_birthday: raise StoreBirthdayError def HandleMigrate(self, path): @@ -909,6 +917,12 @@ class TestServer(object): return (code, '<html><title>Migration: %d</title><H1>%d %s</H1></html>' % (code, code, response)) + def HandleCreateBirthdayError(self): + self.account.ResetStoreBirthday() + return ( + 200, + '<html><title>Birthday error</title><H1>Birthday error</H1></html>') + def HandleCommand(self, query, raw_request): """Decode and handle a sync command from a raw input of bytes. diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py index 693b50b..c9444ba 100755 --- a/net/tools/testserver/testserver.py +++ b/net/tools/testserver/testserver.py @@ -1404,7 +1404,8 @@ class SyncPageHandler(BasePageHandler): def __init__(self, request, client_address, sync_http_server): get_handlers = [self.ChromiumSyncMigrationOpHandler, - self.ChromiumSyncTimeHandler] + self.ChromiumSyncTimeHandler, + self.ChromiumSyncBirthdayErrorOpHandler] post_handlers = [self.ChromiumSyncCommandHandler, self.ChromiumSyncTimeHandler] BasePageHandler.__init__(self, request, client_address, @@ -1467,6 +1468,18 @@ class SyncPageHandler(BasePageHandler): self.wfile.write(raw_reply) return True + def ChromiumSyncBirthdayErrorOpHandler(self): + test_name = "/chromiumsync/birthdayerror" + if not self._ShouldHandleRequest(test_name): + return False + result, raw_reply = self.server._sync_handler.HandleCreateBirthdayError() + self.send_response(result) + self.send_header('Content-Type', 'text/html') + self.send_header('Content-Length', len(raw_reply)) + self.end_headers() + self.wfile.write(raw_reply) + return True; + def MakeDataDir(): if options.data_dir: |