88from unittest .mock import Mock , patch
99
1010import pytest
11+ from django .conf import settings
1112from django .db import IntegrityError , transaction
13+ from django .test .testcases import SerializeMixin
1214from django .urls import reverse
1315from django .utils .timezone import get_current_timezone
1416
15- from config .settings .test import SF_DOMAIN , SF_INSTANCE , SF_PASSWORD , SF_SECURITY_TOKEN , SF_USERNAME
1617from seed .landing .models import SEEDUser as User
1718from seed .lib .superperms .orgs .models import ROLE_MEMBER
1819from seed .models import Column , PropertyView , SalesforceConfig , SalesforceMapping
3233from seed .views .v3 .label_inventories import LabelInventoryViewSet
3334
3435
35- class SalesforceViewTests (DataMappingBaseTestCase ):
36+ class SalesforceLiveTestsMixin (SerializeMixin ):
37+ # These tests use the same live Salesforce sandbox records and must not run in parallel.
38+ lockfile = __file__
39+
40+
41+ class SalesforceViewTests (SalesforceLiveTestsMixin , DataMappingBaseTestCase ):
3642 def setUp (self ):
3743 user_details = {"username" : "test_user@demo.com" , "password" : "test_pass" , "email" : "test_user@demo.com" }
3844 self .api_view = LabelInventoryViewSet ()
@@ -190,8 +196,8 @@ def test_salesforce_connection_fails(self):
190196 self .org .save ()
191197
192198 payload_data = {"salesforce_config" : {"instance" : None , "username" : None , "password" : None , "security_token" : None }}
193- if SF_DOMAIN == "test" :
194- payload_data ["salesforce_config" ]["domain" ] = SF_DOMAIN
199+ if settings . SF_DOMAIN == "test" :
200+ payload_data ["salesforce_config" ]["domain" ] = settings . SF_DOMAIN
195201
196202 response = self .client .post (
197203 reverse ("api:v3:salesforce_configs-salesforce-connection" ) + "?organization_id=" + str (self .org .id ),
@@ -212,15 +218,15 @@ def test_salesforce_connection_success(self):
212218
213219 payload_data = {
214220 "salesforce_config" : {
215- "instance" : SF_INSTANCE ,
216- "username" : SF_USERNAME ,
217- "password" : SF_PASSWORD ,
218- "security_token" : SF_SECURITY_TOKEN ,
221+ "instance" : settings . SF_INSTANCE ,
222+ "username" : settings . SF_USERNAME ,
223+ "password" : settings . SF_PASSWORD ,
224+ "security_token" : settings . SF_SECURITY_TOKEN ,
219225 }
220226 }
221227
222- if SF_DOMAIN == "test" :
223- payload_data ["salesforce_config" ]["domain" ] = SF_DOMAIN
228+ if settings . SF_DOMAIN == "test" :
229+ payload_data ["salesforce_config" ]["domain" ] = settings . SF_DOMAIN
224230
225231 response = self .client .post (
226232 reverse ("api:v3:salesforce_configs-salesforce-connection" ) + "?organization_id=" + str (self .org .id ),
@@ -250,12 +256,12 @@ def test_pushing_salesforce_benchmark(self):
250256 # print(f" view data: {pdata}")
251257
252258 # enable sf
253- self .sf_config .url = SF_INSTANCE
254- self .sf_config .username = SF_USERNAME
255- self .sf_config .password = encrypt (SF_PASSWORD )
256- self .sf_config .security_token = SF_SECURITY_TOKEN
257- if SF_DOMAIN == "test" :
258- self .sf_config .domain = SF_DOMAIN
259+ self .sf_config .url = settings . SF_INSTANCE
260+ self .sf_config .username = settings . SF_USERNAME
261+ self .sf_config .password = encrypt (settings . SF_PASSWORD )
262+ self .sf_config .security_token = settings . SF_SECURITY_TOKEN
263+ if settings . SF_DOMAIN == "test" :
264+ self .sf_config .domain = settings . SF_DOMAIN
259265 self .sf_config .save ()
260266
261267 status , _message = update_salesforce_property (self .org .id , view .id )
@@ -528,7 +534,7 @@ def test_no_sync_when_disabled(self):
528534 # TODO: test auto sync works and sets date
529535
530536
531- class SalesforceViewTestPermissions (AccessLevelBaseTestCase ):
537+ class SalesforceViewTestPermissions (SalesforceLiveTestsMixin , AccessLevelBaseTestCase ):
532538 def setUp (self ):
533539 super ().setUp ()
534540
@@ -699,12 +705,12 @@ def test_property_update_salesforce_perms(self):
699705 self .api_view .add_labels (self .api_view .models ["property" ].objects .none (), "property" , [view .id ], [self .compliance_label .id ])
700706
701707 # enable sf
702- self .sf_config .url = SF_INSTANCE
703- self .sf_config .username = SF_USERNAME
704- self .sf_config .password = encrypt (SF_PASSWORD )
705- self .sf_config .security_token = SF_SECURITY_TOKEN
706- if SF_DOMAIN == "test" :
707- self .sf_config .domain = SF_DOMAIN
708+ self .sf_config .url = settings . SF_INSTANCE
709+ self .sf_config .username = settings . SF_USERNAME
710+ self .sf_config .password = encrypt (settings . SF_PASSWORD )
711+ self .sf_config .security_token = settings . SF_SECURITY_TOKEN
712+ if settings . SF_DOMAIN == "test" :
713+ self .sf_config .domain = settings . SF_DOMAIN
708714 self .sf_config .save ()
709715
710716 url = reverse ("api:v3:properties-update-salesforce" ) + f"?organization_id={ self .org .pk } "
0 commit comments