File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments