Enhance installation

This commit is contained in:
Xavier Bustamante Talavera 2018-09-16 13:53:07 +02:00
parent 0c29497179
commit c9639a5eb8
7 changed files with 17 additions and 22 deletions

View File

@ -29,22 +29,14 @@ The requirements are:
Install Devicehub with *pip*: `pip3 install ereuse-devicehub -U --pre`.
## Running
Download, or copy the contents, of [this file](example/app.py), and
Download, or copy the contents, of [this file](examples/app.py), and
call the new file ``app.py``.
Create a PostgreSQL database called *devicehub*:
Create a PostgreSQL database called *devicehub* by running
[create-db](examples/create-db.sh):
```bash
sudo su - postgres # Change to Postgres main user
postgres $ createdb devicehub # Create main database
postgres $ psql devicehub # Access to the database
postgres $ CREATE USER dhub WITH PASSWORD 'ereuse'; # Create user devicehub uses to access db
postgres $ GRANT ALL PRIVILEGES ON DATABASE devicehub TO dhub; # Give access to the db
postgres $ CREATE EXTENSION pgcrypto SCHEMA public; # Enable pgcrypto
postgres $ CREATE EXTENSION ltree SCHEMA public; # Enable ltree
postgres $ \q
exit
```
- In Debian 9: `sudo su - postgres; examples/create-db.sh devicehub`
- In MacOS: `examples/create-db.sh devicehub`.
Create the tables in the database by executing in the same directory
where `app.py` is:
@ -89,13 +81,9 @@ Use postman as an example of how to use the API.
To run the tests you will need to:
1. `git clone` this project.
2. Create a database for testing. By default the database used is
`dh_test`. Execute to create it:
1. `postgres $ createdb dh_test`.
2. `postgres $ psql dh_test`.
3. `postgres $ GRANT ALL PRIVILEGES ON DATABASE dh_test TO dhub;`.
4. `CREATE EXTENSION pgcrypto SCHEMA public;`
5. `CREATE EXTENSION ltree SCHEMA public;`
2. Create a database for testing executing `create-db.sh` like
the normal installation but changing the first parameter
from `devicehub` to `dh_test`: `create-db.sh dh_test`.
3. Execute at the root folder of the project `python3 setup.py test`.
## Generating the docs

8
examples/create-db.sh Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Creates a database, user, and extensions to use Devicehub
createdb $1 # Create main database
psql -d $1 -c "CREATE USER dhub WITH PASSWORD 'ereuse';" # Create user devicehub uses to access db
psql -d $1 -c "GRANT ALL PRIVILEGES ON DATABASE devicehub TO dhub;" # Give access to the db
psql -d $1 -c "CREATE EXTENSION pgcrypto SCHEMA public;" # Enable pgcrypto
psql -d $1 -c "CREATE EXTENSION ltree SCHEMA public;" # Enable ltree

View File

@ -11,7 +11,6 @@ with open('ereuse_devicehub/__init__.py', 'rt', encoding='utf8') as f:
test_requires = [
'pytest',
'pytest-datadir',
'requests_mock'
]