Skip to content
Prev Previous commit
Next Next commit
fix: TT-401 implemented faker url
  • Loading branch information
ararcos committed Nov 17, 2021
commit 04832681b3279e8cb9e7e37d7af2db9c3b49c10f
17 changes: 2 additions & 15 deletions V2/tests/api/azure/time_entry_azure_endpoints_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from time_tracker.time_entries._application import _time_entries as time_entries
from faker import Faker

import azure.functions as func
import json
Expand All @@ -9,24 +8,12 @@


def test__time_entry_azure_endpoint__creates_an_time_entry__when_time_entry_has_all_attributes(
create_temp_time_entries,
create_temp_time_entries, time_entry_factory
):
time_entries_json, tmp_directory = create_temp_time_entries
time_entries._create_time_entry._JSON_PATH = tmp_directory

time_entry_body = {
"id": None,
"start_date": Faker().date(),
"owner_id": Faker().random_int(),
"description": Faker().sentence(),
"activity_id": Faker().random_int(),
"uri": "http://timetracker.com",
"technologies": ["jira", "git"],
"end_date": Faker().date(),
"deleted": False,
"timezone_offset": "300",
"project_id": Faker().random_int(),
}
time_entry_body = time_entry_factory(None).__dict__
body = json.dumps(time_entry_body).encode("utf-8")
req = func.HttpRequest(
method="POST",
Expand Down
23 changes: 21 additions & 2 deletions V2/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ def _create_fake_database() -> domain.ActivitiesDao:
db_fake = DB('sqlite:///:memory:')
return db_fake

@pytest.fixture
def create_temp_time_entries(tmpdir_factory):
temporary_directory = tmpdir_factory.mktemp("tmp")
json_file = temporary_directory.join("time_entries.json")
time_entries = [
{
"id": Faker().random_int(),
"start_date": Faker().date(),
"owner_id": Faker().random_int(),
"description": Faker().sentence(),
"activity_id": Faker().random_int(),
"uri": Faker().domain_name(),
"technologies": ["jira", "git"],
"end_date": Faker().date(),
"deleted": Faker().random_int(),
"timezone_offset": "300",
"project_id": Faker().random_int(),
}
]

@pytest.fixture(name='time_entry_factory')
def _time_entry_factory() -> TimeEntry:
Expand All @@ -43,10 +62,10 @@ def _make_time_entry(
owner_id=Faker().random_int(),
description=Faker().sentence(),
activity_id=Faker().random_int(),
uri="http://time-tracker.com",
uri=Faker().domain_name(),
technologies=["jira", "git"],
end_date=Faker().date(),
deleted=Faker().random_int(),
deleted=False,
timezone_offset="300",
project_id=Faker().random_int(),
):
Expand Down
18 changes: 3 additions & 15 deletions V2/tests/integration/daos/time_entries_dao.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,11 @@ def _creator(time_entries):


def test_create_time_entry__returns_an_time_entry_dto__when_create_an_time_entry_that_matches_attributes(
create_fake_time_entries,
create_fake_time_entries, time_entry_factory
):
create_fake_time_entries([])

time_entries_json_dao = TimeEntriesJsonDao(Faker().file_path())
time_entry_data = {
"id": None,
"start_date": Faker().date(),
"owner_id": Faker().random_int(),
"description": Faker().sentence(),
"activity_id": Faker().random_int(),
"uri": "http://timetracker.com",
"technologies": ["jira", "git"],
"end_date": Faker().date(),
"deleted": False,
"timezone_offset": "300",
"project_id": Faker().random_int(),
}
result = time_entries_json_dao.create(time_entry_data)
time_entry_data = time_entry_factory()
result = time_entries_json_dao.create(time_entry_data.__dict__)
assert result == TimeEntry(**time_entry_data)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@


class TimeEntriesDao(abc.ABC):
@abc.abstractmethod
def create(self, time_entry_data: dict) -> TimeEntry:
pass
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
[{"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}]
[
{
"id": 1,
"start_date": "12/07/2021",
"owner_id": 2,
"description": "Review system of Time Tracker",
"activity_id": 2,
"uri": "http://time_tracker.com",
"technologies": [
"git",
"jira",
"python"
],
"end_date": "12/07/2021",
"deleted": false,
"timezone_offset": "300",
"project_id": 1
},
{
"id": 2,
"start_date": "12/07/2021",
"owner_id": 2,
"description": "Review system of doors in the ioet office Loja, change the current raspberry pi ",
"activity_id": 2,
"uri": null,
"technologies": [
"git",
"jira",
"python"
],
"end_date": "12/07/2021",
"deleted": false,
"timezone_offset": "300",
"project_id": 1
}
]