|
9 | 9 | * _PyTest_
|
10 | 10 |
|
11 | 11 |
|
12 |
| -## Some commands for comfortable run: |
13 |
| - |
14 |
| -#### To run tests (pytest) |
| 12 | +## _Some commands for comfortable run:_ |
| 13 | +### • To test: |
| 14 | +#### To run tests [pytest]: |
15 | 15 | 1. Activate venv
|
16 | 16 | 2. `pip install -r requirements.txt`
|
17 | 17 | 3. `coverage run -m pytest`
|
18 | 18 | 4. `coverage report` or `coverage html` (for generating report in HTML)
|
19 |
| -5. Remove `coverage-badge.svg` file and run `coverage-badge -o coverage.svg` |
20 |
| - |
| 19 | +5. Remove `coverage-badge.svg` file and run `coverage-badge -o coverage.svg` |
| 20 | + |
| 21 | +#### To run tests [unittest from task-source]: |
| 22 | +1. `pip install -r requirements.txt` |
| 23 | +2. Run server in Docker (see below how to run in docker) or in usual way () |
| 24 | +3. `python unit_test.py` |
21 | 25 |
|
22 |
| -#### To run application locally (you must have PostgreSQL installed and set up): |
| 26 | +### • To launch: |
| 27 | +#### To run application locally [no Docker] (you must have PostgreSQL installed and set up): |
23 | 28 | 1. Activate venv
|
24 | 29 | 2. `pip install -r requirements.txt`
|
25 | 30 | 3. Change `DOCKER` field in `config.json` to `false`
|
26 | 31 | 4. `python manage.py makemigrations`
|
27 | 32 | 5. `python manage.py migrate`
|
28 |
| -6. `python manage.py runserver localhost:80` (or other port) |
29 |
| - |
30 |
| -#### To set up remote machine: |
31 |
| -1. Connect to remote machine (via SSH) |
32 |
| -2. `sudo git clone <this_repo_url>` |
33 |
| -3. `cd rest-api-test-task` |
34 |
| -4. `sudo python3 -m venv venv` |
35 |
| -5. `source venv/bin/activate` |
36 |
| -6. `sudo pip3 install -r requirements.txt` |
37 |
| -7. [Auto running:](https://winitpro.ru/index.php/2019/10/11/avtozagruzka-servisov-i-skriptov-v-linux/) |
38 |
| -8. `sudo touch /etc/systemd/system/test-script.service` |
39 |
| -9. `sudo chmod 664 /etc/systemd/system/test-script.service` |
40 |
| -10. `sudo nano /etc/systemd/system/test-script.service` |
41 |
| -11. Write file |
42 |
| -12. Write entry-point SH executor |
43 |
| -13. `sudo systemctl enable test-script.service` |
| 33 | +6. `python manage.py runserver 0.0.0.0:80` (or other port, for example) |
| 34 | + |
| 35 | +#### To run application locally [with Docker] (build & run) |
| 36 | +1. `docker-compose up -d --build` |
| 37 | +2. `docker-compose exec web python manage.py makemigrations --noinput` |
| 38 | +3. `docker-compose exec web python manage.py migrate --noinput` |
| 39 | +4. [optional] `docker-compose exec web python manage.py createsuperuser` |
| 40 | +5. `docker-compose up` |
| 41 | + |
| 42 | +### • To deploy: |
| 43 | +#### To set up remote machine: |
| 44 | +1. Set `docker` field to `true`/`false` (depending on if you're going to run in Docker) |
| 45 | +2. Push changes to GitHub repository `git add <...>`, `git commit -m <...>`, `git push` |
| 46 | +3. Connect to remote machine (via SSH) `ssh login@ip`. Following actions are done from remote machine |
| 47 | +4. `git clone <this_repo_url>` |
| 48 | +5. `cd rest-api-test-task` |
| 49 | +6. For non-Docker run: |
| 50 | + 1. `python3 -m venv venv` |
| 51 | + 2. `source venv/bin/activate` |
| 52 | + 3. `pip3 install -r requirements.txt` |
| 53 | + 4. `python3 manage.py makemigrations` |
| 54 | + 5. `python3 manage.py migrate` |
| 55 | +7. For Docker-run: |
| 56 | + 1. `docker-compose up -d --build` |
| 57 | + 2. `docker-compose exec web python manage.py makemigrations --noinput` |
| 58 | + 3. `docker-compose exec web python manage.py migrate --noinput` |
| 59 | + 4. [optional] `docker-compose exec web python manage.py createsuperuser` |
| 60 | +8. [Auto running:](https://winitpro.ru/index.php/2019/10/11/avtozagruzka-servisov-i-skriptov-v-linux/) |
| 61 | +9. `sudo touch /etc/systemd/system/test-script.service` |
| 62 | +10. `sudo chmod 664 /etc/systemd/system/test-script.service` |
| 63 | +11. `sudo nano /etc/systemd/system/test-script.service` |
| 64 | +12. Write file |
| 65 | +13. Write entry-point SH executor (for running with or without Docker) |
| 66 | +14. `sudo systemctl enable test-script.service` |
44 | 67 |
|
45 | 68 |
|
46 | 69 |
|
|
0 commit comments