Application
Those instructions will make the project up and running on your local machine for development and testing purposes. See terraform section for notes on how to deploy the project on a live system.
Prerequisites¶
Before statring, you must install all dependencies below inside a centos-7 Linux environment
1- Install Python 3.6.8¶
yum install gcc openssl-devel bzip2-devel libffi-devel
cd /usr/src
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
tar xzf Python-3.6.8.tgz
cd Python-3.6.8
./configure --enable-optimizations
make altinstall
rm /usr/src/Python-3.6.8.tgz
python3 -V
2- Install virtualenv¶
3- Install the latest version of Docker¶
4- Install the Postgres Database¶
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql14-server
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
sudo systemctl enable postgresql-14
sudo systemctl start postgresql-14
5- Create Database, user and table¶
This instruction can be done using psql cli or pgAdmin
-- create database and user
CREATE DATABASE [DATABASE_NAME];
CREATE USER [USERNAME] WITH PASSWORD '[PASSWORD]';
GRANT CONNECT ON DATABASE [DATABASE_NAME] TO [USERNAME];
GRANT USAGE ON SCHEMA public TO [USERNAME];
GRANT all privileges on all tables in schema public TO [USERNAME];
-- create table
DROP TABLE IF EXISTS users;
CREATE TABLE users (
user_id serial PRIMARY KEY,
username VARCHAR UNIQUE,
date_of_birth DATE NOT NULL
);
5- Fill database config file¶
You must fill database.ini with resources created above.
Unit tests¶
Unit tests must be exectued inside a virtualenv.
1- Activate virtualenv¶
2- Install all requirements¶
3- Run unit tests¶
Service tests¶
Service tests must be executed inside a docker container
1- Build docker image¶
2- Run docker container¶
3- Tests endpoints¶
# Test PUT request:
curl -X PUT -H "Content-Type: application/json" \
-d '{"dateOfBirth":"2012-12-31"}' \
http://localhost:80/hello/jhon
# Test GET request :
curl -X 'GET' \
'http://localhost:80/hello/jhon' \
-H 'accept: application/json'
Authors¶
- Oussama BEN CHARRADA - Initial work