Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: TT-417 test name correction
  • Loading branch information
ararcos committed Nov 25, 2021
commit 7dec55a6e8318057ca1f85117442ff5429d38e27
37 changes: 17 additions & 20 deletions V2/tests/api/azure/project_azure_endpoints_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@pytest.fixture(name='insert_project')
def insert_project(test_db, insert_customer, project_factory, customer_factory) -> domain.Project:
def _insert_project(test_db, insert_customer, project_factory, customer_factory) -> domain.Project:
inserted_customer = insert_customer(customer_factory(), test_db)

def _new_project():
Expand All @@ -40,7 +40,7 @@ def test__project_azure_endpoint__returns_all_projects(
assert projects_json_data == json.dumps(inserted_projects)


def test__project_azure_endpoint__returns_an_project__when_project_matches_its_id(
def test__project_azure_endpoint__returns_a_project__when_project_matches_its_id(
insert_project
):
inserted_project = insert_project().__dict__
Expand All @@ -59,7 +59,7 @@ def test__project_azure_endpoint__returns_an_project__when_project_matches_its_i
assert activitiy_json_data == json.dumps(inserted_project)


def test__projects_azure_endpoint__returns_a_status_code_400__when_project_recive_invalid_id(
def test__projects_azure_endpoint__returns_a_status_code_400__when_project_receive_invalid_id(
):
req = func.HttpRequest(
method="GET",
Expand All @@ -74,7 +74,7 @@ def test__projects_azure_endpoint__returns_a_status_code_400__when_project_reciv
assert response.get_body() == b"Invalid Format ID"


def test__project_azure_endpoint__returns_an_project_with_inactive_status__when_a_project_matching_its_id_is_found(
def test__project_azure_endpoint__returns_a_project_with_inactive_status__when_a_project_matching_its_id_is_found(
insert_project
):
inserted_project = insert_project().__dict__
Expand All @@ -94,7 +94,7 @@ def test__project_azure_endpoint__returns_an_project_with_inactive_status__when_
assert project_json_data['deleted'] is True


def test__delete_projects_azure_endpoint__returns_a_status_code_400__when_project_recive_invalid_id(
def test__delete_projects_azure_endpoint__returns_a_status_code_400__when_project_receive_invalid_id(
):
req = func.HttpRequest(
method="DELETE",
Expand Down Expand Up @@ -124,7 +124,7 @@ def test__delete_projects_azure_endpoint__returns_a_status_code_404__when_no_fou
assert response.get_body() == b"Not found"


def test__update_project_azure_endpoint__returns_an_project__when_found_a_project_to_update(
def test__update_project_azure_endpoint__returns_a_project__when_found_a_project_to_update(
insert_project
):
inserted_project = insert_project().__dict__
Expand Down Expand Up @@ -154,7 +154,7 @@ def test__update_projects_azure_endpoint__returns_a_status_code_404__when_no_fou
method="PUT",
body=json.dumps(project_body).encode("utf-8"),
url=PROJECT_URL,
route_params={"id": Faker().pyint()},
route_params={"id": project_body["id"]},
)

response = azure_projects._update_project.update_project(req)
Expand All @@ -163,7 +163,7 @@ def test__update_projects_azure_endpoint__returns_a_status_code_404__when_no_fou
assert response.get_body() == b"Not found"


def test__update_projects_azure_endpoint__returns_a_status_code_400__when_recive_an_incorrect_body(
def test__update_projects_azure_endpoint__returns_a_status_code_400__when_receive_an_incorrect_body(
):
project_body = Faker().pydict(5, True, str)
req = func.HttpRequest(
Expand All @@ -179,7 +179,7 @@ def test__update_projects_azure_endpoint__returns_a_status_code_400__when_recive
assert response.get_body() == b"Incorrect body"


def test__update_projects_azure_endpoint__returns_a_status_code_400__when_project_recive_invalid_id(
def test__update_projects_azure_endpoint__returns_a_status_code_400__when_project_receive_invalid_id(
):
req = func.HttpRequest(
method="PUT",
Expand All @@ -194,15 +194,15 @@ def test__update_projects_azure_endpoint__returns_a_status_code_400__when_projec
assert response.get_body() == b"Invalid Format ID"


def test__project_azure_endpoint__creates_an_project__when_project_has_all_attributes(
def test__project_azure_endpoint__creates_a_project__when_project_has_all_attributes(
test_db, project_factory, insert_customer, customer_factory
):
insert_customer(customer_factory(), test_db)
project_body = project_factory().__dict__
body = json.dumps(project_body).encode("utf-8")
inserted = insert_customer(customer_factory(), test_db)
project_body = project_factory(inserted.id).__dict__

req = func.HttpRequest(
method='POST',
body=body,
body=json.dumps(project_body).encode("utf-8"),
url=PROJECT_URL,
)

Expand All @@ -221,10 +221,9 @@ def test__project_azure_endpoint__returns_a_status_code_400__when_project_does_n
project_body = project_factory(customer_id=inserted_customer.id).__dict__
project_body.pop('name')

body = json.dumps(project_body).encode("utf-8")
req = func.HttpRequest(
method='POST',
body=body,
body=json.dumps(project_body).encode("utf-8"),
url=PROJECT_URL,
)

Expand All @@ -234,17 +233,15 @@ def test__project_azure_endpoint__returns_a_status_code_400__when_project_does_n
assert response.get_body() == json.dumps(['The name key is missing in the input data']).encode()


def test__project_azure_endpoint__returns_a_status_code_500__when_project_recive_incorrect_type_data(
def test__project_azure_endpoint__returns_a_status_code_500__when_project_receive_incorrect_type_data(
project_factory, insert_customer, customer_factory, test_db
):
insert_customer(customer_factory(), test_db)
project_body = project_factory(technologies=Faker().pylist(2, True, str)).__dict__

body = json.dumps(project_body).encode("utf-8")
print(project_body)
req = func.HttpRequest(
method='POST',
body=body,
body=json.dumps(project_body).encode("utf-8"),
url=PROJECT_URL,
)

Expand Down