def testCreateMigrations(self): user = GFWUser() user.auth_ids = ['123'] user.put() new_subscription = Subscription() new_subscription.params = {} new_subscription.user_id = user.key new_subscription.put() subscription = Subscription() subscription.params = {'iso': 'ALB'} subscription.email = '*****@*****.**' subscription.put() Migration.create_from_subscriptions() migration_count = Migration.query().count() self.assertEqual(migration_count, 1) migration = Migration.query().fetch()[0] self.assertEqual(migration.email, '*****@*****.**') self.assertEqual(len(migration.subscriptions), 1) self.assertEqual(migration.subscriptions[0], subscription.key)
def testUpdateSubscriptions(self): subscription = Subscription() subscription.params = {} subscription.put() migration = Migration() migration.subscriptions = [subscription.key] migration.put() user = GFWUser() user.auth_ids = ['123'] user.put() migration.update_subscriptions(user) self.assertIsNotNone(subscription.key.get().user_id) self.assertEqual(subscription.key.get().user_id.urlsafe(), user.key.urlsafe())