Skip to content

Commit bdd788d

Browse files
committed
fix: TT-401 implemented faker url
1 parent 03ca4df commit bdd788d

File tree

5 files changed

+63
-33
lines changed

5 files changed

+63
-33
lines changed

V2/tests/api/azure/time_entry_azure_endpoints_test.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from time_tracker.time_entries._application import _time_entries as time_entries
2-
from faker import Faker
32

43
import azure.functions as func
54
import json
@@ -9,24 +8,12 @@
98

109

1110
def test__time_entry_azure_endpoint__creates_an_time_entry__when_time_entry_has_all_attributes(
12-
create_temp_time_entries,
11+
create_temp_time_entries, time_entry_factory
1312
):
1413
time_entries_json, tmp_directory = create_temp_time_entries
1514
time_entries._create_time_entry._JSON_PATH = tmp_directory
1615

17-
time_entry_body = {
18-
"id": None,
19-
"start_date": Faker().date(),
20-
"owner_id": Faker().random_int(),
21-
"description": Faker().sentence(),
22-
"activity_id": Faker().random_int(),
23-
"uri": "http://timetracker.com",
24-
"technologies": ["jira", "git"],
25-
"end_date": Faker().date(),
26-
"deleted": False,
27-
"timezone_offset": "300",
28-
"project_id": Faker().random_int(),
29-
}
16+
time_entry_body = time_entry_factory(None).__dict__
3017
body = json.dumps(time_entry_body).encode("utf-8")
3118
req = func.HttpRequest(
3219
method="POST",

V2/tests/fixtures.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ def _create_fake_database() -> domain.ActivitiesDao:
3434
db_fake = DB('sqlite:///:memory:')
3535
return db_fake
3636

37+
@pytest.fixture
38+
def create_temp_time_entries(tmpdir_factory):
39+
temporary_directory = tmpdir_factory.mktemp("tmp")
40+
json_file = temporary_directory.join("time_entries.json")
41+
time_entries = [
42+
{
43+
"id": Faker().random_int(),
44+
"start_date": Faker().date(),
45+
"owner_id": Faker().random_int(),
46+
"description": Faker().sentence(),
47+
"activity_id": Faker().random_int(),
48+
"uri": Faker().domain_name(),
49+
"technologies": ["jira", "git"],
50+
"end_date": Faker().date(),
51+
"deleted": Faker().random_int(),
52+
"timezone_offset": "300",
53+
"project_id": Faker().random_int(),
54+
}
55+
]
3756

3857
@pytest.fixture(name='time_entry_factory')
3958
def _time_entry_factory() -> TimeEntry:
@@ -43,10 +62,10 @@ def _make_time_entry(
4362
owner_id=Faker().random_int(),
4463
description=Faker().sentence(),
4564
activity_id=Faker().random_int(),
46-
uri="http://time-tracker.com",
65+
uri=Faker().domain_name(),
4766
technologies=["jira", "git"],
4867
end_date=Faker().date(),
49-
deleted=Faker().random_int(),
68+
deleted=False,
5069
timezone_offset="300",
5170
project_id=Faker().random_int(),
5271
):

V2/tests/integration/daos/time_entries_dao.test.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,11 @@ def _creator(time_entries):
1919

2020

2121
def test_create_time_entry__returns_an_time_entry_dto__when_create_an_time_entry_that_matches_attributes(
22-
create_fake_time_entries,
22+
create_fake_time_entries, time_entry_factory
2323
):
2424
create_fake_time_entries([])
2525

2626
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://timetracker.com",
34-
"technologies": ["jira", "git"],
35-
"end_date": Faker().date(),
36-
"deleted": False,
37-
"timezone_offset": "300",
38-
"project_id": Faker().random_int(),
39-
}
40-
result = time_entries_json_dao.create(time_entry_data)
27+
time_entry_data = time_entry_factory()
28+
result = time_entries_json_dao.create(time_entry_data.__dict__)
4129
assert result == TimeEntry(**time_entry_data)

V2/time_tracker/time_entries/_domain/_persistence_contracts/_time_entries_dao.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55

66
class TimeEntriesDao(abc.ABC):
7+
@abc.abstractmethod
78
def create(self, time_entry_data: dict) -> TimeEntry:
89
pass
Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
[{"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "tenant_id": "asdasdsa", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": "asdasdsaadssa", "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": 2, "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": false, "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": "2", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": false, "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": "2", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": false, "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": "2", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": false, "timezone_offset": "asdasdsa", "project_id": 1}, {"id": null, "start_date": "12/07/2021", "owner_id": "2", "description": "No se que poner jajaj ", "activity_id": 2, "uri": "http://hola.que.hace.com", "technologies": ["git", "jira", "python"], "end_date": "12/07/2021", "deleted": false, "timezone_offset": "asdasdsa", "project_id": 1}]
1+
[
2+
{
3+
"id": 1,
4+
"start_date": "12/07/2021",
5+
"owner_id": 2,
6+
"description": "Review system of Time Tracker",
7+
"activity_id": 2,
8+
"uri": "http://time_tracker.com",
9+
"technologies": [
10+
"git",
11+
"jira",
12+
"python"
13+
],
14+
"end_date": "12/07/2021",
15+
"deleted": false,
16+
"timezone_offset": "300",
17+
"project_id": 1
18+
},
19+
{
20+
"id": 2,
21+
"start_date": "12/07/2021",
22+
"owner_id": 2,
23+
"description": "Review system of doors in the ioet office Loja, change the current raspberry pi ",
24+
"activity_id": 2,
25+
"uri": null,
26+
"technologies": [
27+
"git",
28+
"jira",
29+
"python"
30+
],
31+
"end_date": "12/07/2021",
32+
"deleted": false,
33+
"timezone_offset": "300",
34+
"project_id": 1
35+
}
36+
]

0 commit comments

Comments
 (0)