mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Fix update_message_flags tests to test with real messages.
As it turns out, some of these tests used message IDs 1 and 2, which Hamlet didn't even necessarily receive as the messages to update -- which meant that they previously updated 0 messages and returned success. So those tests started failing when I added a check for not updating anything in the update_message_flags backend -- and this commit fixes the tests to actually update a nonempty set of messages. (imported from commit 9034b415d4862216a266416a8e509d987050ffd7)
This commit is contained in:
		@@ -3561,7 +3561,12 @@ class UnreadCountTests(AuthedTestCase):
 | 
				
			|||||||
    def test_update_all_flags(self):
 | 
					    def test_update_all_flags(self):
 | 
				
			||||||
        self.login("hamlet@zulip.com")
 | 
					        self.login("hamlet@zulip.com")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        result = self.client.post("/json/update_message_flags", {"messages": ujson.dumps([1, 2]),
 | 
					        message_ids = [self.send_message("hamlet@zulip.com", "iago@zulip.com",
 | 
				
			||||||
 | 
					                                         Recipient.PERSONAL, "test"),
 | 
				
			||||||
 | 
					                       self.send_message("hamlet@zulip.com", "cordelia@zulip.com",
 | 
				
			||||||
 | 
					                                         Recipient.PERSONAL, "test2")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        result = self.client.post("/json/update_message_flags", {"messages": ujson.dumps(message_ids),
 | 
				
			||||||
                                                                 "op": "add",
 | 
					                                                                 "op": "add",
 | 
				
			||||||
                                                                 "flag": "read"})
 | 
					                                                                 "flag": "read"})
 | 
				
			||||||
        self.assert_json_success(result)
 | 
					        self.assert_json_success(result)
 | 
				
			||||||
@@ -3589,15 +3594,16 @@ class StarTests(AuthedTestCase):
 | 
				
			|||||||
        /json/update_message_flags.
 | 
					        /json/update_message_flags.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        self.login("hamlet@zulip.com")
 | 
					        self.login("hamlet@zulip.com")
 | 
				
			||||||
        message_ids = [1, 2]
 | 
					        message_ids = [self.send_message("hamlet@zulip.com", "hamlet@zulip.com",
 | 
				
			||||||
 | 
					                                         Recipient.PERSONAL, "test")]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Star a few messages.
 | 
					        # Star a message.
 | 
				
			||||||
        result = self.change_star(message_ids)
 | 
					        result = self.change_star(message_ids)
 | 
				
			||||||
        self.assert_json_success(result)
 | 
					        self.assert_json_success(result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for msg in self.get_old_messages():
 | 
					        for msg in self.get_old_messages():
 | 
				
			||||||
            if msg['id'] in message_ids:
 | 
					            if msg['id'] in message_ids:
 | 
				
			||||||
                self.assertEqual(msg['flags'], ['read', 'starred'])
 | 
					                self.assertEqual(msg['flags'], ['starred'])
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                self.assertEqual(msg['flags'], ['read'])
 | 
					                self.assertEqual(msg['flags'], ['read'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -3607,7 +3613,7 @@ class StarTests(AuthedTestCase):
 | 
				
			|||||||
        # Remove the stars.
 | 
					        # Remove the stars.
 | 
				
			||||||
        for msg in self.get_old_messages():
 | 
					        for msg in self.get_old_messages():
 | 
				
			||||||
            if msg['id'] in message_ids:
 | 
					            if msg['id'] in message_ids:
 | 
				
			||||||
                self.assertEqual(msg['flags'], ['read'])
 | 
					                self.assertEqual(msg['flags'], [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_new_message(self):
 | 
					    def test_new_message(self):
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user