55
66
77@mock .patch ("routes.v1.company.utils.get_company_by_name" )
8- def test_company (mock_get_company_by_name , client ):
8+ @mock .patch ("logger.log.logger.debug" )
9+ def test_company (mock_logger_debug ,
10+ mock_get_company_by_name , client ):
11+ mock_logger_debug .return_value = "Ok"
912 mock_get_company_by_name .return_value = {"id" : 12345 }
1013 response = client .get ("/api/v1/company/test-company/" )
1114 assert response .status_code == 200
1215 assert response .json () == {"id" : 12345 }
1316
1417
1518@mock .patch ("routes.v1.company.utils.get_company_by_name" )
16- def test_company_for_hubspot_companyexception (mock_get_company_by_name , client ):
19+ @mock .patch ("logger.log.logger.debug" )
20+ def test_company_for_hubspot_company_exception (mock_logger_debug ,
21+ mock_get_company_by_name , client ):
22+ mock_logger_debug .return_value = "Ok"
1723 mock_get_company_by_name .side_effect = CompanyException (
1824 "Something went wrong in fetching company from Hubspot"
1925 )
@@ -25,7 +31,9 @@ def test_company_for_hubspot_companyexception(mock_get_company_by_name, client):
2531
2632
2733@mock .patch ("routes.v1.company.utils.create_company" )
28- def test_create_company (mock_create_company , client ):
34+ @mock .patch ("logger.log.logger.debug" )
35+ def test_create_company (mock_logger_debug , mock_create_company , client ):
36+ mock_logger_debug .return_value = "Ok"
2937 mock_create_company .return_value = {"company_id" : 1111 }
3038 response = client .post (
3139 "/api/v1/companies/" , json = {"org_id" : 123 , "name" : "Warner Bros co" }
@@ -35,7 +43,10 @@ def test_create_company(mock_create_company, client):
3543
3644
3745@mock .patch ("routes.v1.company.utils.create_company" )
38- def test_create_company_with_hubspot_companyexception (mock_create_company , client , db ):
46+ @mock .patch ("logger.log.logger.debug" )
47+ def test_create_company_with_hubspot_company_exception (mock_logger_debug , mock_create_company ,
48+ client , db ):
49+ mock_logger_debug .return_value = "Ok"
3950 mock_create_company .side_effect = CompanyException (
4051 "Something went wrong in creating company in Hubspot"
4152 )
@@ -50,25 +61,31 @@ def test_create_company_with_hubspot_companyexception(mock_create_company, clien
5061 assert company == []
5162
5263
53- def test_create_company_with_duplicate_organization_org_id (client , organization ):
64+ @mock .patch ("logger.log.logger.debug" )
65+ def test_create_company_with_duplicate_organization_org_id (mock_logger_debug ,
66+ client , organization ):
67+ mock_logger_debug .return_value = "Ok"
5468 response = client .post (
5569 "/api/v1/companies/" , json = {"org_id" : 12345 , "name" : "UWISO" }
5670 )
5771 assert response .status_code == 200
5872 assert response .json () == {
5973 "detail" : "duplicate key value violates unique constraint "
60- '"organization_org_id_key"\n DETAIL: Key (org_id)=('
61- "12345) already exists.\n "
74+ '"organization_org_id_key"\n DETAIL: Key (org_id)=('
75+ "12345) already exists.\n "
6276 }
6377
6478
65- def test_create_company_with_duplicate_organization_name (client , organization ):
79+ @mock .patch ("logger.log.logger.debug" )
80+ def test_create_company_with_duplicate_organization_name (mock_logger_debug ,
81+ client , organization ):
82+ mock_logger_debug .return_value = "Ok"
6683 response = client .post (
6784 "/api/v1/companies/" , json = {"org_id" : 1232245 , "name" : "Test org" }
6885 )
6986 assert response .status_code == 200
7087 assert response .json () == {
7188 "detail" : "duplicate key value violates unique constraint "
72- '"organization_name_key"\n DETAIL: Key (name)=('
73- "Test org) already exists.\n "
89+ '"organization_name_key"\n DETAIL: Key (name)=('
90+ "Test org) already exists.\n "
7491 }
0 commit comments