desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Runs an async function which takes a callback argument. Waits for
the function to complete and returns any result.'
| def _RunAsync(self, func, *args, **kwargs):
| func(callback=self._stop, *args, **kwargs)
return self._wait()
|
'Iterates through the notifications of every user. For every notification that should
result in an alert, ensures that the alert test service contains a corresponding alert for
every device that should have been alerted.'
| def _ValidateAlerts(self):
| notifications_by_user = defaultdict(list)
(notifications, last_key) = self._RunAsync(Notification.Scan, self.validator.client, None)
for n in notifications:
notifications_by_user[n.user_id].append(n)
all_emails = TestEmailManager.Instance().emails
all_sms = TestSMSManager.Instance().phone_nu... |
'Automatically derives an op_dict from a request_dict that was passed
to a mutable service method. The op_dict can be passed to the various
notification helper methods.'
| def _DeriveNotificationOpDict(self, user_id, device_id, request_dict):
| return {'op_id': request_dict['headers']['op_id'], 'op_timestamp': request_dict['headers']['op_timestamp'], 'user_id': user_id, 'device_id': device_id}
|
'Dump the dicts as sorted JSON and compare.'
| def _CompareResponseDicts(self, context, user_id, request_dict, expected_dict, actual_dict):
| actual_dict = deepcopy(actual_dict)
actual_dict.pop('headers', None)
self._RemoveKeys(expected_dict, set(['_version', 'sort_key']))
exp_json = util.ToCanonicalJSON(expected_dict, indent=True)
actual_json = util.ToCanonicalJSON(actual_dict, indent=True)
if (exp_json != actual_json):
reque... |
'Recurse deeply into the item, removing items with a key value
that is in "key_set".'
| def _RemoveKeys(self, item, key_set):
| if isinstance(item, dict):
for (key, value) in item.items():
if (key in key_set):
del item[key]
else:
self._RemoveKeys(value, key_set)
elif isinstance(item, list):
for value in item:
self._RemoveKeys(value, key_set)
|
'Test listing of identities after linking and unlinking a new identity.'
| def testListIdentities(self):
| self._tester.LinkFacebookUser({'id': 100}, user_cookie=self._cookie)
self._tester.ListIdentities(self._cookie)
self._tester.UnlinkIdentity(self._cookie, 'FacebookGraph:100')
self._tester.ListIdentities(self._cookie)
|
'Update existing followers.'
| def testUpdateFollower(self):
| self._tester.UpdateFollower(self._cookie, self._user.private_vp_id, labels=self._all_labels_sans_removed)
self._tester.UpdateFollower(self._cookie2, self._new_vp_id, labels=[Follower.CONTRIBUTE])
self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=self._all_labels_sans_removed)
|
'Update follower attributes with only viewing permission.'
| def testViewPermissions(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=self._new_vp_id, labels=[])
self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=100)
self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=101, labels=[])
self._tester.UpdateFollower(self.... |
'Error: Update follower with REMOVED labels should fail because it\'s not allowed.'
| def testUpdateFollowerFailure(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=self._new_vp_id, labels=[])
self.assertRaisesHttpError(403, self._tester.UpdateFollower, self._cookie, self._new_vp_id, labels=[Follower.REMOVED])
|
'Verify that attempt to decrease viewed_seq is ignored.'
| def testRatchetViewedSeq(self):
| self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=2)
self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=1)
|
'Verify that attempt to set viewed_seq > update_seq is not allowed.'
| def testViewedSeqTooHigh(self):
| self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=1000)
follower = self._RunAsync(Follower.Query, self._client, self._user2.user_id, self._new_vp_id, None)
self.assertEqual(follower.viewed_seq, 0)
self._tester.UpdateFollower(self._cookie2, self._new_vp_id, viewed_seq=1000)
follow... |
'Update follower attribute to same value as it had before.'
| def testNoOpUpdate(self):
| follower = self._RunAsync(Follower.Query, self._client, self._user.user_id, self._new_vp_id, None)
self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=list(follower.labels))
self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=list(follower.labels))
|
'Remove labels from the viewpoint after setting them there.'
| def testRemoveLabels(self):
| self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=self._all_labels_sans_removed)
self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=Follower.PERMISSION_LABELS)
|
'Set the REMOVED label when it\'s already set.'
| def testSetRemovedLabel(self):
| self._tester.RemoveViewpoint(self._cookie, self._new_vp_id)
self._tester.UpdateFollower(self._cookie, self._new_vp_id, labels=(Follower.PERMISSION_LABELS + [Follower.REMOVED]))
|
'Test the MUTED label on a follower.'
| def testMuteViewpoint(self):
| self._skip_validation_for = ['Alerts']
device = self._RunAsync(Device.Query, self._client, self._user2.user_id, self._device_ids[1], None)
push_token = device.push_token[len(TestService.PREFIX):]
self._tester.UpdateFollower(self._cookie2, self._new_vp_id, labels=[Follower.CONTRIBUTE, Follower.MUTED])
... |
'Test enabling auto-save, then disabling it.'
| def testAutoSave(self):
| self._tester.UpdateFollower(self._cookie2, self._new_vp_id, labels=[Follower.CONTRIBUTE, Follower.AUTOSAVE])
self._tester.ShareExisting(self._cookie, self._new_vp_id, [(self._episode_id2, self._photo_ids2[:1])])
self.assertEqual(self._CountEpisodes(self._cookie2, self._user2.private_vp_id), 1)
self._tes... |
'Try to update attributes which not available for update.'
| def testAdditionalAttributes(self):
| for attr in ['sharing_user_id', 'foo', 'title']:
self.assertRaisesHttpError(400, self._tester.UpdateFollower, self._cookie, self._new_vp_id, attr=attr)
|
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testIdempotency(self):
| self._tester.UpdateFollower(self._cookie, self._new_vp_id, viewed_seq=2, labels=self._all_labels_sans_removed)
|
'ERROR: Try to update a follower on a viewpoint that does not exist.'
| def testInvalidViewpoint(self):
| self.assertRaisesHttpError(403, self._tester.UpdateFollower, self._cookie, 'vunknown')
|
'ERROR: Try to update a viewpoint that is not followed.'
| def testViewpointNotFollowed(self):
| self.assertRaisesHttpError(403, self._tester.UpdateFollower, self._cookie3, self._new_vp_id)
|
'ERROR: Try to clear follower permission labels.'
| def testClearPermissionLabels(self):
| self.assertRaisesHttpError(403, self._tester.UpdateFollower, self._cookie, self._new_vp_id, labels=[])
|
'Successfully resolve a single email.'
| def testOne(self):
| users = self._Resolve(['Email:user1@emailscrubbed.com'])
self.assertEqual(users, [{'identity': 'Email:user1@emailscrubbed.com', 'user_id': self._user.user_id, 'name': self._user.name, 'given_name': self._user.given_name, 'labels': [User.REGISTERED]}])
|
'Unsuccessfully resolve a single email.'
| def testMissing(self):
| users = self._Resolve(['Email:nobody@emailscrubbed.com'])
self.assertEqual(users, [{'identity': 'Email:nobody@emailscrubbed.com'}])
|
'Resolve a phone identity.'
| def testPhone(self):
| users = self._Resolve(['Phone:+14241234567'])
self.assertEqual(users, [{'identity': 'Phone:+14241234567', 'user_id': self.phone_user_id, 'name': 'Ben Darnell', 'given_name': 'Ben', 'family_name': 'Darnell', 'labels': [User.REGISTERED]}])
|
'ERROR: Facebook identities cannot be resolved.'
| def testFacebook(self):
| users = self._Resolve(['FacebookGraph:2'])
self.assertEqual(users, [{'identity': 'FacebookGraph:2'}])
|
'Resolve multiple identities in one request.'
| def testMultiple(self):
| users = self._Resolve(['Email:user1@emailscrubbed.com', 'FacebookGraph:2', 'Phone:+14241234567', 'Email:nobody@emailscrubbed.com'])
self.assertEqual(users, [{'identity': 'Email:user1@emailscrubbed.com', 'user_id': self._user.user_id, 'name': self._user.name, 'given_name': self._user.given_name, 'labels': [User.... |
'Try to resolve an identity that exists, but is not bound to any user.'
| def testUnboundIdentity(self):
| identity_key = 'Email:new.user@emailscrubbed.com'
self._UpdateOrAllocateDBObject(Identity, key=identity_key)
users = self._Resolve([identity_key])
self.assertEqual(users, [{u'identity': identity_key}])
|
'ERROR: Try to resolve identity using non-canonical form.'
| def testNonCanonicalId(self):
| self.assertRaisesHttpError(400, self._Resolve, ['Email:User1@YAHOO.com'])
|
'Terminated users cannot be resolved.'
| def testTerminatedUser(self):
| self._validate = False
users = self._Resolve(['Email:user3@emailscrubbed.com'])
self.assertEqual(users, [{'identity': 'Email:user3@emailscrubbed.com', 'user_id': self._user3.user_id, 'name': self._user3.name, 'labels': [User.REGISTERED]}])
self._tester.TerminateAccount(self._cookie3)
users = self._R... |
'Prospective users can be resolved.'
| def testProspectiveUser(self):
| self._CreateSimpleTestAssets()
(new_user, _, _) = self._CreateProspectiveUser()
users = self._Resolve(['Email:prospective@emailscrubbed.com'])
self.assertEqual(users, [{'identity': 'Email:prospective@emailscrubbed.com', 'user_id': 5, 'labels': []}])
self._UpdateOrAllocateDBObject(User, user_id=new_u... |
'Register user, overriding current logged-in user.'
| def testRegisterWithCookie(self):
| (user, device_id) = self._tester.RegisterGoogleUser(self._google_user_dict)
google_cookie = self._GetSecureUserCookie(user, device_id)
(user2, _) = self._tester.RegisterFacebookUser(self._facebook_user_dict, self._mobile_device_dict, user_cookie=google_cookie)
self.assertNotEqual(user.user_id, user2.use... |
'Test that email/push alert settings are updated properly during registration.'
| def testEmailAlertSettings(self):
| def _ValidateAlerts(email_alerts, push_alerts):
settings = self._RunAsync(AccountSettings.QueryByUser, self._client, self._prospective_user.user_id, None)
self.assertEqual(settings.email_alerts, email_alerts)
self.assertEqual(settings.sms_alerts, AccountSettings.SMS_NONE)
self.assert... |
'Test that SMS/push alert settings are updated properly during registration.'
| def testSmsAlertSettings(self):
| def _ValidateAlerts(sms_alerts, push_alerts):
settings = self._RunAsync(AccountSettings.QueryByUser, self._client, prospective_user.user_id, None)
self.assertEqual(settings.email_alerts, AccountSettings.EMAIL_NONE)
self.assertEqual(settings.sms_alerts, sms_alerts)
self.assertEqual(se... |
'Test multiple authorities that authenticate same identity.'
| def testMultipleAuthorities(self):
| self._tester.RegisterGoogleUser({'name': 'Mike Purtell', 'email': 'mike@emailscrubbed.com', 'verified_email': True})
self._tester.LoginViewfinderUser({'email': 'mike@emailscrubbed.com'}, self._mobile_device_dict)
identity = self._RunAsync(Identity.Query, self._client, 'Email:mike@emailscrubbed.com', None... |
'Test successful login override of current logged-in user.'
| def testLoginWithCookie(self):
| (user, device_id) = self._tester.RegisterFacebookUser(self._facebook_user_dict, self._mobile_device_dict)
facebook_cookie = self._GetSecureUserCookie(user, device_id)
self._tester.LoginFacebookUser(self._facebook_user_dict, self._mobile_device_dict, user_cookie=facebook_cookie)
(user, device_id) = self.... |
'Test that error returned by the service handler is properly formed.'
| def testErrorFormat(self):
| ident_dict = {'key': 'Email:andy@emailscrubbed.com', 'authority': 'FakeViewfinder'}
auth_info_dict = {'identity': ident_dict['key']}
url = self._tester.GetUrl('/login/viewfinder')
request_dict = _CreateRegisterRequest(self._mobile_device_dict, auth_info_dict, synchronous=False)
response = _SendAuthR... |
'ERROR: Try to log into a prospective user account.'
| def testLoginWithProspective(self):
| self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, self._register_user_dict)
|
'ERROR: Try to link another identity to a prospective user.'
| def testLinkWithProspective(self):
| cookie = self._GetSecureUserCookie(self._prospective_user, self._prospective_user.webapp_dev_id)
self.assertRaisesHttpError(403, self._tester.LinkFacebookUser, self._facebook_user_dict, user_cookie=cookie)
|
'ERROR: Try to link a Google account that is already linked to a different Viewfinder account.'
| def testLinkAlreadyLinked(self):
| (user, device_id) = self._tester.RegisterFacebookUser(self._facebook_user_dict)
facebook_cookie = self._GetSecureUserCookie(user, device_id)
self._tester.RegisterGoogleUser(self._google_user_dict)
self.assertRaisesHttpError(403, self._tester.LinkGoogleUser, self._google_user_dict, self._mobile_device_di... |
'Update name of a user and ensure that each friend is notified.'
| def testUpdateFriendAttribute(self):
| (vp_id, ep_ids) = self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Email:kimball.andy@emailscrubbed.com', self._user2.user_id])
self._tester.RegisterGoogleUser(self._google_user_dict)
response_dict = self._tester.QueryNotifications(self._cookie2, 1, scan_forward=False)
self.a... |
'Register an identity that is the target of a contact, which will
be bound to a user_id as a result.'
| def testRegisterContact(self):
| user_dict = {'name': 'Andrew Kimball', 'email': 'kimball.andy@emailscrubbed.com', 'verified_email': True}
identity_key = ('Email:%s' % user_dict['email'])
contact_dict = Contact.CreateContactDict(self._user.user_id, [(identity_key, None)], util._TEST_TIME, Contact.GMAIL, name=user_dict['name'])
self.... |
'Register an identity that is the target of a contact (that is still a prospective user).'
| def testRegisterProspectiveContact(self):
| for user_id in [self._user.user_id, self._user2.user_id]:
identity_key = ('Email:%s' % self._prospective_user.email)
contact_dict = Contact.CreateContactDict(user_id, [(identity_key, None)], util._TEST_TIME, Contact.GMAIL, name='Mr. John')
self._UpdateOrAllocateDBObject(Contact, **contact... |
'Register existing user and device, but create new identity via link.'
| def testNewIdentityOnly(self):
| (user, device_id) = self._tester.RegisterGoogleUser(self._google_user_dict, self._mobile_device_dict)
cookie = self._GetSecureUserCookie(user, device_id)
self._mobile_device_dict['device_id'] = device_id
self._tester.LinkFacebookUser(self._facebook_user_dict, self._mobile_device_dict, cookie)
|
'Register existing user and identity, but create new device as part of login.'
| def testNewDeviceOnly(self):
| self._tester.RegisterGoogleUser(self._google_user_dict)
self._tester.LoginGoogleUser(self._google_user_dict, self._mobile_device_dict)
|
'Register device with push token that is already in use by another device.'
| def testDuplicateToken(self):
| self._tester.RegisterGoogleUser(self._google_user_dict, self._mobile_device_dict)
self._tester.RegisterFacebookUser(self._facebook_user_dict, self._mobile_device_dict)
|
'Send async register request.'
| def testAsyncRequest(self):
| ident_dict = {'key': 'Email:andy@emailscrubbed.com', 'authority': 'FakeViewfinder'}
auth_info_dict = {'identity': ident_dict['key']}
url = self._tester.GetUrl('/link/fakeviewfinder')
request_dict = _CreateRegisterRequest(self._mobile_device_dict, auth_info_dict, synchronous=False)
response = _SendAu... |
'ERROR: Try to register existing device without existing user.'
| def testDeviceNoUser(self):
| (user, device_id) = self._tester.RegisterGoogleUser(self._google_user_dict, self._mobile_device_dict)
self._mobile_device_dict['device_id'] = device_id
self.assertRaisesHttpError(403, self._tester.RegisterFacebookUser, self._facebook_user_dict, self._mobile_device_dict)
|
'ERROR: Try to register existing device that is not owned by the
existing user.'
| def testDeviceNotOwned(self):
| self._tester.RegisterGoogleUser(self._google_user_dict, self._mobile_device_dict)
self._mobile_device_dict['device_id'] = 1000
self.assertRaisesHttpError(403, self._tester.RegisterGoogleUser, self._google_user_dict, self._mobile_device_dict)
|
'ERROR: Verify that attempt to register fails if --freeze_new_accounts
is true. This is the kill switch the server can throw to stop the tide
of incoming account registrations.'
| def testRegisterFreezeNewAccounts(self):
| options.options.freeze_new_accounts = True
exc = self.assertRaisesHttpError(403, self._tester.RegisterGoogleUser, self._google_user_dict, self._mobile_device_dict)
error_dict = json.loads(exc.response.body)
self.assertEqual(error_dict['error']['message'], auth._FREEZE_NEW_ACCOUNTS_MESSAGE)
self.asse... |
'ERROR: Try to login with an identity that exists, but is not bound to a user.'
| def testLoginWithUnboundIdentity(self):
| self._UpdateOrAllocateDBObject(Identity, key='Email:andy@emailscrubbed.com')
self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, self._viewfinder_user_dict, self._mobile_device_dict)
|
'ERROR: Verify that various malformed and missing register fields result
in a bad request (400) error.'
| def testBadRequest(self):
| url = ((self.get_url('/register/facebook') + '?') + urllib.urlencode({'access_token': 'dummy'}))
self.assertRaisesHttpError(400, _SendAuthRequest, self._tester, url, 'POST', request_dict='')
self.assertRaisesHttpError(400, _SendAuthRequest, self._tester, url, 'POST', request_dict={'device': 'foo'})
|
'ERROR: Try to register a user that already exists.'
| def testRegisterExisting(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user_dict)
self.assertRaisesHttpError(403, self._tester.RegisterViewfinderUser, self._viewfinder_user_dict, self._mobile_device_dict)
|
'Ensure that logout sends back a cookie with an expiration time.'
| def testLogout(self):
| url = self._tester.GetUrl('/logout')
response = _SendAuthRequest(self._tester, url, 'GET', user_cookie=self._cookie)
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['location'], '/')
self.assertIn('user', response.headers['Set-Cookie'])
self.assertIn('expires', response.he... |
'Test "use_session_cookie" option in auth request.'
| def testSessionCookie(self):
| auth_info_dict = {'identity': 'Email:andy@emailscrubbed.com', 'name': 'Andy Kimball', 'given_name': 'Andy', 'password': 'supersecure'}
url = self._tester.GetUrl('/register/viewfinder')
request_dict = _CreateRegisterRequest(None, auth_info_dict)
response = _SendAuthRequest(self._tester, url, 'POST', r... |
'Test successful build_archive.'
| def testBuildArchive(self):
| self._validate = False
self._CreateQueryAssets(add_test_photos=True)
all_viewpoints = self._validator.QueryModelObjects(Viewpoint)
vp_id_to_remove = all_viewpoints[1].viewpoint_id
self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=vp_id_to_remove, labels=[])
self._... |
'Creates a new photo and photo and updates both.'
| def testUpdatePhoto(self):
| photo_id = self._UploadEpisodeWithPhoto()
self._tester.UpdatePhoto(self._cookie, photo_id, caption='An Updated Caption', placemark={'iso_country_code': 'US', 'country': 'United States', 'state': 'NY', 'locality': 'New York', 'sublocality': 'NoHo', 'thoroughfare': 'Broadway', 'subthoroughfare': '682'... |
'Creates a new episode and photo and fails to update photo using different user.'
| def testUpdatePhotoForbidden(self):
| photo_id = self._UploadEpisodeWithPhoto()
self.assertRaisesHttpError(403, self._tester.UpdatePhoto, self._cookie3, photo_id, caption='An Updated Caption', placemark={'iso_country_code': 'US', 'country': 'United States', 'state': 'NY', 'locality': 'New York', 'sublocality': 'NoHo', 'thoroughfare': 'B... |
'Create episode with photo and upload.
Returns: photo_id of created photo.'
| def _UploadEpisodeWithPhoto(self):
| timestamp = time.time()
episode_id = Episode.ConstructEpisodeId(timestamp, self._device_ids[0], 100)
ep_dict = {'episode_id': episode_id, 'timestamp': timestamp, 'title': 'Episode Title'}
photo_id = Photo.ConstructPhotoId(timestamp, self._device_ids[0], 100)
ph_dict = {'aspect_ratio': 1.3333, 'ti... |
'Verify the put url can be fetched via /service/get_client_log.'
| def testNewClientLogUrl(self):
| timestamp = time.time()
log_timestamp = (timestamp - ((24 * 60) * 60))
response_dict = self._SendRequest('new_client_log_url', self._cookie, {'headers': {'op_id': 'o1', 'op_timestamp': timestamp}, 'timestamp': log_timestamp, 'client_log_id': 'log1'})
exp_put_url = ClientLog.GetPutUrl(self._user.user_id,... |
'Verify that content type can be set explicitly and used.'
| def testContentType(self):
| request_dict = {'headers': {'op_id': 'o1', 'op_timestamp': time.time()}, 'timestamp': time.time(), 'client_log_id': 'log_content_type', 'content_type': 'text/plain'}
self._GetNewLogUrlAndVerify(request_dict, 'test log file', content_type='test/plain', content_md5=None)
|
'Verify default content type.'
| def testDefaultContentType(self):
| request_dict = {'headers': {'op_id': 'o1', 'op_timestamp': time.time()}, 'timestamp': time.time(), 'client_log_id': 'default_content_type'}
self._GetNewLogUrlAndVerify(request_dict, 'test log file', content_type=CLIENT_LOG_CONTENT_TYPE, content_md5=None)
|
'Verify MD5 validation for client logs.'
| def testMD5ClientLog(self):
| log_body = 'test log file'
content_md5 = util.ComputeMD5Hex(log_body)
request_dict = {'headers': {'op_id': 'o1', 'op_timestamp': time.time()}, 'timestamp': time.time(), 'client_log_id': 'log1', 'content_md5': content_md5}
self._GetNewLogUrlAndVerify(request_dict, log_body, content_type=CLIENT_LOG_... |
'Get a new client log url based on "request_dict" and verify
the URL can be PUT using the specified content-type and md5.'
| def _GetNewLogUrlAndVerify(self, request_dict, log_body, content_type, content_md5):
| response_dict = self._SendRequest('new_client_log_url', self._cookie, request_dict)
url = response_dict['client_log_put_url']
headers = {'Content-Type': content_type}
if (content_md5 is not None):
headers['Content-MD5'] = content_md5
response = self._RunAsync(self._tester.http_client.fetch, ... |
'Share a single photo with two other users.'
| def testShare(self):
| vp_dict = self._CreateViewpointDict(self._cookie)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[:1])], [self._user2.user_id, self._user3.user_id], **vp_dict)
viewpoint = self._RunAsync(Viewpoint.Query, self._client, vp_dict['viewpoint_id'], col_names=None)
self.assertEqual(view... |
'ERROR: Try to share episode from viewpoint that is not followed.'
| def testInvalidShare(self):
| self.assertRaisesHttpError(403, self._tester.ShareNew, self._cookie2, [(self._episode_id, self._photo_ids[:1])], [self._user3.user_id])
|
'Try to override user_id, device_id, sharing_user_id, etc.'
| def testInvalidOverrides(self):
| for attr in ['user_id', 'device_id', 'sharing_user_id']:
self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [{'user_id': self._user2.user_id}], **self._CreateViewpointDict(self._cookie, **{attr: 100}))
|
'Set all possible attributes, then as few attributes as possible.'
| def testViewpointAttributes(self):
| vp_dict = self._CreateViewpointDict(self._cookie)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [{'user_id': self._user2.user_id}], **vp_dict)
viewpoint_id = Viewpoint.ConstructViewpointId(self._device_ids[0], self._test_id)
self._test_id += 1
self._tester.ShareNew(self.... |
'Share two photos with two other users.'
| def testShareMultiple(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id, self._user3.user_id], **self._CreateViewpointDict(self._cookie))
|
'Share two photos with two other users which exceeds too many followers.'
| @mock.patch.object(Viewpoint, 'MAX_FOLLOWERS', 2)
def testShareMultipleTooMany(self):
| self.assertRaisesHttpError(403, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id, self._user3.user_id])
|
'Share photos from originator to user2, and from user2 to user3.'
| def testSeriallyShare(self):
| (vp_id, ep_ids) = self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id], **self._CreateViewpointDict(self._cookie))
self._tester.ShareNew(self._cookie2, [(ep_ids[0], self._photo_ids)], [self._user3.user_id], **self._CreateViewpointDict(self._cookie2))
|
'Share photos to multiple episodes in the new viewpoint.'
| def testMultipleEpisodes(self):
| vp_dict = self._CreateViewpointDict(self._cookie)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[:1]), (self._episode_id, self._photo_ids[1:]), (self._episode_id, self._photo_ids)], [self._user2.user_id, self._user3.user_id], **vp_dict)
viewpoint = self._RunAsync(Viewpoint.Query, se... |
'Share multiple photos to same target episode in new viewpoint.'
| def testShareToSameEpisode(self):
| timestamp = time.time()
new_episode_id = Episode.ConstructEpisodeId(timestamp, self._device_ids[0], self._test_id)
self._test_id += 1
share_dict1 = {'existing_episode_id': self._episode_id, 'new_episode_id': new_episode_id, 'photo_ids': self._photo_ids[:1]}
share_dict2 = {'existing_episode_id': self... |
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testIdempotency(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1', {'identity': 'Local:identity2', 'name': 'Andy Kimball'}, {'identity': 'Email:me@emailscrubbed.com', 'name': 'Someone'}, 'Phone:+14251234567', 'Email:spam@emailscrubbed.com'])
|
'ERROR: Try to share the same photo multiple times to same episode.'
| def testShareSamePhotoSameEpisode(self):
| timestamp = time.time()
new_episode_id = Episode.ConstructEpisodeId(timestamp, self._device_ids[0], self._test_id)
self._test_id += 1
share_dict = {'existing_episode_id': self._episode_id, 'new_episode_id': new_episode_id, 'timestamp': timestamp, 'photo_ids': self._photo_ids}
self.assertRaisesHttpEr... |
'ERROR: Try to set an invalid label in the viewpoint.'
| def testInvalidLabel(self):
| self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [{'user_id': self._user2.user_id}], **self._CreateViewpointDict(self._cookie, labels=['UNKNOWN']))
|
'ERROR: Try to create a viewpoint and episode using device ids that
are different than the ones in the user cookies.'
| def testWrongDeviceIds(self):
| self.assertRaisesHttpError(403, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [{'user_id': self._user2.user_id}], **self._CreateViewpointDict(self._cookie2))
self.assertRaisesHttpError(403, self._tester.ShareNew, self._cookie, [self._tester.CreateCopyDict(self._cookie2, self._episo... |
'Verify that sharing with an unrecognized contact results in the
creation of a prospective user that is added as a follower.'
| def testProspectiveShare(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1'], **self._CreateViewpointDict(self._cookie))
|
'Verify that sharing multiple unrecognized contacts results in
multiple prospective users added as followers.'
| def testMultipleProspectiveShares(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1', {'identity': 'Local:identity2', 'name': 'Andy Kimball'}, {'identity': 'Email:me@emailscrubbed.com', 'name': 'Someone'}, 'Phone:+14251234567', 'Email:spam@emailscrubbed.com'])
|
'Verify that sharing unrecognized contacts with existing users
adds the correct followers.'
| def testMixedProspectiveShares(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1', {'identity': 'Local:identity2', 'name': 'Andy Kimball'}, self._user2.user_id, self._user3.user_id])
|
'Verify that sharing to the same unrecognized contact in sequence
results in the creation of a single prospective user.'
| def testSequenceProspectiveShares(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1'])
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], ['Local:identity1'])
|
'Add a contact as a follower using an identity that exists, but is not bound to a user.'
| def testProspectiveUnboundIdentity(self):
| identity_key = 'Email:new.user@emailscrubbed.com'
self._UpdateOrAllocateDBObject(Identity, key=identity_key)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [identity_key])
|
'Verify that sharing an empty episode list works.'
| def testShareNoEpisodes(self):
| self._tester.ShareNew(self._cookie, [], [self._user2.user_id], **self._CreateViewpointDict(self._cookie))
|
'Verify that sharing an empty contact list works.'
| def testShareNoContacts(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [], **self._CreateViewpointDict(self._cookie))
|
'Verify that sharing photos from multiple episodes works.'
| def testShareMultipleEpisodes(self):
| vp_dict = self._CreateViewpointDict(self._cookie)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids), (self._episode_id2, self._photo_ids2)], [self._user2.user_id, self._user3.user_id], **vp_dict)
viewpoint = self._RunAsync(Viewpoint.Query, self._client, vp_dict['viewpoint_id'], col_na... |
'Share into a new viewpoint, with self as a follower.'
| def testShareWithSelf(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user.user_id])
|
'Share into a new viewpoint, with duplicate followers.'
| def testShareWithDuplicateUsers(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id, self._user2.user_id], **self._CreateViewpointDict(self._cookie))
|
'Share photo from originator to user2, then another photo to user2.'
| def testMultipleSharesToSameUser(self):
| self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[:1])], [self._user2.user_id])
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[1:])], [self._user2.user_id])
|
'Share photo from originator to user2, then to user3. Then share a
different photo directly from user1 to user3'
| def testMultiplePathsToSameUser(self):
| (vp_id, ep_ids) = self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[:1])], [self._user2.user_id])
self._tester.ShareNew(self._cookie2, [(ep_ids[0], self._photo_ids[:1])], [self._user3.user_id])
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[1:])], [self._user3.... |
'Share 2 photos from same episode to user2, then 2 photos (1 of which
is in first set) with user3.'
| def testOverlappingShares(self):
| (episode_id, photo_ids) = self._UploadOneEpisode(self._cookie, 3)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[:2])], [self._user2.user_id])
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[1:])], [self._user3.user_id])
|
'Test sending the same share_new request in two different operations and observe that it succeeds.
A client may do this if it crashes while sending a share_new request.'
| def testRepeatedShareNew(self):
| (vp_id, _) = self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids[1:])], [self._user2.user_id])
vp_dict = {'viewpoint_id': vp_id}
(vp_id2, _) = self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id], **vp_dict)
self.assertEqual(vp_id, vp_id2)
|
'Share photos and specify one of them as the cover_photo.'
| def testShareWithCoverPhoto(self):
| update_vp_dict = {'cover_photo': (self._episode_id, self._photo_ids[0])}
vp_dict = self._CreateViewpointDict(self._cookie, **update_vp_dict)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id, self._user3.user_id], **vp_dict)
viewpoint = self._RunAsync(Viewpo... |
'ERROR: try sharing with a cover photo specified that is not being shared and expect failure.'
| def testShareWithMissingCoverPhoto(self):
| update_vp_dict = {'cover_photo': (self._episode_id, self._photo_ids[1])}
self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids[:1])], [self._user2.user_id, self._user3.user_id], **self._CreateViewpointDict(self._cookie, **update_vp_dict))
|
'ERROR: Try to share a cover photo that has a blank photo_id.'
| def testShareWithBlankCoverPhotoId(self):
| update_vp_dict = {'cover_photo': (self._episode_id, '')}
self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids[:1])], [self._user2.user_id, self._user3.user_id], **self._CreateViewpointDict(self._cookie, **update_vp_dict))
|
'ERROR: Try to create a default and system viewpoint.'
| def testShareInvalidTypes(self):
| self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id], **self._CreateViewpointDict(self._cookie, type=Viewpoint.DEFAULT))
self.assertRaisesHttpError(400, self._tester.ShareNew, self._cookie, [(self._episode_id, self._photo_ids)], [self.... |
'Authenticate test-user admin via JSON.'
| def testJSONAdminAuthenticate(self):
| otp._ClearUserHistory()
self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, True)
self.wait()
|
'Verify that reusing an OTP yields no cookie.'
| def testOTPReuse(self):
| otp._ClearUserHistory()
self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, True)
self.wait()
self._SendJSONRequest('test-user', 'test-password', otp.GetOTP('test-user'), 200, False)
self.wait()
|
'Verify that incorrect OTP value yields no cookie.'
| def testBadOTP(self):
| otp._ClearUserHistory()
self._SendJSONRequest('test-user', 'test-password', 0, 200, False)
self.wait()
|
'Verify bad password yields no cookie.'
| def testBadPassword(self):
| otp._ClearUserHistory()
self._SendJSONRequest('test-user', 'wrong-password', otp.GetOTP('test-user'), 200, False)
self.wait()
|
'Verify bad user yields no cookie.'
| def testBadUser(self):
| otp._ClearUserHistory()
self._SendJSONRequest('wrong-user', 'test-password', otp.GetOTP('test-user'), 200, False)
self.wait()
|
'Authenticate test-user admin via HTTP with a form post.'
| def testHTTPAdminAuthenticate(self):
| otp._ClearUserHistory()
self._SendHTTPRequest('test-user', 'test-password', otp.GetOTP('test-user'), 302, True)
self.wait()
otp._ClearUserHistory()
self._SendHTTPRequest('test-user', 'wrong-password', otp.GetOTP('test-user'), 200, False)
self.wait()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.