From 39e56d2c48b05f0076abd50f07e7dfcabb9ab5a5 Mon Sep 17 00:00:00 2001 From: Edward Emanuel Date: Tue, 9 Jul 2024 10:35:40 -0500 Subject: [PATCH] Fix tests --- tests/integration/test_account.py | 5 +++-- tests/integration/test_attachable.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/integration/test_account.py b/tests/integration/test_account.py index 78d5b46..b90c953 100644 --- a/tests/integration/test_account.py +++ b/tests/integration/test_account.py @@ -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) @@ -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" }) diff --git a/tests/integration/test_attachable.py b/tests/integration/test_attachable.py index eec0593..2eeffab 100644 --- a/tests/integration/test_attachable.py +++ b/tests/integration/test_attachable.py @@ -41,7 +41,11 @@ 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] @@ -49,12 +53,19 @@ def test_create_file(self): 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") + +