Skip to content

Commit 4676dc4

Browse files
committed
feat: TT-401 Implemented service, end-point, dao, test- time entries
1 parent 5f107f3 commit 4676dc4

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import json
2+
import pytest
3+
import typing
4+
5+
from faker import Faker
6+
7+
from time_tracker.time_entries._infrastructure import TimeEntriesJsonDao
8+
from time_tracker.time_entries._domain import TimeEntry
9+
10+
11+
@pytest.fixture(name="create_fake_time_entries")
12+
def _create_fake_time_entries(mocker) -> typing.List[TimeEntry]:
13+
def _creator(time_entries):
14+
read_data = json.dumps(time_entries)
15+
mocker.patch("builtins.open", mocker.mock_open(read_data=read_data))
16+
return [TimeEntry(**time_entry) for time_entry in time_entries]
17+
18+
return _creator
19+
20+
21+
def test_create_time_entry__returns_an_time_entry_dto__when_create_an_time_entry_that_matches_attributes(
22+
create_fake_time_entries,
23+
):
24+
create_fake_time_entries([])
25+
26+
time_entries_json_dao = TimeEntriesJsonDao(Faker().file_path())
27+
time_entry_data = {
28+
"id" : None,
29+
"start_date" : Faker().date(),
30+
"owner_id" : Faker().random_int(),
31+
"description": Faker().sentence(),
32+
"activity_id" : Faker().random_int(),
33+
"uri": "http://hola.com",
34+
"technologies" : ["jira","git"],
35+
"end_date": Faker().date(),
36+
"deleted": Faker().random_int(),
37+
"timezone_offset": "UTC-5",
38+
"project_id": Faker().random_int(),
39+
}
40+
result = time_entries_json_dao.create(time_entry_data)
41+
assert result == TimeEntry(**time_entry_data)
42+
43+
44+
45+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[{
2+
"id": null,
3+
"start_date": "12/07/2021",
4+
"owner_id": 2,
5+
"tenant_id": "asdasdsa",
6+
"description": "No se que poner jajaj ",
7+
"activity_id": 2,
8+
"uri": "http://hola.que.hace.com",
9+
"technologies": ["git", "jira", "python"],
10+
"end_date": "12/07/2021",
11+
"deleted": "asdasdsaadssa",
12+
"timezone_offset": "asdasdsa",
13+
"project_id": 1
14+
}, {
15+
"id": null,
16+
"start_date": "12/07/2021",
17+
"owner_id": 2,
18+
"tenant_id": "asdasdsa",
19+
"description": "No se que poner jajaj ",
20+
"activity_id": 2,
21+
"uri": "http://hola.que.hace.com",
22+
"technologies": ["git", "jira", "python"],
23+
"end_date": "12/07/2021",
24+
"deleted": "asdasdsaadssa",
25+
"timezone_offset": "asdasdsa",
26+
"project_id": 1
27+
}, {
28+
"id": null,
29+
"start_date": "12/07/2021",
30+
"owner_id": 2,
31+
"tenant_id": "asdasdsa",
32+
"description": "No se que poner jajaj ",
33+
"activity_id": 2,
34+
"uri": "http://hola.que.hace.com",
35+
"technologies": ["git", "jira", "python"],
36+
"end_date": "12/07/2021",
37+
"deleted": "asdasdsaadssa",
38+
"timezone_offset": "asdasdsa",
39+
"project_id": 1
40+
}, {
41+
"id": null,
42+
"start_date": "12/07/2021",
43+
"owner_id": 2,
44+
"tenant_id": "asdasdsa",
45+
"description": "No se que poner jajaj ",
46+
"activity_id": 2,
47+
"uri": "http://hola.que.hace.com",
48+
"technologies": ["git", "jira", "python"],
49+
"end_date": "12/07/2021",
50+
"deleted": "asdasdsaadssa",
51+
"timezone_offset": "asdasdsa",
52+
"project_id": 1
53+
}, {
54+
"id": null,
55+
"start_date": "12/07/2021",
56+
"owner_id": 2,
57+
"tenant_id": "asdasdsa",
58+
"description": "No se que poner jajaj ",
59+
"activity_id": 2,
60+
"uri": "http://hola.que.hace.com",
61+
"technologies": ["git", "jira", "python"],
62+
"end_date": "12/07/2021",
63+
"deleted": "asdasdsaadssa",
64+
"timezone_offset": "asdasdsa",
65+
"project_id": 1
66+
}, {
67+
"id": null,
68+
"start_date": "12/07/2021",
69+
"owner_id": 2,
70+
"tenant_id": "asdasdsa",
71+
"description": "No se que poner jajaj ",
72+
"activity_id": 2,
73+
"uri": "http://hola.que.hace.com",
74+
"technologies": ["git", "jira", "python"],
75+
"end_date": "12/07/2021",
76+
"deleted": "asdasdsaadssa",
77+
"timezone_offset": "asdasdsa",
78+
"project_id": 1
79+
}, {
80+
"id": null,
81+
"start_date": "12/07/2021",
82+
"owner_id": 2,
83+
"tenant_id": "asdasdsa",
84+
"description": "No se que poner jajaj ",
85+
"activity_id": 2,
86+
"uri": "http://hola.que.hace.com",
87+
"technologies": ["git", "jira", "python"],
88+
"end_date": "12/07/2021",
89+
"deleted": "asdasdsaadssa",
90+
"timezone_offset": "asdasdsa",
91+
"project_id": 1
92+
}]

0 commit comments

Comments
 (0)