Example #1
0
 def test_archive_is_removed_for_both_respondent_and_internal(self):
     """testing archive label is removed after being added to both respondent and internal"""
     self.populate_database(2)
     with self.engine.connect() as con:
         query = 'SELECT msg_id FROM secure_message LIMIT 1'
         query_x = con.execute(query)
         names = []
         for row in query_x:
             names.append(row[0])
     with app.app_context():
         with current_app.test_request_context():
             msg_id = str(names[0])
             message_service = Retriever()
             modifier = Modifier()
             message = message_service.retrieve_message(
                 msg_id, 'respondent.21345')
             modifier.add_archived(message, 'respondent.21345')
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             modifier.add_archived(message, 'internal.21345')
             message = message_service.retrieve_message(
                 msg_id, 'respondent.21345')
             modifier.del_archived(message, 'respondent.21345')
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             modifier.del_archived(message, 'internal.21345')
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             self.assertCountEqual(message['labels'], ['UNREAD', 'INBOX'])
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             self.assertCountEqual(message['labels'], ['UNREAD', 'INBOX'])
Example #2
0
 def test_archived_label_is_removed_from_message(self):
     """testing message is added to database with archived label removed and inbox and read is added instead"""
     self.populate_database(1)
     with self.engine.connect() as con:
         query = 'SELECT msg_id FROM secure_message LIMIT 1'
         query_x = con.execute(query)
         names = []
         for row in query_x:
             names.append(row[0])
     with app.app_context():
         with current_app.test_request_context():
             msg_id = str(names[0])
             message_service = Retriever()
             message = message_service.retrieve_message(
                 msg_id, 'respondent.21345')
             modifier = Modifier()
             modifier.add_archived(message, 'respondent.21345')
             message = message_service.retrieve_message(
                 msg_id, 'respondent.21345')
             modifier.del_archived(
                 message,
                 'respondent.21345',
             )
             message = message_service.retrieve_message(
                 msg_id, 'respondent.21345')
             self.assertCountEqual(message['labels'], ['SENT'])
Example #3
0
 def test_add_archive_is_added_to_internal(self):
     """testing message is added to database with archived label attached"""
     self.populate_database(1)
     with self.engine.connect() as con:
         query = 'SELECT msg_id FROM secure_message LIMIT 1'
         query_x = con.execute(query)
         names = []
         for row in query_x:
             names.append(row[0])
     with app.app_context():
         with current_app.test_request_context():
             msg_id = str(names[0])
             message_service = Retriever()
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             Modifier.del_archived(message, 'internal.21345')
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             Modifier.add_archived(message, 'internal.21345')
             message = message_service.retrieve_message(
                 msg_id, 'internal.21345')
             self.assertCountEqual(message['labels'],
                                   ['UNREAD', 'INBOX', 'ARCHIVE'])