Skip to content
bug-rancher edited this page Feb 13, 2020 · 8 revisions

Collaborative platform

Elasticsearch

Installation

Ubuntu 18.04

Install and run Elasticsearch according to this article: https://linuxize.com/post/how-to-install-elasticsearch-on-ubuntu-18-04/

Initialization

  • If you use Virtualenv, activate it:

    $ source path/to/virtualenv/bin/activate
    
  • Run Django shell:

    $ cd path/to/project/collaborative-platform/src/collaborative_platform/
    $ python manage.py shell
    
  • Copy whole content from .../apps/index_and_search/initialize.py, paste it in Django shell and Enter.

SSL on localhost

It's necessary only for test login to Collaborative Platform by Facebook on local machine. If you don't use this function (login by Google or ORCID will work), you can skip this point.

  • If you use Virtualenv, activate it:

    $ source path/to/virtualenv/bin/activate
    
  • Install necessary packages:

    $ pip install django-extensions Werkzeug pyOpenSSL service_identity
    
  • Add django_extensions to INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        'django_extensions',
    ]
    
  • Instead default runserver command, start server with command:

    $ python manage.py runserver_plus --cert-file /tmp/cert
    
  • Now you can visit Collaborative Platform on https://localhost:8000/

Periodical tasks

To start executing periodic tasks, you need to run Celery Beat:

  1. In console go to collaborative-platform/src/collaborative_platform/ directory
  2. Run in console:
    celery -A collaborative_platform worker -B -l DEBUG -E
    

Testing

Directories

All tests for each app should be in tests/ directory, inside main folder of the app, e.g. tests for:

close_reading

app should be in:

.../collaborative-platform/apps/close_reading/tests/

directory. Each category of tests should be in proper subdirectory, e.g. unit tests should be in

.../close_reading/tests/unit_tests/`

subdirectory.

Testing framework

All tests should be written with pytest framework.

Running tests

To run all tests, go to collaborative-platform/src/collaborative_platform/ directory and run:

pytest

Pytest marks

Assumed three marks, to help run certain set tests:

  • unit_tests
  • integration_tests
  • functional_tests

To run tests marked with specific mark, e.g. unit_tests run:

pytest -m unit_tests