Skip to content

diogosimao/b2blue-test

Repository files navigation

b2blue-test

The goal is the get csv file via web page, parse it and get provide a page for graphics.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Things you need to have installed:

or

  • pipenv
  • Python3
  • PostgreSQL

Installing

This is a quick project setup for local machine and development purpose to get server up at http://0.0.0.0:8000/.

  • Clone this repo.

      $ git clone git@github.com:diogosimao/b2blue-test.git b2blue-test
    
  • Create a virtual environment. Make sure you have pipenv installed.

      $ cd b2blue-test
    
      $ pipenv --three && pipenv shell
    

Choose docker or continue with pipenv setup mode

If docker:

It will need some extras. See requirements_docker.txt

    $ pip install -r requirements_docker.txt
    
    $ . ./bin/start-docker-development-server.sh
If pipenv
  • Create database on PostgreSQL

      $ createdb b2blue-test
    
  • With a shortcut just edit ./bin/start-development-server.sh with your DB system info and run the shell script.

  • Or without the script follow ahead with:

      $ pip install -r requirements.txt
    
    • Set DATABASE_URL environment variable:

        $ export DATABASE_URL=pgsql://YOUR_USER:YOUR_PWD@127.0.0.1:5432/b2blue-test
      
    • Run Django makemigration and migrate:

        $ python manage.py makemigrations
        $ python manage.py migrate
      
    • Run the development server

        $ python manage.py runserver
      

Django background tasks

Required setup (must)

  • Necessary command:

      $ python manage.py process_tasks
    
    • It must be executed on second instance of a unix shell (with the same previously created environment pipenv and with required enviroment variables)
  • Or in the same docker container running development server.

    • Sample:

        $ docker exec -it <DJANGO_CONTAINER_ID> /bin/bash
        
        $ python manage.py process_tasks
      

Administration Screen

  • Shell

    • Create superuser with the following line:

        $ python manage.py createsuperuser
      
  • Docker

    • In the same docker container running development server.

      • Sample:

        $ docker exec -it <DJANGO_CONTAINER_ID> /bin/bash
        
        $ python manage.py createsuperuser
        

Default Django administration screen should be up at http://0.0.0.0:8000/admin and you are able to login in.

Running the tests

From b2blue-test directory with pipenv --three and pipenv shell previously executed:

$ pip install -r requirements.txt

Unittests

To run the unittests for this system locally:

$ python manage.py test

In case you want to see code coverage the htmlcov folder (which contains html output from coverage package) will be created after running:

$ . ./bin/run-tests.sh

Functional tests

Do you have geckodrive install for Firefox? If not see jq.

After than install it with:

$ . ./bin/geckodrive-install.sh

and

$ python tests/functional/tests.py

Built With

Author

  • Diogo Simão

Acknowledgments

  • B2Blue.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published