Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ej2 committed Jul 9, 2024
1 parent 89a38ac commit 39e56d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/integration/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AccountTest(QuickbooksTestCase):
def setUp(self):
super(AccountTest, self).setUp()

self.time = datetime.now()
self.account_number = datetime.now().strftime('%d%H%M')
self.name = "Test Account {0}".format(self.account_number)

Expand Down Expand Up @@ -35,8 +36,8 @@ def test_update(self):

def test_create_using_from_json(self):
account = Account.from_json({
"AcctNum": self.account_number,
"Name": self.name,
"AcctNum": datetime.now().strftime('%d%H%M%S'),
"Name": "{} {}".format(self.name, self.time.strftime("%Y-%m-%d %H:%M:%S")),
"AccountSubType": "CashOnHand"
})

Expand Down
13 changes: 12 additions & 1 deletion tests/integration/test_attachable.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,31 @@ def test_update_note(self):

def test_create_file(self):
attachable = Attachable()
test_file = tempfile.NamedTemporaryFile(suffix=".txt")
test_file = tempfile.NamedTemporaryFile(mode='w+t', suffix=".txt", delete=False)

with test_file as f:
f.write("File contents")
f.flush()

vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]

attachable_ref = AttachableRef()
attachable_ref.EntityRef = vendor.to_ref()
attachable.AttachableRef.append(attachable_ref)

attachable.Note = "Sample note"
attachable.FileName = os.path.basename(test_file.name)
attachable._FilePath = test_file.name
attachable.ContentType = 'text/plain'

attachable.save(qb=self.qb_client)

test_file.close()
os.unlink(test_file.name)

query_attachable = Attachable.get(attachable.Id, qb=self.qb_client)

self.assertEqual(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
self.assertEqual(query_attachable.Note, "Sample note")


0 comments on commit 39e56d2

Please sign in to comment.