def test_list_submitted_resources(self):
        '''Test_list_submitted_resources - check the data selection and update for admin interface'''

        id_tests = []

        id_tests.append(
            insert_into_swr_clientdata(
                4, 97, 1, 'test', 'test', '10030148',
                'https://arxiv.org/sword-app/edit/10030148',
                'https://arxiv.org/sword-app/edit/10030148.atom',
                'http://arxiv.org/resolve/app/10030148'))

        time.sleep(1)

        id_tests.append(
            insert_into_swr_clientdata(
                4, 97, 1, 'test', 'test', '10030148',
                'https://arxiv.org/sword-app/edit/10030148',
                'https://arxiv.org/sword-app/edit/10030148.atom',
                'http://arxiv.org/resolve/app/10030148'))

        update_submission_status(id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED,
                                 '1003.0148')

        time.sleep(1)

        id_tests.append(
            insert_into_swr_clientdata(
                3, 92, 2, 'test', 'test', '12340097',
                'https://arxiv.org/sword-app/edit/12340097',
                'https://arxiv.org/sword-app/edit/12340097.atom',
                'http://arxiv.org/resolve/app/12340097'))

        time.sleep(1)

        (submissions, modifications) = list_submitted_resources(0, 10, '')

        self.assertEqual(len(submissions), 3)
        self.assertEqual(len(modifications), 2)

        self.assertEqual(submissions[1]['id_remote'], '1003.3743')
        self.assertEqual(submissions[1]['status'],
                         CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[1]['publication_date'] != '', True)

        self.assertEqual(submissions[2]['id_remote'], '1003.0148')
        self.assertEqual(submissions[2]['status'],
                         CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[2]['publication_date'] != '', True)

        self.assertEqual(submissions[0]['id_remote'], '12340097')
        self.assertEqual(submissions[0]['status'],
                         CFG_SUBMISSION_STATUS_REMOVED)
        self.assertEqual(submissions[0]['removal_date'] != '', True)

        self.assertEqual(modifications[1], submissions[0]['id'])
        self.assertEqual(modifications[0], submissions[1]['id'])

        for id_test in id_tests:
            delete_from_swr_clientdata(id_test)
    def test_list_submitted_resources(self):
        '''Test_list_submitted_resources - check the data selection and update for admin interface'''

        id_tests = []

        id_tests.append(insert_into_swr_clientdata(4, 97, 1, 'test', 'test', '10030148',
                               'https://arxiv.org/sword-app/edit/10030148',
                               'https://arxiv.org/sword-app/edit/10030148.atom',
                               'http://arxiv.org/resolve/app/10030148'))

        time.sleep(1)

        id_tests.append(insert_into_swr_clientdata(4, 97, 1, 'test', 'test', '10030148',
                               'https://arxiv.org/sword-app/edit/10030148',
                               'https://arxiv.org/sword-app/edit/10030148.atom',
                               'http://arxiv.org/resolve/app/10030148'))

        update_submission_status(id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED, '1003.0148')

        time.sleep(1)

        id_tests.append(insert_into_swr_clientdata(3, 92, 2, 'test', 'test', '12340097',
                               'https://arxiv.org/sword-app/edit/12340097',
                               'https://arxiv.org/sword-app/edit/12340097.atom',
                               'http://arxiv.org/resolve/app/12340097'))

        time.sleep(1)

        (submissions, modifications) = list_submitted_resources(0, 10, '')

        self.assertEqual(len(submissions), 3)
        self.assertEqual(len(modifications), 2)

        self.assertEqual(submissions[1]['id_remote'], '1003.3743')
        self.assertEqual(submissions[1]['status'], CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[1]['publication_date'] != '', True)

        self.assertEqual(submissions[2]['id_remote'], '1003.0148')
        self.assertEqual(submissions[2]['status'], CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[2]['publication_date'] != '', True)

        self.assertEqual(submissions[0]['id_remote'], '12340097')
        self.assertEqual(submissions[0]['status'], CFG_SUBMISSION_STATUS_REMOVED)
        self.assertEqual(submissions[0]['removal_date'] != '', True)

        self.assertEqual(modifications[1], submissions[0]['id'])
        self.assertEqual(modifications[0], submissions[1]['id'])


        for id_test in id_tests:
            delete_from_swr_clientdata(id_test)
    def test_update_submission(self):
        '''Test_insert_submission - check update submission rows in swrCLIENTDATA'''

        update_submission_status(self.id_tests[0],
                                 CFG_SUBMISSION_STATUS_SUBMITTED)
        update_submission_status(self.id_tests[1],
                                 CFG_SUBMISSION_STATUS_PUBLISHED, '1007.0221')
        update_submission_status(self.id_tests[2],
                                 CFG_SUBMISSION_STATUS_REMOVED)

        rows = run_sql('''SELECT id, id_swrREMOTESERVER, id_record, report_no,
                       id_remote, id_user, user_name, user_email, xml_media_deposit,
                       xml_metadata_submit, submission_date, publication_date, removal_date,
                       link_medias, link_metadata, link_status, status, last_update
                       FROM swrCLIENTDATA''')
        for row in rows:
            self.assertEqual(row[0] in self.id_tests, True)
            if row[0] == self.id_tests[0]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 97)
                self.assertEqual(row[4], '10030148')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/10030148')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/10030148.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/10030148')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_SUBMITTED)

            if row[0] == self.id_tests[1]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '1007.0221')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/10070221')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/10070221.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/10070221')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_PUBLISHED)

            if row[0] == self.id_tests[2]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '12340097')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/12340097')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/12340097.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/12340097')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_REMOVED)
    def test_update_submission(self):
        '''Test_insert_submission - check update submission rows in swrCLIENTDATA'''

        update_submission_status(self.id_tests[0],
                                 CFG_SUBMISSION_STATUS_SUBMITTED)
        update_submission_status(self.id_tests[1],
                                 CFG_SUBMISSION_STATUS_PUBLISHED, '1007.0221')
        update_submission_status(self.id_tests[2],
                                 CFG_SUBMISSION_STATUS_REMOVED)

        rows = run_sql('''SELECT * FROM swrCLIENTDATA''')
        for row in rows:
            self.assertEqual(row[0] in self.id_tests, True)
            if row[0] == self.id_tests[0]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 97)
                self.assertEqual(row[4], '10030148')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/10030148')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/10030148.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/10030148')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_SUBMITTED)

            if row[0] == self.id_tests[1]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '1007.0221')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/10070221')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/10070221.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/10070221')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_PUBLISHED)

            if row[0] == self.id_tests[2]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '12340097')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13],
                                 'https://arxiv.org/sword-app/edit/12340097')
                self.assertEqual(
                    row[14], 'https://arxiv.org/sword-app/edit/12340097.atom')
                self.assertEqual(row[15],
                                 'http://arxiv.org/resolve/app/12340097')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_REMOVED)
    def test_update_submission(self):
        '''Test_insert_submission - check update submission rows in swrCLIENTDATA'''

        update_submission_status(self.id_tests[0], CFG_SUBMISSION_STATUS_SUBMITTED)
        update_submission_status(self.id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED, '1007.0221')
        update_submission_status(self.id_tests[2], CFG_SUBMISSION_STATUS_REMOVED)

        rows = run_sql('''SELECT id, id_swrREMOTESERVER, id_record, report_no,
                       id_remote, id_user, user_name, user_email, xml_media_deposit,
                       xml_metadata_submit, submission_date, publication_date, removal_date,
                       link_medias, link_metadata, link_status, status, last_update
                       FROM swrCLIENTDATA''')
        for row in rows:
            self.assertEqual(row[0] in self.id_tests, True)
            if row[0] == self.id_tests[0]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 97)
                self.assertEqual(row[4], '10030148')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/10030148')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/10030148.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/10030148')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_SUBMITTED)

            if row[0] == self.id_tests[1]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '1007.0221')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/10070221')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/10070221.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/10070221')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_PUBLISHED)

            if row[0] == self.id_tests[2]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '12340097')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/12340097')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/12340097.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/12340097')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_REMOVED)
    def test_update_submission(self):
        """Test_insert_submission - check update submission rows in swrDATA"""

        update_submission_status(self.id_tests[0], CFG_SUBMISSION_STATUS_SUBMITTED)
        update_submission_status(self.id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED, "1007.0221")
        update_submission_status(self.id_tests[2], CFG_SUBMISSION_STATUS_REMOVED)

        rows = run_sql("""SELECT * FROM swrDATA""")

        for row in rows:
            self.assertEqual(row[0] in self.id_tests, True)
            if row[0] == self.id_tests[0]:
                self.assertEqual(row[1], 4)
                self.assertEqual(row[2], 97)
                self.assertEqual(row[4], 1)
                self.assertEqual(row[3], "10030148")
                self.assertEqual(row[10], "https://arxiv.org/sword-app/edit/10030148")
                self.assertEqual(row[11], "https://arxiv.org/sword-app/edit/10030148.atom")
                self.assertEqual(row[12], "http://arxiv.org/resolve/app/10030148")
                self.assertEqual(row[13], CFG_SUBMISSION_STATUS_SUBMITTED)

            if row[0] == self.id_tests[1]:
                self.assertEqual(row[1], 4)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], 2)
                self.assertEqual(row[3], "1007.0221")
                self.assertEqual(row[10], "https://arxiv.org/sword-app/edit/10070221")
                self.assertEqual(row[11], "https://arxiv.org/sword-app/edit/10070221.atom")
                self.assertEqual(row[12], "http://arxiv.org/resolve/app/10070221")
                self.assertEqual(row[13], CFG_SUBMISSION_STATUS_PUBLISHED)

            if row[0] == self.id_tests[2]:
                self.assertEqual(row[1], 3)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], 2)
                self.assertEqual(row[3], "12340097")
                self.assertEqual(row[10], "https://arxiv.org/sword-app/edit/12340097")
                self.assertEqual(row[11], "https://arxiv.org/sword-app/edit/12340097.atom")
                self.assertEqual(row[12], "http://arxiv.org/resolve/app/12340097")
                self.assertEqual(row[13], CFG_SUBMISSION_STATUS_REMOVED)
    def test_update_submission(self):
        '''Test_insert_submission - check update submission rows in swrCLIENTDATA'''

        update_submission_status(self.id_tests[0], CFG_SUBMISSION_STATUS_SUBMITTED)
        update_submission_status(self.id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED, '1007.0221')
        update_submission_status(self.id_tests[2], CFG_SUBMISSION_STATUS_REMOVED)

        rows = run_sql('''SELECT * FROM swrCLIENTDATA''')
        for row in rows:
            self.assertEqual(row[0] in self.id_tests, True)
            if row[0] == self.id_tests[0]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 97)
                self.assertEqual(row[4], '10030148')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/10030148')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/10030148.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/10030148')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_SUBMITTED)

            if row[0] == self.id_tests[1]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '1007.0221')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/10070221')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/10070221.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/10070221')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_PUBLISHED)

            if row[0] == self.id_tests[2]:
                self.assertEqual(row[1], 1)
                self.assertEqual(row[2], 92)
                self.assertEqual(row[4], '12340097')
                self.assertEqual(row[8], 'test_media_deposit')
                self.assertEqual(row[13], 'https://arxiv.org/sword-app/edit/12340097')
                self.assertEqual(row[14], 'https://arxiv.org/sword-app/edit/12340097.atom')
                self.assertEqual(row[15], 'http://arxiv.org/resolve/app/12340097')
                self.assertEqual(row[16], CFG_SUBMISSION_STATUS_REMOVED)
    def test_list_submitted_resources(self):
        """Test_list_submitted_resources - check the data selection and update for admin interface"""

        id_tests = []

        id_tests.append(
            insert_into_swr_clientdata(
                4,
                97,
                1,
                "test",
                "test",
                "10030148",
                "https://arxiv.org/sword-app/edit/10030148",
                "https://arxiv.org/sword-app/edit/10030148.atom",
                "http://arxiv.org/resolve/app/10030148",
            )
        )

        time.sleep(1)

        id_tests.append(
            insert_into_swr_clientdata(
                4,
                97,
                1,
                "test",
                "test",
                "10030148",
                "https://arxiv.org/sword-app/edit/10030148",
                "https://arxiv.org/sword-app/edit/10030148.atom",
                "http://arxiv.org/resolve/app/10030148",
            )
        )

        update_submission_status(id_tests[1], CFG_SUBMISSION_STATUS_PUBLISHED, "1003.0148")

        time.sleep(1)

        id_tests.append(
            insert_into_swr_clientdata(
                3,
                92,
                2,
                "test",
                "test",
                "12340097",
                "https://arxiv.org/sword-app/edit/12340097",
                "https://arxiv.org/sword-app/edit/12340097.atom",
                "http://arxiv.org/resolve/app/12340097",
            )
        )

        time.sleep(1)

        (submissions, modifications) = list_submitted_resources(0, 10, "")

        self.assertEqual(len(submissions), 3)
        self.assertEqual(len(modifications), 2)

        self.assertEqual(submissions[1]["id_remote"], "1003.3743")
        self.assertEqual(submissions[1]["status"], CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[1]["publication_date"] != "", True)

        self.assertEqual(submissions[2]["id_remote"], "1003.0148")
        self.assertEqual(submissions[2]["status"], CFG_SUBMISSION_STATUS_PUBLISHED)
        self.assertEqual(submissions[2]["publication_date"] != "", True)

        self.assertEqual(submissions[0]["id_remote"], "12340097")
        self.assertEqual(submissions[0]["status"], CFG_SUBMISSION_STATUS_REMOVED)
        self.assertEqual(submissions[0]["removal_date"] != "", True)

        self.assertEqual(modifications[1], submissions[0]["id"])
        self.assertEqual(modifications[0], submissions[1]["id"])

        for id_test in id_tests:
            delete_from_swr_clientdata(id_test)