コード例 #1
0
    os.environ['PGPASSWORD'] = pgpassword
    os.environ['PGUSER'] = pguser

    parser = argparse.ArgumentParser(
        description='Run tests on the Web2Py Runestone server.')
    parser.add_argument(
        '--rebuildgrades',
        action='store_true',
        help='Reset the unit test based on current grading code.')
    parser.add_argument('--skipdbinit',
                        action='store_true',
                        help='Skip initialization of the test database.')
    parsed_args = parser.parse_args()

    if parsed_args.rebuildgrades:
        with pushd('../../..'):
            print("recalculating grades tables")
            xqt('{} web2py.py -S runestone -M -R applications/runestone/tests/make_clean_db_with_grades.py'
                .format(sys.executable))
            print("dumping the data")
            xqt('pg_dump --no-owner runestone_test > applications/runestone/tests/runestone_test.sql'
                )
        sys.exit(0)

    if parsed_args.skipdbinit:
        print('Skipping DB initialization.')
    else:
        # make sure runestone_test is nice and clean
        xqt('dropdb --echo --if-exists "{}"'.format(dbname),
            'createdb --echo "{}"'.format(dbname),
            'psql "{}" < runestone_test.sql'.format(dbname))
コード例 #2
0
ファイル: run_tests.py プロジェクト: SalasC2/RunestoneServer
        # tables that web2py will then re-create.
        xqt('rsmanage --verbose initdb --reset --force')

        # Copy the test book to the books directory.
        rmtree('../books/test_course_1', ignore_errors=True)
        # Sometimes this fails for no good reason on Windows. Retry.
        for retry in range(100):
            try:
                copytree('test_course_1', '../books/test_course_1')
                break
            except WindowsError:
                if retry == 99:
                    raise
        # Build the test book to add in db fields needed.
        #xqt('rsmanage addcourse --course-name=test_course_1 --basecourse=test_course_1')
        with pushd('../books/test_course_1'):
            # The runestone build process only looks at ``DBURL``.
            os.environ['DBURL'] = os.environ['TEST_DBURL']
            xqt('{} -m runestone build --all'.format(sys.executable),
                '{} -m runestone deploy'.format(sys.executable))

    with pushd('../../..'):
        if extra_args:
            print(extra_args)
            print('Passing the additional arguments {} to pytest.'.format(
                ' '.join(extra_args)))
        # Now run tests.
        test_files = [
            "test_server.py", "test_admin.py", "test_dashboard.py",
            "test_ajax2.py", "test_designer.py", "test_autograder.py"
        ]
コード例 #3
0
ファイル: run_tests.py プロジェクト: hangde01/RunestoneServer
    # Extract the components of the DBURL. The expected format is ``postgresql://user:password@netloc/dbname``, a simplified form of the `connection URI <https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-CONNSTRING>`_.
    empty1, postgres_ql, pguser, pgpassword, pgnetloc, dbname, empty2 = re.split('^postgres(ql)?://(.*):(.*)@(.*)/(.*)$', os.environ['TEST_DBURL'])
    assert (not empty1) and (not empty2)
    os.environ['PGPASSWORD'] = pgpassword
    os.environ['PGUSER'] = pguser

    parser = argparse.ArgumentParser(description='Run tests on the Web2Py Runestone server.')
    parser.add_argument('--rebuildgrades', action='store_true',
        help='Reset the unit test based on current grading code.')
    parser.add_argument('--skipdbinit', action='store_true',
        help='Skip initialization of the test database.')
    # Per https://docs.python.org/2/library/argparse.html#partial-parsing, gather any known args. These will be passed to pytest.
    parsed_args, extra_args = parser.parse_known_args()

    if parsed_args.rebuildgrades:
        with pushd('../../..'):
            print("recalculating grades tables")
            xqt('{} web2py.py -S runestone -M -R applications/runestone/tests/make_clean_db_with_grades.py'.format(sys.executable))
            print("dumping the data")
            xqt('pg_dump --no-owner runestone_test > applications/runestone/tests/runestone_test.sql')
        sys.exit(0)

    if parsed_args.skipdbinit:
        print('Skipping DB initialization.')
    else:
        # make sure runestone_test is nice and clean.
        xqt('dropdb --echo --if-exists "{}"'.format(dbname),
            'createdb --echo "{}"'.format(dbname),
            'psql "{}" < runestone_test.sql'.format(dbname))
        # Build the test book to add in db fields needed.
        with pushd('test_book'):
コード例 #4
0
    os.environ['PGPASSWORD'] = pgpassword
    os.environ['PGUSER'] = pguser

    parser = argparse.ArgumentParser(
        description='Run tests on the Web2Py Runestone server.')
    parser.add_argument(
        '--rebuildgrades',
        action='store_true',
        help='Reset the unit test based on current grading code.')
    parser.add_argument('--skipdbinit',
                        action='store_true',
                        help='Skip initialization of the test database.')
    parsed_args = parser.parse_args()

    if parsed_args.rebuildgrades:
        with pushd('../../..'):
            print("recalculating grades tables")
            xqt('{} web2py.py -S runestone -M -R applications/runestone/tests/make_clean_db_with_grades.py'
                .format(sys.executable))
            print("dumping the data")
            xqt('pg_dump --no-owner runestone_test > applications/runestone/tests/runestone_test.sql'
                )
        sys.exit(0)

    if parsed_args.skipdbinit:
        print('Skipping DB initialization.')
    else:
        # make sure runestone_test is nice and clean
        xqt('dropdb --echo --if-exists "{}"'.format(dbname),
            'createdb --echo "{}"'.format(dbname),
            'psql "{}" < runestone_test.sql'.format(dbname))