Пример #1
0
    def test_draft_label_is_deleted(self):
        """Check draft label is deleted for message"""
        with app.app_context():
            with current_app.test_request_context():
                self.test_message = {
                    'msg_id': 'test123',
                    'urn_to': 'richard',
                    'urn_from': 'respondent.richard',
                    'subject': 'MyMessage',
                    'body': 'hello',
                    'thread_id': '',
                    'collection_case': 'ACollectionCase',
                    'reporting_unit': 'AReportingUnit',
                    'survey': 'ACollectionInstrument'
                }

                modifier = Modifier()
                with self.engine.connect() as con:
                    add_draft = (
                        "INSERT INTO status (label, msg_id, actor) "
                        "VALUES ('{0}', 'test123', 'respondent.richard')"
                    ).format(Labels.DRAFT.value)
                    con.execute(add_draft)
                modifier.del_draft(self.test_message['msg_id'])

                with self.engine.connect() as con:
                    request = con.execute(
                        "SELECT * FROM status WHERE msg_id='{0}' AND actor='{1}'"
                        .format('test123', 'respondent.richard'))
                    for row in request:
                        self.assertTrue(row is None)
                        break
                    else:
                        pass
Пример #2
0
 def del_draft_labels(draft_id):
     modifier = Modifier()
     modifier.del_draft(draft_id)