Index: sync/tools/testserver/chromiumsync.py |
diff --git a/sync/tools/testserver/chromiumsync.py b/sync/tools/testserver/chromiumsync.py |
index 5487ef23aba0c1fb33c016eee39b6d39bf75b169..55bea94bbfa4ef981602ccdf2973241703713fcb 100644 |
--- a/sync/tools/testserver/chromiumsync.py |
+++ b/sync/tools/testserver/chromiumsync.py |
@@ -50,8 +50,6 @@ import session_specifics_pb2 |
import sync_pb2 |
import sync_enums_pb2 |
import synced_notification_app_info_specifics_pb2 |
-import synced_notification_data_pb2 |
-import synced_notification_render_pb2 |
import synced_notification_specifics_pb2 |
import theme_specifics_pb2 |
import typed_url_specifics_pb2 |
@@ -1207,46 +1205,6 @@ class SyncDataModel(object): |
def GetInducedError(self): |
return self.induced_error |
- def AddSyncedNotification(self, serialized_notification): |
- """Adds a synced notification to the server data. |
- |
- The notification will be delivered to the client on the next GetUpdates |
- call. |
- |
- Args: |
- serialized_notification: A serialized CoalescedSyncedNotification. |
- |
- Returns: |
- The string representation of the added SyncEntity. |
- |
- Raises: |
- ClientNotConnectedError: if the client has not yet connected to this |
- server |
- """ |
- # A unique string used wherever a unique ID for this notification is |
- # required. |
- unique_notification_id = str(uuid.uuid4()) |
- |
- specifics = self._CreateSyncedNotificationEntitySpecifics( |
- unique_notification_id, serialized_notification) |
- |
- # Create the root SyncEntity representing a single notification. |
- entity = sync_pb2.SyncEntity() |
- entity.specifics.CopyFrom(specifics) |
- entity.parent_id_string = self._ServerTagToId( |
- 'google_chrome_synced_notifications') |
- entity.name = 'Synced notification added for testing' |
- entity.version = self._GetNextVersionNumber() |
- |
- entity.client_defined_unique_tag = self._CreateSyncedNotificationClientTag( |
- specifics.synced_notification.coalesced_notification.key) |
- entity.id_string = self._ClientTagToId(GetEntryType(entity), |
- entity.client_defined_unique_tag) |
- |
- self._entries[entity.id_string] = copy.deepcopy(entity) |
- |
- return google.protobuf.text_format.MessageToString(entity) |
- |
def _GetNextVersionNumber(self): |
"""Set the version to one more than the greatest version number seen.""" |
entries = sorted(self._entries.values(), key=operator.attrgetter('version')) |
@@ -1254,97 +1212,6 @@ class SyncDataModel(object): |
raise ClientNotConnectedError |
return entries[-1].version + 1 |
- def _CreateSyncedNotificationEntitySpecifics(self, unique_id, |
- serialized_notification): |
- """Create the EntitySpecifics proto for a synced notification.""" |
- coalesced = synced_notification_data_pb2.CoalescedSyncedNotification() |
- google.protobuf.text_format.Merge(serialized_notification, coalesced) |
- |
- # Override the provided key so that we have a unique one. |
- coalesced.key = unique_id |
- |
- specifics = sync_pb2.EntitySpecifics() |
- notification_specifics = \ |
- synced_notification_specifics_pb2.SyncedNotificationSpecifics() |
- notification_specifics.coalesced_notification.CopyFrom(coalesced) |
- specifics.synced_notification.CopyFrom(notification_specifics) |
- |
- return specifics |
- |
- def _CreateSyncedNotificationClientTag(self, key): |
- """Create the client_defined_unique_tag value for a SyncedNotification. |
- |
- Args: |
- key: The entity used to create the client tag. |
- |
- Returns: |
- The string value of the to be used as the client_defined_unique_tag. |
- """ |
- serialized_type = sync_pb2.EntitySpecifics() |
- specifics = synced_notification_specifics_pb2.SyncedNotificationSpecifics() |
- serialized_type.synced_notification.CopyFrom(specifics) |
- hash_input = serialized_type.SerializeToString() + key |
- return base64.b64encode(hashlib.sha1(hash_input).digest()) |
- |
- def AddSyncedNotificationAppInfo(self, app_info): |
- """Adds an app info struct to the server data. |
- |
- The notification will be delivered to the client on the next GetUpdates |
- call. |
- |
- Args: |
- app_info: A serialized AppInfo. |
- |
- Returns: |
- The string representation of the added SyncEntity. |
- |
- Raises: |
- ClientNotConnectedError: if the client has not yet connected to this |
- server |
- """ |
- specifics = self._CreateSyncedNotificationAppInfoEntitySpecifics(app_info) |
- |
- # Create the root SyncEntity representing a single app info protobuf. |
- entity = sync_pb2.SyncEntity() |
- entity.specifics.CopyFrom(specifics) |
- entity.parent_id_string = self._ServerTagToId( |
- 'google_chrome_synced_notification_app_info') |
- entity.name = 'App info added for testing' |
- entity.version = self._GetNextVersionNumber() |
- |
- # App Infos do not have a strong id, it only needs to be unique. |
- entity.client_defined_unique_tag = "foo" |
- entity.id_string = "foo" |
- |
- self._entries[entity.id_string] = copy.deepcopy(entity) |
- |
- print "entity before exit is ", entity |
- |
- return google.protobuf.text_format.MessageToString(entity) |
- |
- def _CreateSyncedNotificationAppInfoEntitySpecifics( |
- self, synced_notification_app_info): |
- """Create the EntitySpecifics proto for a synced notification app info.""" |
- # Create a single, empty app_info object |
- app_info = \ |
- synced_notification_app_info_specifics_pb2.SyncedNotificationAppInfo() |
- # Fill the app_info object from the text format protobuf. |
- google.protobuf.text_format.Merge(synced_notification_app_info, app_info) |
- |
- # Create a new specifics object with a contained app_info |
- specifics = sync_pb2.EntitySpecifics() |
- app_info_specifics = \ |
- synced_notification_app_info_specifics_pb2.\ |
- SyncedNotificationAppInfoSpecifics() |
- |
- # Copy the app info from the text format protobuf |
- contained_app_info = app_info_specifics.synced_notification_app_info.add() |
- contained_app_info.CopyFrom(app_info) |
- |
- # And put the new app_info_specifics into the specifics before returning. |
- specifics.synced_notification_app_info.CopyFrom(app_info_specifics) |
- |
- return specifics |
class TestServer(object): |
"""An object to handle requests for one (and only one) Chrome Sync account. |
@@ -1740,9 +1607,7 @@ class TestServer(object): |
"""Customizes the value of the ClientCommand of ServerToClientResponse. |
Currently, this only allows for changing the sessions_commit_delay_seconds |
- field. This is useful for testing in conjunction with |
- AddSyncedNotification so that synced notifications are seen immediately |
- after triggering them with an HTTP call to the test server. |
+ field. |
Args: |
sessions_commit_delay_seconds: The desired sync delay time for sessions. |