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_zdelete_submission(self):
        """Test_insert_submission - check delete submission rows in swrDATA"""

        nb_rows_before = run_sql("""SELECT COUNT(*) FROM swrDATA""")[0][0]

        for id_test in self.id_tests:
            delete_from_swr_clientdata(id_test)

        nb_rows_after = run_sql("""SELECT COUNT(*) FROM swrDATA""")[0][0]

        nb_rows = nb_rows_before - nb_rows_after

        self.assertEqual(nb_rows, 3)
    def test_zdelete_submission(self):
        '''test_delete_submission - check delete submission rows in swrCLIENTDATA'''

        nb_rows_before = run_sql('''SELECT COUNT(*) FROM swrCLIENTDATA''')[0][0]

        for id_test in self.id_tests:
            delete_from_swr_clientdata(id_test)

        nb_rows_after = run_sql('''SELECT COUNT(*) FROM swrCLIENTDATA''')[0][0]

        nb_rows = nb_rows_before - nb_rows_after

        self.assertEqual(nb_rows, 3)
    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_zdelete_submission(self):
        '''test_delete_submission - check delete submission rows in swrCLIENTDATA'''

        nb_rows_before = run_sql(
            '''SELECT COUNT(*) FROM swrCLIENTDATA''')[0][0]

        for id_test in self.id_tests:
            delete_from_swr_clientdata(id_test)

        nb_rows_after = run_sql('''SELECT COUNT(*) FROM swrCLIENTDATA''')[0][0]

        nb_rows = nb_rows_before - nb_rows_after

        self.assertEqual(nb_rows, 3)
    def test_perform_submission_process(self):
        """Test_perform_submission_process - test document submission"""

        metadata = {}
        metadata["primary_label"] = "Test - Test Disruptive Networks"
        metadata["primary_url"] = "http://arxiv.org/terms/arXiv/test.dis-nn"

        user_info = {}
        user_info["nickname"] = "test_user"
        user_info["email"] = "*****@*****.**"
        user_info["id"] = 1

        result = perform_submission_process(4, "https://arxiv.org/sword-app/test-collection", 97, user_info, metadata)

        self.assertEqual(open("/tmp/media.xml", "r").read() != "", True)
        self.assertEqual(open("/tmp/metadata.xml", "r").read() != "", True)
        self.assertEqual(open("/tmp/submit.xml", "r").read() != "", True)

        if result["row_id"] != "":
            delete_from_swr_clientdata(result["row_id"])
    def test_perform_submission_process(self):
        '''Test_perform_submission_process - test document submission'''

        metadata = {}
        metadata['primary_label'] = 'Test - Test Disruptive Networks'
        metadata['primary_url'] = 'http://arxiv.org/terms/arXiv/test.dis-nn'

        user_info = {}
        user_info['nickname'] = 'test_user'
        user_info['email'] = '*****@*****.**'
        user_info['id'] = 1

        result = perform_submission_process(
            4, 'https://arxiv.org/sword-app/test-collection', 97, user_info,
            metadata)

        self.assertEqual(open('/tmp/media.xml', 'r').read() != '', True)
        self.assertEqual(open('/tmp/metadata.xml', 'r').read() != '', True)
        self.assertEqual(open('/tmp/submit.xml', 'r').read() != '', True)

        if result['row_id'] != '':
            delete_from_swr_clientdata(result['row_id'])
    def test_perform_submission_process(self):
        '''Test_perform_submission_process - test document submission'''

        metadata = {}
        metadata['primary_label'] = 'Test - Test Disruptive Networks'
        metadata['primary_url'] = 'http://arxiv.org/terms/arXiv/test.dis-nn'

        user_info = {}
        user_info['nickname'] = 'test_user'
        user_info['email'] = '*****@*****.**'
        user_info['id'] = 1

        result = perform_submission_process(4, 'https://arxiv.org/sword-app/test-collection',
                                            97, user_info, metadata)

        self.assertEqual(open('/tmp/media.xml', 'r').read() != '', True)
        self.assertEqual(open('/tmp/metadata.xml', 'r').read() != '', True)
        self.assertEqual(open('/tmp/submit.xml', 'r').read() != '', True)



        if result['row_id'] != '':
            delete_from_swr_clientdata(result['row_id'])
    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)