Skip to content

Commit 74ed6e7

Browse files
surajitsurajit
authored andcommitted
add test for getting company
1 parent b62413c commit 74ed6e7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/routes/test_company.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from unittest import mock
2+
3+
from hubspot_api.utils import CompanyException
4+
5+
6+
@mock.patch("routes.v1.company.utils.get_company_by_name")
7+
def test_company(mock_get_company_by_name, client):
8+
mock_get_company_by_name.return_value = {"id": 12345}
9+
response = client.get("/api/v1/company/test-company/")
10+
assert response.status_code == 200
11+
assert response.json() == {"id": 12345}
12+
13+
14+
@mock.patch("routes.v1.company.utils.get_company_by_name")
15+
def test_company_for_hubspot_companyexception(mock_get_company_by_name, client):
16+
mock_get_company_by_name.side_effect = CompanyException(
17+
"Something went wrong in fetching company from Hubspot"
18+
)
19+
response = client.get("/api/v1/company/test-company/")
20+
assert response.status_code == 200
21+
assert response.json() == {
22+
"detail": "Something went wrong in fetching company from Hubspot"
23+
}

0 commit comments

Comments
 (0)