Skip to content

Commit

Permalink
Merge pull request #9 from SEED-platform/prep-tests
Browse files Browse the repository at this point in the history
restore tests
  • Loading branch information
nllong authored Mar 3, 2023
2 parents c07653b + c1bd94e commit 050e29d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "seed-salesforce"
version = "0.1.0"
description = "Package for connecting SEED data to Salesforce"
authors = ["Nicholas Long <[email protected]>"]
authors = ["Nicholas Long <[email protected]>", "Katherine Fleming <[email protected]>"]
license = "BSD-3-Clause"

readme = "README.md"
Expand Down
24 changes: 13 additions & 11 deletions tests/test_salesforce_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Alliance for Sustainable Energy, LLC. See also https://github.com/seed-platform/seed-salesforce/blob/develop/LICENSE.md

import random
import unittest
from pathlib import Path

Expand All @@ -14,7 +15,7 @@ def test_init_by_file(self):
sf = SalesforceClient(connection_config_filepath=config_file)
# check if the Salesforce connection has the base_url method and that it is not None
assert hasattr(sf.connection, 'base_url')
print(f"sf connection: {sf.connection.base_url}")
# print(f"sf connection: {sf.connection.base_url}")
assert sf.connection.base_url is not None


Expand All @@ -37,9 +38,10 @@ def setUp(self) -> None:

return super().setUp()

@pytest.mark.skip(reason="Need to confirm that this is a valid test")
# @pytest.mark.skip(reason="Need to confirm that this is a valid test")
def test_search_and_create_and_delete_account(self):
test_account_name = 'Scrumptious Ice Cream'
r = random.randrange(1, 5000, 2)
test_account_name = 'Scrumptious Ice Cream' + str(r)
account = self.sf.find_account_by_name(test_account_name)
# The first time should not have any results
assert not account
Expand All @@ -61,16 +63,16 @@ def test_search_and_create_and_delete_account(self):

# Find the record
account = self.sf.find_account_by_name(test_account_name)
print(f"hasdlfkjasdlfkjasdflkj {account}")
assert account['Id'] == account_id

# now delete it to cleanup
success = self.sf.delete_account_by_id(account_id)
assert success

@pytest.mark.skip(reason="Need to confirm that this is a valid test")
# @pytest.mark.skip(reason="Need to confirm that this is a valid test")
def test_update_contact_and_account(self):
test_account_name = 'A Fake Account'
r = random.randrange(1, 5000, 2)
test_account_name = 'A Fake Account' + str(r)
details = {
'Type': 'Office',
'Phone': '555-867-5309',
Expand All @@ -93,22 +95,22 @@ def test_update_contact_and_account(self):
# create contact (associated with account)
details = {
'AccountId': account_id,
'LastName': 'Richard Hendrick'
'LastName': 'Richard Hendrick' + str(r)
}
if self.contact_record_type:
details['RecordTypeID'] = self.contact_record_type

self.sf.create_contact('[email protected]', **details)
self.sf.create_contact('user' + str(r) + '@company.com', **details)
# retrieve contact
contact = self.sf.find_contact_by_email('[email protected]')
contact = self.sf.find_contact_by_email('user' + str(r) + '@company.com')
assert contact['AccountId'] == account_id

# update contact (can't change email)
details = {
'AccountId': account_id,
'LastName': 'Russ Hanneman'
'LastName': 'Russ Hanneman' + str(r)
}
self.sf.create_or_update_contact_on_account('[email protected]', **details)
self.sf.create_or_update_contact_on_account('user' + str(r) + '@company.com', **details)
assert contact['AccountId'] == account_id

# now delete it to cleanup
Expand Down

0 comments on commit 050e29d

Please sign in to comment.