This section is intended for developers new to the database who want to get up and running with a test instance quickly.
Before you start¶
You should have done the following things before starting to work on the database:
Running a test instance with fake data¶
Clone the repository and
cd to it. The remaining instructions assume
the repository root is the current working directory.
Create a virtualenv:
$ virtualenv -p $(which python2.7) env $ echo "env" >>.git/info/exclude # To avoid any accidental commits $ . env/bin/activate
Install the requirements:
$ pip install -r requirements.txt -r dev-requirements.txt
requirements.txt file lists the Python packages required for
dev-requirements.txt file lists the Python packages used
only by developers. For example, the “ipython” package, which is used to
shell_plus command, is in the
since it is not required when deploying the database.
Perform the initial database migration and populate the database with some fake data:
$ ./edpcmentoring/manage.py migrate $ ./edpcmentoring/manage.py runscript loadtestfixtures
Start a local development server:
$ ./edpcmentoring/manage.py runserver_plus
Installing on UIS MWS3 (https://panel.mws3.csx.cam.ac.uk/)¶
You will need:
- To register and create an MWS3 server (see link above)
- The root password for MySQL server (available once you MWS3 has been setup)
ssh onto your MWS3 server (via putty, or a linux/unix console), then:
$ cd /var/www/default/admindir $ git clone https://github.com/cuedpc/edpcmentoring.git $ python edpcmentoring/deploy/setup_mws.py
You will be asked for
- The server’s MySQL root password.
- A short name which will be prefixed by ‘pc_‘ and used as the database name
- A password the Django applicatoin will use to connect to the MySQL server
- A unique passphrase / secret key for your application
- Whether you wish to load the sample test data into the application
Once complete you should be able to visit the mws3’s host name and, if you have loaded the test data, login as test000X.
The local config is held in edpcmentoring/edpcmentoring/edpcmentoring/settings_local.py, and DEBUG is set to True - not advised for production systems.
Notes on the test database¶
- There is one superuser:
- The users
test0002can log into the admin interface.
test0099are members of CUED but not all are active.
test0199exist in the database but are not CUED members.
This section contains some important information if you’re thinking of developing a feature for the database.
The test suite for the mentoring database is run via the
tox test-runner. If
you’re intending to develop a feature for the database, it is important that you
write tests. By default,
tox will run tests using whichever Python version
correspond to the installed
tox via pip:
$ pip install --user tox
You can now run the tests via the
Any positional arguments are passed to the underlying invocation of
test and so you can specify a particular application to test by giving it’s
directory. For example:
$ tox edpcmentoring/cuedmembers
The tests are run under the
coverage code-coverage utility and files which
do not have 100% test coverage are printed out after the tests are run.
Additionally, a HTML report is generated in
htmlcov/ which is useful for
determining which lines are untested.
Although 100% code coverage is probably infeasible in general, we aim for as close as possible in the database. Pull requests which increase test code coverage are welcome.