From 41c00d604968d6a5eafb8618404a6d75691de651 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 13:15:51 -0700 Subject: [PATCH 1/6] Allow specifying hostname and sec token for tests Also a little cleanup to allow easier copy paste between tests --- pyforce/xmlclient.py | 1 + tests/benchmark_test.py | 50 +++-- tests/python_client_test.py | 408 +++++++++++++++++++++--------------- tests/xmlclient_test.py | 54 ++--- tox.ini | 2 +- 5 files changed, 293 insertions(+), 222 deletions(-) diff --git a/pyforce/xmlclient.py b/pyforce/xmlclient.py index 5a75285..32b96f5 100644 --- a/pyforce/xmlclient.py +++ b/pyforce/xmlclient.py @@ -467,6 +467,7 @@ def post(self, conn=None, alwaysReturnList=False): self.serverUrl, data=envelope, headers=headers, + timeout=10, ) except requests.exceptions.ConnectionError as ex: attempt += 1 diff --git a/tests/benchmark_test.py b/tests/benchmark_test.py index 58148d7..adc4bab 100644 --- a/tests/benchmark_test.py +++ b/tests/benchmark_test.py @@ -13,7 +13,7 @@ BENCHMARK_REPS = 1 -SERVER_URL = "https://test.salesforce.com/services/Soap/u/20.0" +DEFAULT_HOSTNAME = "test.salesforce.com" def benchmark(func): @@ -33,35 +33,35 @@ def benchmarked_func(self): class TestUtils(unittest.TestCase): def setUp(self): - self.svc = svc = pyforce.PythonClient(serverUrl=SERVER_URL) - svc.login(os.getenv('SF_USERNAME'), os.getenv('SF_PASSWORD')) + hostname = os.getenv('SF_HOSTNAME', DEFAULT_HOSTNAME) + server_url = "https://{}/services/Soap/u/20.0".format(hostname) + self.svc = pyforce.PythonClient(serverUrl=server_url) + password = os.getenv('SF_PASSWORD') + os.getenv('SF_SECTOKEN', '') + self.svc.login(os.getenv('SF_USERNAME'), password) self._todelete = list() def tearDown(self): - svc = self.svc ids = self._todelete if ids: while len(ids) > 200: - svc.delete(ids[:200]) + self.svc.delete(ids[:200]) ids = ids[200:] if ids: - svc.delete(ids) + self.svc.delete(ids) self._todelete = list() @benchmark def testDescribeSObjects(self): - svc = self.svc - globalres = svc.describeGlobal() + globalres = self.svc.describeGlobal() types = globalres['types'] - res = svc.describeSObjects(types[0]) + res = self.svc.describeSObjects(types[0]) self.assertEqual(type(res), list) self.assertEqual(len(res), 1) - res = svc.describeSObjects(types[:100]) + res = self.svc.describeSObjects(types[:100]) self.assertEqual(len(types[:100]), len(res)) @benchmark def testCreate(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -69,14 +69,17 @@ def testCreate(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + [id], + ) self.assertEqual(len(contacts), 1) contact = contacts[0] for k in ['LastName', 'FirstName', 'Phone', 'Email', 'Birthdate']: @@ -85,7 +88,6 @@ def testCreate(self): @benchmark def testQuery(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -93,7 +95,7 @@ def testQuery(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) self._todelete.append(res[0]['id']) data2 = dict(type='Contact', LastName='Doe', @@ -102,16 +104,22 @@ def testQuery(self): Email='jane@doe.com', Birthdate=datetime.date(1972, 10, 15) ) - res = svc.create([data2]) + res = self.svc.create([data2]) janeid = res[0]['id'] self._todelete.append(janeid) - res = svc.query('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', "LastName = 'Doe'") + res = self.svc.query( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + "LastName = 'Doe'", + ) self.assertEqual(len(res), 2) self.assertEqual(res['size'], 2) self.assertEqual(res.size, 2) - res = svc.query('Id, LastName, FirstName, Phone, Email, Birthdate', - 'Contact', "LastName = 'Doe' and FirstName = 'Jane'") + res = self.svc.query( + 'Id, LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + "LastName = 'Doe' and FirstName = 'Jane'", + ) self.assertEqual(len(res), 1) self.assertEqual(res[0]['Id'], janeid) self.tearDown() diff --git a/tests/python_client_test.py b/tests/python_client_test.py index edd2a75..3c27921 100644 --- a/tests/python_client_test.py +++ b/tests/python_client_test.py @@ -13,7 +13,7 @@ from pyforce.pyclient import _prepareSObjects -SERVER_URL = "https://test.salesforce.com/services/Soap/u/20.0" +DEFAULT_HOSTNAME = "test.salesforce.com" DELAY_RETRY = 10 DELAY_SEC = 2 @@ -21,23 +21,24 @@ class TestUtils(unittest.TestCase): def setUp(self): - self.svc = svc = pyforce.PythonClient(serverUrl=SERVER_URL) - svc.login(os.getenv('SF_USERNAME'), os.getenv('SF_PASSWORD')) + hostname = os.getenv('SF_HOSTNAME', DEFAULT_HOSTNAME) + server_url = "https://{}/services/Soap/u/20.0".format(hostname) + self.svc = self.svc = pyforce.PythonClient(serverUrl=server_url) + password = os.getenv('SF_PASSWORD') + os.getenv('SF_SECTOKEN', '') + self.svc.login(os.getenv('SF_USERNAME'), password) self._todelete = list() def tearDown(self): - svc = self.svc ids = self._todelete if ids: while len(ids) > 200: - svc.delete(ids[:200]) + self.svc.delete(ids[:200]) ids = ids[200:] if ids: - svc.delete(ids) + self.svc.delete(ids) def testDescribeGlobal(self): - svc = self.svc - res = svc.describeGlobal() + res = self.svc.describeGlobal() self.assertEqual(type(res), dict) self.assertTrue(isinstance(res['encoding'], string_types)) self.assertTrue(isinstance(res['maxBatchSize'], int)) @@ -47,17 +48,15 @@ def testDescribeGlobal(self): self.assertTrue(len(res['types']) > 0) def testDescribeSObjects(self): - svc = self.svc - globalres = svc.describeGlobal() + globalres = self.svc.describeGlobal() types = globalres['types'][:100] - res = svc.describeSObjects(types[0]) + res = self.svc.describeSObjects(types[0]) self.assertEqual(type(res), list) self.assertEqual(len(res), 1) - res = svc.describeSObjects(types) + res = self.svc.describeSObjects(types) self.assertEqual(len(types), len(res)) def testCreate(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -65,14 +64,17 @@ def testCreate(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + [id], + ) self.assertEqual(len(contacts), 1) contact = contacts[0] for k in ['LastName', 'FirstName', 'Phone', 'Email', 'Birthdate']: @@ -82,7 +84,6 @@ def testCreate(self): def testSetIntegerField(self): # Passes when you feed it floats, even if salesforce field is defined # for 0 decimal places. Lack of data validation in SF? - svc = self.svc testField = 'Favorite_Integer__c' data = dict( type='Contact', @@ -90,13 +91,13 @@ def testSetIntegerField(self): FirstName='John', Favorite_Integer__c=-25, ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve( + contacts = self.svc.retrieve( 'LastName, FirstName, Favorite_Integer__c', 'Contact', [id], @@ -106,27 +107,30 @@ def testSetIntegerField(self): self.assertEqual(data[testField], contact[testField]) def testSetFloatField(self): - # this fails when you have a large amount (I didn't test the #) of decimal places. - svc = self.svc + # this fails when you have a large amount (I didn't test the #) + # of decimal places. testField = 'Favorite_Float__c' data = dict(type='Contact', LastName='Doe', FirstName='John', Favorite_Float__c=-1.999888777 ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, FirstName, Favorite_Float__c', 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, FirstName, Favorite_Float__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts), 1) contact = contacts[0] self.assertEqual(data[testField], contact[testField]) def testCreatePickListMultiple(self): - svc = self.svc data = dict( type='Contact', @@ -137,13 +141,13 @@ def testCreatePickListMultiple(self): Birthdate=datetime.date(1970, 1, 4), Favorite_Fruit__c=["Apple", "Orange", "Pear"], ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve( + contacts = self.svc.retrieve( 'LastName, FirstName, Phone, Email, Birthdate, Favorite_Fruit__c', 'Contact', [id], @@ -163,7 +167,6 @@ def testCreatePickListMultiple(self): #def testCreatePickListMultipleWithInvalid(self): #""" This fails, and I guess it should(?) # SF doesn't enforce vocabularies, appearently """ - #svc = self.svc #data = dict(type='Contact', #LastName='Doe', @@ -173,13 +176,13 @@ def testCreatePickListMultiple(self): #Birthdate = datetime.date(1970, 1, 4), #Favorite_Fruit__c = ["Apple","Orange","Pear","RottenFruit"] #) - #res = svc.create([data]) + #res = self.svc.create([data]) #self.assertTrue(type(res) in (list, tuple)) #self.assertTrue(len(res) == 1) #self.assertTrue(res[0]['success']) #id = res[0]['id'] #self._todelete.append(id) - #contacts = svc.retrieve('LastName, FirstName, Phone, Email, Birthdate, \ + #contacts = self.svc.retrieve('LastName, FirstName, Phone, Email, Birthdate, \ #Favorite_Fruit__c', 'Contact', [id]) #self.assertEqual(len(contacts), 1) #contact = contacts[0] @@ -190,7 +193,6 @@ def testCreatePickListMultiple(self): #data[k], contact[k]) def testFailedCreate(self): - svc = self.svc data = dict( type='Contact', LastName='Doe', @@ -199,10 +201,9 @@ def testFailedCreate(self): Email='john@doe.com', Birthdate='foo', ) - self.assertRaises(SoapFaultError, svc.create, data) + self.assertRaises(SoapFaultError, self.svc.create, data) def testRetrieve(self): - svc = self.svc data = dict( type='Contact', LastName='Doe', @@ -211,19 +212,18 @@ def testRetrieve(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4), ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - typedesc = svc.describeSObjects('Contact')[0] + typedesc = self.svc.describeSObjects('Contact')[0] fieldnames = list() fields = typedesc.fields.values() fieldnames = [f.name for f in fields] fieldnames = ', '.join(fieldnames) - contacts = svc.retrieve(fieldnames, 'Contact', [id]) + contacts = self.svc.retrieve(fieldnames, 'Contact', [id]) self.assertEqual(len(contacts), 1) def testRetrieveDeleted(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -231,19 +231,18 @@ def testRetrieveDeleted(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create(data) + res = self.svc.create(data) id = res[0]['id'] - svc.delete(id) - typedesc = svc.describeSObjects('Contact')[0] + self.svc.delete(id) + typedesc = self.svc.describeSObjects('Contact')[0] fieldnames = list() fields = typedesc.fields.values() fieldnames = [f.name for f in fields] fieldnames = ', '.join(fieldnames) - contacts = svc.retrieve(fieldnames, 'Contact', [id]) + contacts = self.svc.retrieve(fieldnames, 'Contact', [id]) self.assertEqual(len(contacts), 0) def testDelete(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -251,15 +250,14 @@ def testDelete(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] - res = svc.delete([id]) + res = self.svc.delete([id]) self.assertTrue(res[0]['success']) - contacts = svc.retrieve('LastName', 'Contact', [id]) + contacts = self.svc.retrieve('LastName', 'Contact', [id]) self.assertEqual(len(contacts), 0) def testUpdate(self): - svc = self.svc originaldate = datetime.date(1970, 1, 4) newdate = datetime.date(1970, 1, 5) lastname = 'Doe' @@ -270,22 +268,21 @@ def testUpdate(self): Email='john@doe.com', Birthdate=originaldate ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, Birthdate', 'Contact', [id]) + contacts = self.svc.retrieve('LastName, Birthdate', 'Contact', [id]) self.assertEqual(contacts[0]['Birthdate'], originaldate) self.assertEqual(contacts[0]['LastName'], lastname) data = dict(type='Contact', Id=id, Birthdate=newdate) - svc.update(data) - contacts = svc.retrieve('LastName, Birthdate', 'Contact', [id]) + self.svc.update(data) + contacts = self.svc.retrieve('LastName, Birthdate', 'Contact', [id]) self.assertEqual(contacts[0]['Birthdate'], newdate) self.assertEqual(contacts[0]['LastName'], lastname) def testShrinkMultiPicklist(self): - svc = self.svc originalList = ["Pear", "Apple"] newList = ["Pear", ] lastname = 'Doe' @@ -296,20 +293,27 @@ def testShrinkMultiPicklist(self): Email='john@doe.com', Favorite_Fruit__c=originalList ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 2) data = dict(type='Contact', Id=id, Favorite_Fruit__c=newList) - svc.update(data) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + self.svc.update(data) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 1) def testGrowMultiPicklist(self): - svc = self.svc originalList = ["Pear", "Apple"] newList = ["Pear", "Apple", "Orange"] lastname = 'Doe' @@ -320,20 +324,27 @@ def testGrowMultiPicklist(self): Email='john@doe.com', Favorite_Fruit__c=originalList ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 2) data = dict(type='Contact', Id=id, Favorite_Fruit__c=newList) - svc.update(data) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + self.svc.update(data) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 3) def testUpdateDeleted(self): - svc = self.svc originaldate = datetime.date(1970, 1, 4) newdate = datetime.date(1970, 1, 5) lastname = 'Doe' @@ -344,20 +355,19 @@ def testUpdateDeleted(self): Email='john@doe.com', Birthdate=originaldate ) - res = svc.create(data) + res = self.svc.create(data) id = res[0]['id'] - svc.delete(id) - contacts = svc.retrieve('LastName, Birthdate', 'Contact', [id]) + self.svc.delete(id) + contacts = self.svc.retrieve('LastName, Birthdate', 'Contact', [id]) self.assertEqual(len(contacts), 0) data = dict(type='Contact', Id=id, Birthdate=newdate) - res = svc.update(data) + res = self.svc.update(data) self.assertTrue(not res[0]['success']) self.assertTrue(len(res[0]['errors']) > 0) def testQuery(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -365,7 +375,7 @@ def testQuery(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) self._todelete.append(res[0]['id']) data2 = dict(type='Contact', LastName='Doe', @@ -374,17 +384,16 @@ def testQuery(self): Email='jane@doe.com', Birthdate=datetime.date(1972, 10, 15) ) - res = svc.create([data2]) + res = self.svc.create([data2]) janeid = res[0]['id'] self._todelete.append(janeid) - res = svc.query("SELECT LastName, FirstName, Phone, Email, Birthdate FROM Contact WHERE LastName = 'Doe'") + res = self.svc.query("SELECT LastName, FirstName, Phone, Email, Birthdate FROM Contact WHERE LastName = 'Doe'") self.assertEqual(len(res), 2) - res = svc.query("SELECT Id, LastName, FirstName, Phone, Email, Birthdate FROM Contact WHERE LastName = 'Doe' and FirstName = 'Jane'") + res = self.svc.query("SELECT Id, LastName, FirstName, Phone, Email, Birthdate FROM Contact WHERE LastName = 'Doe' and FirstName = 'Jane'") self.assertEqual(len(res), 1) self.assertEqual(res[0]['Id'], janeid) def testBackwardsCompatibleQuery(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -392,7 +401,7 @@ def testBackwardsCompatibleQuery(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create([data]) + res = self.svc.create([data]) self._todelete.append(res[0]['id']) data2 = dict(type='Contact', LastName='Doe', @@ -401,19 +410,25 @@ def testBackwardsCompatibleQuery(self): Email='jane@doe.com', Birthdate=datetime.date(1972, 10, 15) ) - res = svc.create([data2]) + res = self.svc.create([data2]) janeid = res[0]['id'] self._todelete.append(janeid) # conditional expression as positional arg - res = svc.query('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', "LastName = 'Doe'") + res = self.svc.query( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + "LastName = 'Doe'", + ) self.assertEqual(len(res), 2) # conditional expression as *empty* positional arg - res = svc.query('LastName', 'Contact', '') + res = self.svc.query('LastName', 'Contact', '') self.assertTrue(len(res) > 0) # conditional expression as kwarg - res = svc.query('Id, LastName, FirstName, Phone, Email, Birthdate', - 'Contact', conditionalExpression="LastName = 'Doe' and FirstName = 'Jane'") + res = self.svc.query( + 'Id, LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + conditionalExpression="LastName = 'Doe' and FirstName = 'Jane'", + ) self.assertEqual(len(res), 1) self.assertEqual(res[0]['Id'], janeid) @@ -445,46 +460,61 @@ def patched_describeSObjects(self, sObjectTypes): self.svc.cacheTypeDescriptions = False def testChildToParentMultiQuery(self): - svc = self.svc - account_data = dict(type='Account', - Name='ChildTestAccount', - AccountNumber='987654321', - Site='www.testsite.com', - ) - account = svc.create([account_data]) + account_data = dict( + type='Account', + Name='ChildTestAccount', + AccountNumber='987654321', + Site='www.testsite.com', + ) + account = self.svc.create([account_data]) self._todelete.append(account[0]['id']) - contact_data = dict(type='Contact', - LastName='TestLastName', - FirstName='TestFirstName', - Phone='123-456-7890', - AccountID=account[0]['id'], - Email='testfirstname@testlastname.com', - Birthdate=datetime.date(1965, 1, 5) - ) - contact = svc.create([contact_data]) + contact_data = dict( + type='Contact', + LastName='TestLastName', + FirstName='TestFirstName', + Phone='123-456-7890', + AccountID=account[0]['id'], + Email='testfirstname@testlastname.com', + Birthdate=datetime.date(1965, 1, 5), + ) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) - query_res = svc.query("Id, LastName, FirstName, Account.Site, Account.AccountNumber", - "Contact", - "Phone='123-456-7890'" - ) + query_res = self.svc.query( + "Id, LastName, FirstName, Account.Site, Account.AccountNumber", + "Contact", + "Phone='123-456-7890'", + ) self.assertEqual(query_res.size, 1) rr = query_res.records[0] self.assertEqual(rr.type, 'Contact') - map(self.assertEqual, - [rr.Id, rr.LastName, rr.FirstName, rr.Account.Site, rr.Account.AccountNumber], - [contact[0]['id'], contact_data['LastName'], contact_data['FirstName'], account_data['Site'], account_data['AccountNumber']]) + map( + self.assertEqual, + [ + rr.Id, + rr.LastName, + rr.FirstName, + rr.Account.Site, + rr.Account.AccountNumber, + ], + [ + contact[0]['id'], + contact_data['LastName'], + contact_data['FirstName'], + account_data['Site'], + account_data['AccountNumber'], + ], + ) def testChildToParentMultiQuery2(self): - svc = self.svc paccount_data = dict(type='Account', Name='ParentTestAccount', AccountNumber='123456789', Site='www.testsite.com', ) - paccount = svc.create([paccount_data]) + paccount = self.svc.create([paccount_data]) self._todelete.append(paccount[0]['id']) caccount_data = dict(type='Account', @@ -493,7 +523,7 @@ def testChildToParentMultiQuery2(self): Site='www.testsite.com', ParentID=paccount[0]['id'] ) - caccount = svc.create([caccount_data]) + caccount = self.svc.create([caccount_data]) self._todelete.append(caccount[0]['id']) contact_data = dict(type='Contact', @@ -504,29 +534,43 @@ def testChildToParentMultiQuery2(self): Email='testfirstname@testlastname.com', Birthdate=datetime.date(1965, 1, 5) ) - contact = svc.create([contact_data]) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) - query_res = svc.query("Id, LastName, FirstName, Account.Site, Account.Parent.AccountNumber", - "Contact", - "Account.AccountNumber='987654321'" - ) + query_res = self.svc.query( + "Id, LastName, FirstName, Account.Site, Account.Parent.AccountNumber", + "Contact", + "Account.AccountNumber='987654321'", + ) rr = query_res.records[0] self.assertEqual(query_res.size, 1) self.assertEqual(rr.type, 'Contact') - map(self.assertEqual, - [rr.Id, rr.LastName, rr.FirstName, rr.Account.Site, rr.Account.Parent.AccountNumber], - [contact[0]['id'], contact_data['LastName'], contact_data['FirstName'], caccount_data['Site'], paccount_data['AccountNumber']]) + map( + self.assertEqual, + [ + rr.Id, + rr.LastName, + rr.FirstName, + rr.Account.Site, + rr.Account.Parent.AccountNumber, + ], + [ + contact[0]['id'], + contact_data['LastName'], + contact_data['FirstName'], + caccount_data['Site'], + paccount_data['AccountNumber'], + ], + ) def testParentToChildMultiQuery(self): - svc = self.svc caccount_data = dict(type='Account', Name='ChildTestAccount', AccountNumber='987654321', Site='www.testsite.com', ) - caccount = svc.create([caccount_data]) + caccount = self.svc.create([caccount_data]) self._todelete.append(caccount[0]['id']) contact_data = dict(type='Contact', @@ -537,7 +581,7 @@ def testParentToChildMultiQuery(self): Email='testfirstname@testlastname.com', Birthdate=datetime.date(1965, 1, 5) ) - contact = svc.create([contact_data]) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) contact_data2 = dict(type='Contact', @@ -548,13 +592,14 @@ def testParentToChildMultiQuery(self): Email='testfirstname2@testlastname2.com', Birthdate=datetime.date(1965, 1, 5) ) - contact2 = svc.create([contact_data2]) + contact2 = self.svc.create([contact_data2]) self._todelete.append(contact2[0]['id']) - query_res = svc.query("Id, Name, (select FirstName from Contacts)", - "Account", - "AccountNumber='987654321'" - ) + query_res = self.svc.query( + "Id, Name, (select FirstName from Contacts)", + "Account", + "AccountNumber='987654321'", + ) rr = query_res.records[0] self.assertEqual(query_res.size, 1) @@ -565,13 +610,12 @@ def testParentToChildMultiQuery(self): [caccount[0]['id'], caccount_data['Name']]) def testParentToChildMultiQuery2(self): - svc = self.svc caccount_data = dict(type='Account', Name='ChildTestAccount', AccountNumber='987654321', Site='www.testsite.com', ) - caccount = svc.create([caccount_data]) + caccount = self.svc.create([caccount_data]) self._todelete.append(caccount[0]['id']) contact_data = dict(type='Contact', @@ -582,7 +626,7 @@ def testParentToChildMultiQuery2(self): Email='testfirstname@testlastname.com', Birthdate=datetime.date(1965, 1, 5) ) - contact = svc.create([contact_data]) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) contact_data2 = dict(type='Contact', @@ -593,13 +637,14 @@ def testParentToChildMultiQuery2(self): Email='testfirstname2@testlastname2.com', Birthdate=datetime.date(1965, 1, 5) ) - contact2 = svc.create([contact_data2]) + contact2 = self.svc.create([contact_data2]) self._todelete.append(contact2[0]['id']) - query_res = svc.query("Id, Name, (select FirstName, Account.Site from Contacts), (select Name from Assets)", - "Account", - "AccountNumber='987654321'" - ) + query_res = self.svc.query( + "Id, Name, (select FirstName, Account.Site from Contacts), (select Name from Assets)", + "Account", + "AccountNumber='987654321'", + ) rr = query_res.records[0] self.assertEqual(query_res.size, 1) @@ -617,7 +662,6 @@ def testParentToChildMultiQuery2(self): self.assertEqual(result, rr.Contacts.size) def testMultiQueryCount(self): - svc = self.svc contact_data = dict(type='Contact', LastName='TestLastName', FirstName='TestFirstName', @@ -625,7 +669,7 @@ def testMultiQueryCount(self): Email='testfirstname@testlastname.com', Birthdate=datetime.date(1965, 1, 5) ) - contact = svc.create([contact_data]) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) contact_data2 = dict(type='Contact', @@ -635,18 +679,18 @@ def testMultiQueryCount(self): Email='testfirstname2@testlastname2.com', Birthdate=datetime.date(1965, 1, 5) ) - contact2 = svc.create([contact_data2]) + contact2 = self.svc.create([contact_data2]) self._todelete.append(contact2[0]['id']) - query_res = svc.query("count()", - "Contact", - "Phone='123-456-7890'" - ) + query_res = self.svc.query( + "count()", + "Contact", + "Phone='123-456-7890'", + ) self.assertEqual(query_res.size, 2) def testAggregateQuery(self): - svc = self.svc contact_data = dict(type='Contact', LastName='TestLastName', FirstName='TestFirstName', @@ -654,10 +698,10 @@ def testAggregateQuery(self): Email='testfirstname@testlastname.com', Birthdate=datetime.date(1900, 1, 5) ) - contact = svc.create([contact_data]) + contact = self.svc.create([contact_data]) self._todelete.append(contact[0]['id']) - res = svc.query("SELECT MAX(CreatedDate) FROM Contact GROUP BY LastName") + res = self.svc.query("SELECT MAX(CreatedDate) FROM Contact GROUP BY LastName") # the aggregate result is in the 'expr0' attribute of the result self.assertTrue(hasattr(res[0], 'expr0')) # (unfortunately no field type info is returned as part of the @@ -665,13 +709,15 @@ def testAggregateQuery(self): # correct Python type) def testQueryDoesNotExist(self): - res = self.svc.query('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', "LastName = 'Doe'") + res = self.svc.query( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + "LastName = 'Doe'", + ) self.assertEqual(len(res), 0) def testQueryMore(self): - svc = self.svc - svc.batchSize = 100 + self.svc.batchSize = 100 data = list() for x in range(250): data.append(dict(type='Contact', @@ -681,17 +727,20 @@ def testQueryMore(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) )) - res = svc.create(data[:200]) + res = self.svc.create(data[:200]) ids = [x['id'] for x in res] self._todelete.extend(ids) - res = svc.create(data[200:]) + res = self.svc.create(data[200:]) ids = [x['id'] for x in res] self._todelete.extend(ids) - res = svc.query('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', "LastName = 'Doe'") + res = self.svc.query( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + "LastName = 'Doe'", + ) self.assertTrue(not res['done']) self.assertEqual(len(res), 200) - res = svc.queryMore(res['queryLocator']) + res = self.svc.queryMore(res['queryLocator']) self.assertTrue(res['done']) self.assertEqual(len(res), 50) @@ -719,7 +768,6 @@ def testSearch(self): self.assertEqual(len(res), 0) def testGetDeleted(self): - svc = self.svc startdate = datetime.datetime.utcnow() enddate = startdate + datetime.timedelta(seconds=61) data = dict(type='Contact', @@ -729,16 +777,15 @@ def testGetDeleted(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create(data) + res = self.svc.create(data) id = res[0]['id'] - svc.delete(id) - res = svc.getDeleted('Contact', startdate, enddate) + self.svc.delete(id) + res = self.svc.getDeleted('Contact', startdate, enddate) self.assertTrue(len(res) != 0) ids = [r['id'] for r in res] self.assertTrue(id in ids) def testGetUpdated(self): - svc = self.svc startdate = datetime.datetime.utcnow() enddate = startdate + datetime.timedelta(seconds=61) data = dict(type='Contact', @@ -748,19 +795,18 @@ def testGetUpdated(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.create(data) + res = self.svc.create(data) id = res[0]['id'] self._todelete.append(id) data = dict(type='Contact', Id=id, FirstName='Jane') - svc.update(data) - res = svc.getUpdated('Contact', startdate, enddate) + self.svc.update(data) + res = self.svc.getUpdated('Contact', startdate, enddate) self.assertTrue(id in res) def testGetUserInfo(self): - svc = self.svc - userinfo = svc.getUserInfo() + userinfo = self.svc.getUserInfo() self.assertTrue('accessibilityMode' in userinfo) self.assertTrue('currencySymbol' in userinfo) self.assertTrue('organizationId' in userinfo) @@ -789,12 +835,10 @@ def testDescribeTabs(self): self.assertTrue('url' in tab) def testDescribeLayout(self): - svc = self.svc - self.assertRaises(NotImplementedError, svc.describeLayout, + self.assertRaises(NotImplementedError, self.svc.describeLayout, 'Contact') def testSetMultiPicklistToEmpty(self): - svc = self.svc originalList = ["Pear", "Apple"] newList = [] lastname = 'Doe' @@ -803,21 +847,28 @@ def testSetMultiPicklistToEmpty(self): FirstName='John', Favorite_Fruit__c=originalList ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 2) data = dict(type='Contact', Id=id, Favorite_Fruit__c=newList) - svc.update(data) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + self.svc.update(data) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertTrue(isinstance(contacts[0]['Favorite_Fruit__c'], list)) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 0) def testAddToEmptyMultiPicklist(self): - svc = self.svc originalList = [] newList = ["Pear", "Apple"] lastname = 'Doe' @@ -826,29 +877,35 @@ def testAddToEmptyMultiPicklist(self): FirstName='John', Favorite_Fruit__c=originalList ) - res = svc.create([data]) + res = self.svc.create([data]) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertTrue(isinstance(contacts[0]['Favorite_Fruit__c'], list)) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 0) data = dict(type='Contact', Id=id, Favorite_Fruit__c=newList) - svc.update(data) - contacts = svc.retrieve('LastName, Favorite_Fruit__c', 'Contact', [id]) + self.svc.update(data) + contacts = self.svc.retrieve( + 'LastName, Favorite_Fruit__c', + 'Contact', + [id], + ) self.assertTrue(isinstance(contacts[0]['Favorite_Fruit__c'], list)) self.assertEqual(len(contacts[0]['Favorite_Fruit__c']), 2) def testIsNillableField(self): - svc = self.svc - res = svc.describeSObjects('Contact') + res = self.svc.describeSObjects('Contact') self.assertFalse(res[0].fields['LastName'].nillable) self.assertTrue(res[0].fields['FirstName'].nillable) self.assertTrue(res[0].fields['Favorite_Fruit__c'].nillable) def testUpsert(self): - svc = self.svc data = dict(type='Contact', LastName='Doe', FirstName='John', @@ -856,14 +913,17 @@ def testUpsert(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4) ) - res = svc.upsert('Email', [data]) + res = self.svc.upsert('Email', [data]) self.assertTrue(type(res) in (list, tuple)) self.assertTrue(len(res) == 1) self.assertTrue(res[0]['success']) id = res[0]['id'] self._todelete.append(id) - contacts = svc.retrieve('LastName, FirstName, Phone, Email, Birthdate', - 'Contact', [id]) + contacts = self.svc.retrieve( + 'LastName, FirstName, Phone, Email, Birthdate', + 'Contact', + [id], + ) self.assertEqual(len(contacts), 1) contact = contacts[0] for k in ['LastName', 'FirstName', 'Phone', 'Email', 'Birthdate']: diff --git a/tests/xmlclient_test.py b/tests/xmlclient_test.py index 997cff9..0cb87b3 100644 --- a/tests/xmlclient_test.py +++ b/tests/xmlclient_test.py @@ -10,9 +10,7 @@ partnerns = pyforce.pyclient._tPartnerNS sobjectns = pyforce.pyclient._tSObjectNS -SERVER_URL = "https://test.salesforce.com/services/Soap/u/20.0" -svc = pyforce.XMLClient(SERVER_URL) - +DEFAULT_HOSTNAME = "test.salesforce.com" DELAY_RETRY = 10 DELAY_SEC = 2 @@ -20,12 +18,16 @@ class TestBeatbox(unittest.TestCase): def setUp(self): - svc.login(os.getenv('SF_USERNAME'), os.getenv('SF_PASSWORD')) + hostname = os.getenv('SF_HOSTNAME', DEFAULT_HOSTNAME) + server_url = "https://{}/services/Soap/u/20.0".format(hostname) + self.svc = pyforce.XMLClient(server_url) + password = os.getenv('SF_PASSWORD') + os.getenv('SF_SECTOKEN', '') + self.svc.login(os.getenv('SF_USERNAME'), password) self._todelete = list() def tearDown(self): for id in self._todelete: - svc.delete(id) + self.svc.delete(id) def testCreate(self): data = dict( @@ -36,11 +38,11 @@ def testCreate(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4), ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertEqual(str(res[partnerns.success]), 'true') id = str(res[partnerns.id]) self._todelete.append(id) - contact = svc.retrieve( + contact = self.svc.retrieve( 'LastName, FirstName, Phone, Email', 'Contact', [id], @@ -55,11 +57,11 @@ def testUpdate(self): FirstName='John', Email='john@doe.com', ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertEqual(str(res[partnerns.success]), 'true') id = str(res[partnerns.id]) self._todelete.append(id) - contact = svc.retrieve('Email', 'Contact', [id]) + contact = self.svc.retrieve('Email', 'Contact', [id]) self.assertEqual( str(contact[sobjectns.Email]), data['Email']) updata = dict( @@ -67,9 +69,9 @@ def testUpdate(self): Id=id, Email='jd@doe.com', ) - res = svc.update(updata) + res = self.svc.update(updata) self.assertEqual(str(res[partnerns.success]), 'true') - contact = svc.retrieve( + contact = self.svc.retrieve( 'LastName, FirstName, Email', 'Contact', [id], @@ -91,7 +93,7 @@ def testQuery(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4), ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertEqual(str(res[partnerns.success]), 'true') self._todelete.append(str(res[partnerns.id])) data2 = dict( @@ -102,17 +104,17 @@ def testQuery(self): Email='jane@doe.com', Birthdate=datetime.date(1972, 10, 15), ) - res = svc.create([data2]) + res = self.svc.create([data2]) self.assertEqual(str(res[partnerns.success]), 'true') janeid = str(res[partnerns.id]) self._todelete.append(janeid) query = ("select LastName, FirstName, Phone, Email, Birthdate " "from Contact where LastName = 'Doe'") - res = svc.query(query) + res = self.svc.query(query) self.assertEqual(int(str(res[partnerns.size])), 2) query = ("select Id, LastName, FirstName, Phone, Email, Birthdate " "from Contact where LastName = 'Doe' and FirstName = 'Jane'") - res = svc.query(query) + res = self.svc.query(query) self.assertEqual(int(str(res[partnerns.size])), 1) records = res[partnerns.records, ] self.assertEqual( @@ -127,14 +129,14 @@ def testSearch(self): Email='john@doe.com', Birthdate=datetime.date(1970, 1, 4), ) - res = svc.create([data]) + res = self.svc.create([data]) self.assertEqual(str(res[partnerns.success]), 'true') self._todelete.append(str(res[partnerns.id])) # Requires some delay for indexing for _ in range(DELAY_RETRY): sleep(DELAY_SEC) - res = svc.search( + res = self.svc.search( "FIND {Long} in ALL FIELDS RETURNING " "Contact(Id, LastName, FirstName, Phone, Email, Birthdate)" ) @@ -150,22 +152,22 @@ def testSendSimpleEmail(self): 'Salesforce sendEmail()' ), 'saveAsActivity': False, - 'toAddresses': str(svc.getUserInfo()['userEmail']), + 'toAddresses': str(self.svc.getUserInfo()['userEmail']), 'plainTextBody': ( 'This is a test email message with HTML markup.\n\n' 'You are currently looking at the plain-text body, ' 'but the message is sent in both forms.' ), } - res = svc.sendEmail([testemail]) + res = self.svc.sendEmail([testemail]) self.assertEqual(str(res[partnerns.success]), 'true') @unittest.skip("Email is not working...") def testSendEmailMissingFields(self): testemail = { - 'toAddresses': str(svc.getUserInfo()['userEmail']), + 'toAddresses': str(self.svc.getUserInfo()['userEmail']), } - res = svc.sendEmail([testemail]) + res = self.svc.sendEmail([testemail]) self.assertEqual(str(res[partnerns.success]), 'false') self.assertEqual( str(res[partnerns.errors][partnerns.statusCode]), @@ -187,7 +189,7 @@ def testSendHTMLEmailWithAttachment(self): ), 'useSignature': True, 'saveAsActivity': False, - 'toAddresses': str(svc.getUserInfo()['userEmail']), + 'toAddresses': str(self.svc.getUserInfo()['userEmail']), 'plainTextBody': ( 'This is a test email message with HTML markup.\n\n' 'You are currently looking at the plain-text body, ' @@ -198,15 +200,15 @@ def testSendHTMLEmailWithAttachment(self): 'references': '<1234567890123456789%example@example.com>', 'fileAttachments': [solid_logo] } - res = svc.sendEmail([testemail]) + res = self.svc.sendEmail([testemail]) self.assertEqual(str(res[partnerns.success]), 'true') def testLogout(self): """Logout and verify that the previous sessionId longer works.""" # from ipdb import set_trace; set_trace() - result = svc.getUserInfo() + result = self.svc.getUserInfo() self.assertTrue(hasattr(result, 'userId')) - response = svc.logout() + response = self.svc.logout() self.assertEqual( response._name, partnerns.logoutResponse, @@ -219,7 +221,7 @@ def testLogout(self): # Sometimes this doesn't work on the first try. Flakey... for _ in range(DELAY_RETRY): sleep(DELAY_SEC) - result = svc.getUserInfo() + result = self.svc.getUserInfo() self.assertEqual( cm.exception.faultCode, 'INVALID_SESSION_ID', diff --git a/tox.ini b/tox.ini index e0ee9af..64722e1 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ deps = -rrequirements-dev.txt # Streaming coverage omitted because baoicas is not in pypi [testenv] # Env for integration tests -passenv = SF_USERNAME SF_PASSWORD SF_SECTOKEN SF_VERSION +passenv = SF_USERNAME SF_PASSWORD SF_SECTOKEN SF_VERSION SF_HOSTNAME deps = {[base]deps} commands = pre-commit run --all-files From cf63c18d2046608e1452f9a5e44816dd441c93a4 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 13:21:11 -0700 Subject: [PATCH 2/6] Add tests to workflow --- .github/workflows/pythonpackage.yml | 34 ------------------------ .github/workflows/pythonpublish.yml | 33 ++++++++++++------------ .github/workflows/pythontests.yml | 40 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/pythonpackage.yml create mode 100644 .github/workflows/pythontests.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml deleted file mode 100644 index b7f6b1c..0000000 --- a/.github/workflows/pythonpackage.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.7] - # Eventually, when running tests this should be done for all versions - # python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install virtualenv - run: | - python -m pip install --upgrade pip - pip install virtualenv - - name: Run lint with pre-commit hooks - run: | - make check diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 4772ae9..d759711 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -1,3 +1,4 @@ +--- # This workflows will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries @@ -13,19 +14,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/pythontests.yml b/.github/workflows/pythontests.yml new file mode 100644 index 0000000..be06233 --- /dev/null +++ b/.github/workflows/pythontests.yml @@ -0,0 +1,40 @@ +--- +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7] + # Eventually, when running tests this should be done for all versions + # python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install virtualenv + run: | + python -m pip install --upgrade pip + pip install virtualenv + - name: Run lint with pre-commit hooks + env: + SF_USERNAME: ${{ secrets.SF_USERNAME }} + SF_PASSWORD: ${{ secrets.SF_PASSWORD }} + SF_SECTOKEN: ${{ secrets.SF_SECTOKEN }} + SF_HOSTNAME: ${{ secrets.SF_HOSTNAME }} + run: | + make test From 2e4bdc61802171989cada246ca65bdef2b93ba10 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 14:08:56 -0700 Subject: [PATCH 3/6] Fix indent on tests workflow --- .github/workflows/pythontests.yml | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pythontests.yml b/.github/workflows/pythontests.yml index be06233..9f1655e 100644 --- a/.github/workflows/pythontests.yml +++ b/.github/workflows/pythontests.yml @@ -20,21 +20,21 @@ jobs: # Eventually, when running tests this should be done for all versions # python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install virtualenv - run: | - python -m pip install --upgrade pip - pip install virtualenv - - name: Run lint with pre-commit hooks - env: - SF_USERNAME: ${{ secrets.SF_USERNAME }} - SF_PASSWORD: ${{ secrets.SF_PASSWORD }} - SF_SECTOKEN: ${{ secrets.SF_SECTOKEN }} - SF_HOSTNAME: ${{ secrets.SF_HOSTNAME }} - run: | - make test + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install virtualenv + run: | + python -m pip install --upgrade pip + pip install virtualenv + - name: Run lint with pre-commit hooks + env: + SF_USERNAME: ${{ secrets.SF_USERNAME }} + SF_PASSWORD: ${{ secrets.SF_PASSWORD }} + SF_SECTOKEN: ${{ secrets.SF_SECTOKEN }} + SF_HOSTNAME: ${{ secrets.SF_HOSTNAME }} + run: | + make test From 6cef25368f30efdfd014f0b93c20ea36c4a19911 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 14:11:40 -0700 Subject: [PATCH 4/6] Install tox in Workflow build --- .github/workflows/pythontests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythontests.yml b/.github/workflows/pythontests.yml index 9f1655e..64ef694 100644 --- a/.github/workflows/pythontests.yml +++ b/.github/workflows/pythontests.yml @@ -29,8 +29,8 @@ jobs: - name: Install virtualenv run: | python -m pip install --upgrade pip - pip install virtualenv - - name: Run lint with pre-commit hooks + pip install tox + - name: Run tests env: SF_USERNAME: ${{ secrets.SF_USERNAME }} SF_PASSWORD: ${{ secrets.SF_PASSWORD }} From 4c4c54da20554b13f3a9d38092947ef157b893ea Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 14:22:11 -0700 Subject: [PATCH 5/6] Add lint test again --- .github/workflows/pythonlint.yml | 35 +++++++++++++++++++++++++++++++ .github/workflows/pythontests.yml | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pythonlint.yml diff --git a/.github/workflows/pythonlint.yml b/.github/workflows/pythonlint.yml new file mode 100644 index 0000000..81ba3a8 --- /dev/null +++ b/.github/workflows/pythonlint.yml @@ -0,0 +1,35 @@ +--- +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python lint + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7] + # Eventually, when running tests this should be done for all versions + # python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install virtualenv + run: | + python -m pip install --upgrade pip + pip install virtualenv + - name: Run lint + run: | + make check diff --git a/.github/workflows/pythontests.yml b/.github/workflows/pythontests.yml index 64ef694..1a4e872 100644 --- a/.github/workflows/pythontests.yml +++ b/.github/workflows/pythontests.yml @@ -26,7 +26,7 @@ jobs: uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - - name: Install virtualenv + - name: Install tox run: | python -m pip install --upgrade pip pip install tox From 1acfb0f52b7615364d10c57121a36f8c881a3988 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 13 Apr 2020 14:25:36 -0700 Subject: [PATCH 6/6] Stop trying to run tests on prs --- .github/workflows/pythontests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pythontests.yml b/.github/workflows/pythontests.yml index 1a4e872..8fe4b91 100644 --- a/.github/workflows/pythontests.yml +++ b/.github/workflows/pythontests.yml @@ -7,8 +7,6 @@ name: Python tests on: push: branches: [master] - pull_request: - branches: [master] jobs: build: