Exemplo n.º 1
0
 def setUp(self):
     """Create an application instance."""
     self.app = create_ui_web_app()
     os.environ['JWT_SECRET'] = self.app.config.get('JWT_SECRET')
     _, self.db = tempfile.mkstemp(suffix='.db')
     self.app.config['CLASSIC_DATABASE_URI'] = f'sqlite:///{self.db}'
     self.client = self.app.test_client()
     with self.app.app_context():
         classic.create_all()
Exemplo n.º 2
0
 def setUp(self):
     """Create an application instance."""
     self.app = create_ui_web_app()
     os.environ['JWT_SECRET'] = self.app.config.get('JWT_SECRET')
     _, self.db = tempfile.mkstemp(suffix='.db')
     self.app.config['CLASSIC_DATABASE_URI'] = f'sqlite:///{self.db}'
     self.token = generate_token(
         '1234',
         '*****@*****.**',
         'foouser',
         scope=[
             scopes.CREATE_SUBMISSION, scopes.EDIT_SUBMISSION,
             scopes.VIEW_SUBMISSION, scopes.READ_UPLOAD,
             scopes.WRITE_UPLOAD, scopes.DELETE_UPLOAD_FILE
         ],
         endorsements=[
             Category('astro-ph.GA'),
             Category('astro-ph.CO'),
         ])
     self.headers = {'Authorization': self.token}
     self.client = self.app.test_client()
     with self.app.app_context():
         classic.create_all()
Exemplo n.º 3
0
import time
import logging

from arxiv.submission.services import classic
from arxiv.submission.services.classic import bootstrap
from arxiv.users.helpers import generate_token
from arxiv.users.auth import scopes
from submit.factory import create_ui_web_app

logging.getLogger('arxiv.submission.services.classic.interpolate') \
    .setLevel(logging.ERROR)
logging.getLogger('arxiv.base.alerts').setLevel(logging.ERROR)

logger = logging.getLogger(__name__)

app = create_ui_web_app()

with app.app_context():
    session = classic.current_session()
    engine = classic.util.current_engine()
    logger.info('Waiting for database server to be available')
    logger.info(app.config['SQLALCHEMY_DATABASE_URI'])
    wait = 2
    while True:
        try:
            session.execute('SELECT 1')
            break
        except Exception as e:
            logger.info(e)
            logger.info(f'...waiting {wait} seconds...')
            time.sleep(wait)
Exemplo n.º 4
0
    def setUp(self):
        """Create an application instance."""
        self.app = create_ui_web_app()
        os.environ['JWT_SECRET'] = self.app.config.get('JWT_SECRET')
        _, self.db = tempfile.mkstemp(suffix='.db')
        self.app.config['CLASSIC_DATABASE_URI'] = f'sqlite:///{self.db}'
        self.user = User('1234',
                         '*****@*****.**',
                         endorsements=['astro-ph.GA', 'astro-ph.CO'])
        self.token = generate_token(
            '1234',
            '*****@*****.**',
            'foouser',
            scope=[
                scopes.CREATE_SUBMISSION, scopes.EDIT_SUBMISSION,
                scopes.VIEW_SUBMISSION, scopes.READ_UPLOAD,
                scopes.WRITE_UPLOAD, scopes.DELETE_UPLOAD_FILE
            ],
            endorsements=[
                Category('astro-ph.GA'),
                Category('astro-ph.CO'),
            ])
        self.headers = {'Authorization': self.token}
        self.client = self.app.test_client()

        # Create and announce a submission.
        with self.app.app_context():
            classic.create_all()
            session = classic.current_session()

            cc0 = 'http://creativecommons.org/publicdomain/zero/1.0/'
            self.submission, _ = save(
                CreateSubmission(creator=self.user),
                ConfirmContactInformation(creator=self.user),
                ConfirmAuthorship(creator=self.user, submitter_is_author=True),
                SetLicense(creator=self.user,
                           license_uri=cc0,
                           license_name='CC0 1.0'),
                ConfirmPolicy(creator=self.user),
                SetPrimaryClassification(creator=self.user,
                                         category='astro-ph.GA'),
                SetUploadPackage(
                    creator=self.user,
                    checksum="a9s9k342900skks03330029k",
                    source_format=SubmissionContent.Format.TEX,
                    identifier=123,
                    uncompressed_size=593992,
                    compressed_size=59392,
                ), SetTitle(creator=self.user, title='foo title'),
                SetAbstract(creator=self.user, abstract='ab stract' * 20),
                SetComments(creator=self.user, comments='indeed'),
                SetReportNumber(creator=self.user, report_num='the number 12'),
                SetAuthors(creator=self.user,
                           authors=[
                               Author(order=0,
                                      forename='Bob',
                                      surname='Paulson',
                                      email='*****@*****.**',
                                      affiliation='Fight Club')
                           ]), FinalizeSubmission(creator=self.user))

            # announced!
            db_submission = session.query(classic.models.Submission) \
                .get(self.submission.submission_id)
            db_submission.status = classic.models.Submission.ANNOUNCED
            db_document = classic.models.Document(paper_id='1234.5678')
            db_submission.doc_paper_id = '1234.5678'
            db_submission.document = db_document
            session.add(db_submission)
            session.add(db_document)
            session.commit()

        self.submission_id = self.submission.submission_id
Exemplo n.º 5
0
"""Web Server Gateway Interface entry-point."""

from submit.factory import create_ui_web_app
import os
import logging

logging.getLogger('arxiv.submission.services.classic.interpolate') \
    .setLevel(logging.ERROR)
logging.getLogger('arxiv.base.alerts').setLevel(logging.ERROR)


__flask_app__ = create_ui_web_app()


def application(environ, start_response):
    """WSGI application factory."""
    global __flask_app__
    for key, value in environ.items():
        if key in __flask_app__.config and key != 'SERVER_NAME':
            __flask_app__.config[key] = value
            os.environ[key] = value
    return __flask_app__(environ, start_response)