Skip to content

Commit 12c1663

Browse files
committed
Merge remote-tracking branch 'origin/master' into TT-418-CRUD-CUSTOMER-V2
2 parents 6824013 + c8a3134 commit 12c1663

File tree

63 files changed

+1695
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1695
-72
lines changed

V2/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.PHONY: help
22
help:
33
@echo "---------------HELP-----------------"
4-
@echo "To install the dependencies type make install"
5-
@echo "To test the project type make test"
6-
@echo "To run the local database type make start-local"
7-
@echo "To run all comands type make ci"
4+
@echo "- make install --> Install the dependencies"
5+
@echo "- make test --> Run all tests"
6+
@echo "- make test specific_test=<name_of_the_test> --> Run specific test"
7+
@echo "- make start-local --> Run local database"
8+
@echo "- make ci --> Install the dependencies and run all tests"
89
@echo "------------------------------------"
910

1011
.PHONY: install
@@ -17,13 +18,16 @@ install:
1718

1819
.PHONY: test
1920
test: export ENVIRONMENT = test
20-
test: export TEST_DB_CONNECTION = sqlite:///:memory:
2121
test:
2222
@echo "=========================================Lint with flake8========================================="
2323
flake8 . --show-source --statistics
2424
@echo "Completed flake8!"
2525
@echo "=========================================Test with pytest========================================="
26-
python -m pytest -v
26+
@if [ "$(specific_test)" ]; then \
27+
python -m pytest -vv -s -k $(specific_test);\
28+
else \
29+
python -m pytest -v;\
30+
fi
2731
@echo "Completed test!"
2832

2933
start-local:

V2/README.md

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,108 @@
1-
# time-tracker-api V2
1+
# **Time-tracker-api V2 Architecture**
2+
Architecture
3+
The application follows a DDD approach with a hexagonal clean architecture. BIG WORDS!, what does it mean? it means the following:
24

