|
7 | 7 | from flask_restplus._http import HTTPStatus |
8 | 8 | from pytest_mock import MockFixture |
9 | 9 |
|
10 | | -from commons.data_access_layer.cosmos_db import current_datetime |
| 10 | +from commons.data_access_layer.cosmos_db import current_datetime, current_datetime_str |
11 | 11 |
|
12 | 12 | fake = Faker() |
13 | 13 |
|
|
16 | 16 | "project_id": fake.uuid4(), |
17 | 17 | "activity_id": fake.uuid4(), |
18 | 18 | "description": fake.paragraph(nb_sentences=2), |
19 | | - "start_date": str(yesterday.isoformat()), |
20 | | - "owner_id": fake.uuid4(), |
21 | | - "tenant_id": fake.uuid4() |
| 19 | + "start_date": current_datetime_str(), |
22 | 20 | } |
23 | 21 |
|
24 | 22 | fake_time_entry = ({ |
25 | 23 | "id": fake.random_int(1, 9999), |
26 | 24 | "running": True, |
| 25 | + "owner_id": fake.uuid4(), |
| 26 | + "tenant_id": fake.uuid4(), |
27 | 27 | }) |
28 | 28 | fake_time_entry.update(valid_time_entry_input) |
29 | 29 |
|
@@ -86,21 +86,20 @@ def test_create_time_entry_should_succeed_with_valid_request(client: FlaskClient |
86 | 86 | repository_create_mock.assert_called_once() |
87 | 87 |
|
88 | 88 |
|
89 | | -def test_create_time_entry_should_reject_bad_request(client: FlaskClient, |
90 | | - mocker: MockFixture, |
91 | | - valid_header: dict): |
| 89 | +def test_create_time_entry_with_missing_req_field_should_return_bad_request(client: FlaskClient, |
| 90 | + mocker: MockFixture, |
| 91 | + valid_header: dict): |
92 | 92 | from time_tracker_api.time_entries.time_entries_namespace import time_entries_dao |
93 | | - invalid_time_entry_input = valid_time_entry_input.copy() |
94 | | - invalid_time_entry_input.update({ |
95 | | - "project_id": None, |
96 | | - }) |
97 | 93 | repository_create_mock = mocker.patch.object(time_entries_dao.repository, |
98 | 94 | 'create', |
99 | 95 | return_value=fake_time_entry) |
100 | 96 |
|
101 | 97 | response = client.post("/time-entries", |
102 | 98 | headers=valid_header, |
103 | | - json=invalid_time_entry_input, |
| 99 | + json={ |
| 100 | + "activity_id": fake.uuid4(), |
| 101 | + "start_date": current_datetime_str(), |
| 102 | + }, |
104 | 103 | follow_redirects=True) |
105 | 104 |
|
106 | 105 | assert HTTPStatus.BAD_REQUEST == response.status_code |
|
0 commit comments