Chromium Code Reviews| Index: net/tools/testserver/chromiumsync.py |
| diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py |
| index 7e83a8833797a10e8262b6134d37f0f5fcfb037b..17936f9faf1e5e7c59832df414c60f456b3f6d21 100755 |
| --- a/net/tools/testserver/chromiumsync.py |
| +++ b/net/tools/testserver/chromiumsync.py |
| @@ -100,6 +100,9 @@ class MigrationDoneError(Error): |
| class StoreBirthdayError(Error): |
| """The client sent a birthday that doesn't correspond to this server.""" |
|
ncarter (slow)
2011/07/29 18:52:17
The style guide requires 2 blank lines between top
lipalani1
2011/08/05 21:33:57
Done.
|
| +class TransientError(Error): |
| + """The client would be sent a transient error.""" |
| + |
| def GetEntryType(entry): |
| """Extract the sync type from a SyncEntry. |
| @@ -915,6 +918,7 @@ class TestServer(object): |
| self.clients = {} |
| self.client_name_generator = ('+' * times + chr(c) |
| for times in xrange(0, sys.maxint) for c in xrange(ord('A'), ord('Z'))) |
| + self.transient_error = False |
| def GetShortClientName(self, query): |
| parsed = cgi.parse_qs(query[query.find('?')+1:]) |
| @@ -933,6 +937,11 @@ class TestServer(object): |
| if self.account.store_birthday != request.store_birthday: |
| raise StoreBirthdayError |
| + def CheckTransientError(self): |
| + """Raises Transiet error if |transient_error| variable is set.""" |
|
ncarter (slow)
2011/07/29 18:52:17
"Transiet" is a misspelling, you should probably s
lipalani1
2011/08/05 21:33:57
Done.
|
| + if self.transient_error == True: |
|
ncarter (slow)
2011/07/29 18:52:17
Just say "if self.transient_error:". While this i
lipalani1
2011/08/05 21:33:57
Done.
|
| + raise TransientError |
| + |
| def HandleMigrate(self, path): |
| query = urlparse.urlparse(path)[4] |
| code = 200 |
| @@ -961,6 +970,12 @@ class TestServer(object): |
| 200, |
| '<html><title>Birthday error</title><H1>Birthday error</H1></html>') |
| + def HandleSetTransientError(self): |
| + self.transient_error = True |
| + return ( |
| + 200, |
| + '<html><title>Transient error</title><H1>Transient error</H1></html>') |
| + |
| def HandleCommand(self, query, raw_request): |
| """Decode and handle a sync command from a raw input of bytes. |
| @@ -989,6 +1004,7 @@ class TestServer(object): |
| response.error_code = sync_pb2.ClientToServerResponse.SUCCESS |
| self.CheckStoreBirthday(request) |
| response.store_birthday = self.account.store_birthday |
| + self.CheckTransientError(); |
| print_context('->') |
| @@ -1026,6 +1042,12 @@ class TestServer(object): |
| response.store_birthday = self.account.store_birthday |
| response.error_code = sync_pb2.ClientToServerResponse.NOT_MY_BIRTHDAY |
| return (200, response.SerializeToString()) |
| + except TransientError as error: |
| + print_context('<-') |
| + print 'TRANSIENT_ERROR' |
| + response.store_birthday = self.account.store_birthday |
| + response.error_code = sync_pb2.ClientToServerResponse.TRANSIENT_ERROR |
| + return (200, response.SerializeToString()) |
| finally: |
| self.account_lock.release() |