3-
Refer to [Serverless docs](https://serverless.com/framework/docs/providers/azure/guide/intro/) for more information.
5+
We have a directory for each domain entitiy (i.e. time entries, technologies, activities, etc)
6+
Inside each entity directory we have other 3 directories (application, domain and infrastructure)
7+
I'll leave this drawing to understand how these three folders work and what logic should be included in these directories
48

5-
## Requirements to use makefile
9+
![ddd.png](https://raw.githubusercontent.com/eguezgustavo/time_tracker_app_skeleton/master/ddd.png)
10+
More information [Here](https://github.com/eguezgustavo/time_tracker_app_skeleton)
611

7-
- Python version 3.6 or 3.7.
12+
## **Stack Technologies**
13+
- [Serverless](https://serverless.com/framework/docs/providers/azure/guide/intro/)
14+
- Python
15+
- Pytest
16+
- Docker Compose
17+
18+
Recommended link [tdd_dojo](https://github.com/eguezgustavo/tdd_dojo)
819

9-
- Use an environment to install requirements (pyenv).
20+
## **Setup environment**
1021

11-
## How to use makefile
22+
### **Requeriments**
23+
24+
- Install python 3.6 or 3.7 (recommendation to install python [pyenv](https://github.com/pyenv/pyenv))
25+
- Install node (recommendation to install node [nvm](https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04-es#:~:text=de%20Node.js.-,Opci%C3%B3n%203%3A%20Instalar%20Node%20usando%20el%20administrador%20de%20versiones%20de%20Node,-Otra%20forma%20de))
26+
27+
### **Add variables**
28+
In the root directory /time-tracker-backend create a file .env with these values
29+
30+
```
31+
export MS_AUTHORITY=XXX
32+
export MS_CLIENT_ID=XXX
33+
export MS_SCOPE=XXX
34+
export MS_SECRET=XXX
35+
export MS_ENDPOINT=XXX
36+
export DATABASE_ACCOUNT_URI=XXX
37+
export DATABASE_MASTER_KEY=XXX
38+
export DATABASE_NAME=XXX
39+
export FLASK_APP=XXX
40+
export FLASK_ENV=XXX
41+
export AZURE_APP_CONFIGURATION_CONNECTION_STRING=XXX
42+
export USERID=XXX
43+
export FLASK_DEBUG=True
44+
export PYTHONPATH=XXX
45+
export DB_CONNECTION=XXX
46+
export ENVIRONMENT=XXX
47+
```
48+
49+
In the directory /V2 create a file .env with these values
50+
```
51+
DB_USER=XXX
52+
DB_PASS=XXX
53+
DB_NAME=XXX
54+
```
55+
56+
### **Install dependencies**
57+
In the Directory /V2
58+
```
59+
make install
60+
```
61+
62+
## **Start Project**
63+
In the directory /V2
64+
```
65+
npm run offline
66+
docker compose up or make start-local
67+
```
68+
69+
70+
## **Makefile to run a locally CI**
1271

1372
Execute the next command to show makefile help:
1473

1574
```shell
16-
make help
75+
$ make help
1776
```
1877

1978
- To install the dependencies type the command ```make install```
20-
2179
- To test the project type the command ```make test```
22-
2380
- To run the local database type the command ```make start-local```
81+
82+
## **How to contribute to the project**
83+
Clone the repository and from the master branch create a new branch for each new task.
84+
### **Branch names format**
85+
For example if your task in Jira is **TT-48 implement semantic versioning** your branch name is:
86+
```
87+
TT-48-implement-semantic-versioning
88+
```
89+
### **Commit messages format**
90+
91+
92+
Below there are some common examples you can use for your commit messages [semantic version](https://semver.org/) :
93+
94+
- **feat**: A new feature.
95+
- **fix**: A bug fix.
96+
- **perf**: A code change that improves performance.
97+
- **build**: Changes that affect the build system or external dependencies (example scopes: npm, ts configuration).
98+
- **ci**: Changes to our CI or CD configuration files and scripts (example scopes: Azure devops, github actions).
99+
- **docs**: Documentation only changes.
100+
- **refactor**: A code change that neither fixes a bug nor adds a feature.
101+
It is important to mention that this key is not related to css styles.
102+
- **test**: Adding missing tests or correcting existing tests.
103+
104+
### Example
105+
fix: TT-48 implement semantic versioning
106+
107+
Prefix to use in the space fix:
108+
`(fix: |feat: |perf: |build: |ci: |docs: |refactor: |style: |test: )`

V2/serverless.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ functions:
7272
- http: true
7373
x-azure-settings:
7474
methods:
75-
- PUT
75+
- PUT
7676
route: activities/{id}
77-
authLevel: anonymous
77+
authLevel: anonymous
7878

7979
create_activity:
8080
handler: time_tracker/activities/interface.create_activity
@@ -100,6 +100,16 @@ functions:
100100
route: time-entries/
101101
authLevel: anonymous
102102

103+
get_time_entries:
104+
handler: time_tracker/time_entries/interface.get_time_entries
105+
events:
106+
- http: true
107+
x-azure-settings:
108+
methods:
109+
- GET
110+
route: time-entries/{id:?}
111+
authLevel: anonymous
112+
103113
delete_time_entry:
104114
handler: time_tracker/time_entries/interface.delete_time_entry
105115
events:
@@ -110,6 +120,16 @@ functions:
110120
route: time-entries/{id}
111121
authLevel: anonymous
112122

123+
update_time_entry:
124+
handler: time_tracker/time_entries/interface.update_time_entry
125+
events:
126+
- http: true
127+
x-azure-settings:
128+
methods:
129+
- PUT
130+
route: time-entries/{id}
131+
authLevel: anonymous
132+
113133
#endregion end Time-Entries
114134

115135
#region start Customer
@@ -156,4 +176,4 @@ functions:
156176

157177
#endregion end Customer
158178

159-
#endregion end Functions
179+
#endregion end Functions

V2/tests/api/azure/activity_azure_endpoints_test.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def test__activity_azure_endpoint__returns_all_activities(
1717
insert_activity(existent_activities[1], test_db).__dict__
1818
]
1919

20-
azure_activities._get_activities.DATABASE = test_db
21-
2220
req = func.HttpRequest(method='GET', body=None, url=ACTIVITY_URL)
2321
response = azure_activities._get_activities.get_activities(req)
2422
activities_json_data = response.get_body().decode("utf-8")
@@ -33,7 +31,6 @@ def test__activity_azure_endpoint__returns_an_activity__when_activity_matches_it
3331
existent_activity = activity_factory()
3432
inserted_activity = insert_activity(existent_activity, test_db).__dict__
3533

36-
azure_activities._get_activities.DATABASE = test_db
3734
req = func.HttpRequest(
3835
method='GET',
3936
body=None,
@@ -54,7 +51,6 @@ def test__activity_azure_endpoint__returns_an_activity_with_inactive_status__whe
5451
existent_activity = activity_factory()
5552
inserted_activity = insert_activity(existent_activity, test_db).__dict__
5653

57-
azure_activities._delete_activity.DATABASE = test_db
5854
req = func.HttpRequest(
5955
method='DELETE',
6056
body=None,
@@ -76,7 +72,6 @@ def test__update_activity_azure_endpoint__returns_an_activity__when_found_an_act
7672
existent_activity = activity_factory()
7773
inserted_activity = insert_activity(existent_activity, test_db).__dict__
7874

79-
azure_activities._update_activity.DATABASE = test_db
8075
activity_body = {"description": Faker().sentence()}
8176
req = func.HttpRequest(
8277
method='PUT',

0 commit comments

Comments
 (0)