Beispiel #1
0
    def login_user(self, shard_id=None):
        """Logs in the user."""
        if shard_id is None:
            shard_id = self.shard.shard_id

        login_id = presence.user_logged_in(shard_id, self.user_id)
        login_record = models.LoginRecord.get_by_id(login_id)
        login_record.email_address = '*****@*****.**'
        login_record.put()
Beispiel #2
0
    def testChannelMessage(self):
        """Tests that post and apply both send message updates."""
        shard = models.Shard(id='my-shard-name')
        shard.put()

        channel_stub = self.testbed.get_stub(testbed.CHANNEL_SERVICE_NAME)
        user_id = 'my-user-id'
        presence.user_logged_in(shard.shard_id, user_id)
        _, browser_token = presence.change_presence(
            shard.shard_id, user_id, 'name here', True, True, False)
        channel_stub.connect_channel(browser_token)

        # This clears the presence Post from change_presence()
        posts.apply_posts(shard.shard_id)
        channel_stub.pop_first_message(browser_token)

        post_key = posts.insert_post(
            shard.shard_id,
            archive_type=models.Post.CHAT,
            nickname='My name',
            user_id='abc',
            body='Here is my message')

        message = channel_stub.pop_first_message(browser_token)
        found_posts = json.loads(message)['posts']
        post = post_key.get()
        expected_posts = posts.marshal_posts(shard.shard_id, [post])
        self.assertEquals(expected_posts, found_posts)
        self.assertEquals(None, expected_posts[0]['sequenceId'])

        posts.apply_posts(shard.shard_id)
        post = post_key.get()
        message = channel_stub.pop_first_message(browser_token)
        found_posts = json.loads(message)['posts']
        self.assertEquals(2, found_posts[0]['sequenceId'])
        post = post_key.get()
        post.sequence = 2  # Pretend to do what apply_posts does
        expected_posts = posts.marshal_posts(shard.shard_id, [post])
        self.assertEquals(expected_posts, found_posts)