From a2d0b2d33965fb40d0bd8647518896531eec0199 Mon Sep 17 00:00:00 2001 From: Nicholas Long Date: Thu, 3 Mar 2022 14:29:56 -0700 Subject: [PATCH] save output to testoutput_2 --- tests/test_buildingsync_asset_extractor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_buildingsync_asset_extractor.py b/tests/test_buildingsync_asset_extractor.py index a88e98a..6e3c31c 100644 --- a/tests/test_buildingsync_asset_extractor.py +++ b/tests/test_buildingsync_asset_extractor.py @@ -35,7 +35,6 @@ """ import unittest from pathlib import Path -from shutil import rmtree from buildingsync_asset_extractor import __version__ from buildingsync_asset_extractor.processor import BSyncProcessor @@ -47,13 +46,12 @@ def setUp(self): self.no_ns_testfile = Path(__file__).parent / 'files' / 'testfile2.xml' self.output_dir = Path(__file__).parent / 'output' self.out_file = 'testoutput.json' + self.out_file_2 = 'testoutput_2.json' self.num_assets_to_extract = 8 self.num_sections_in_testfile = 3 # create output dir - if self.output_dir.exists(): - rmtree(self.output_dir) - self.output_dir.mkdir(parents=True) + self.output_dir.mkdir(parents=True, exist_ok=True) print("TESTFILE: {}".format(self.testfile)) self.bp = BSyncProcessor(self.testfile) @@ -70,6 +68,9 @@ def test_initialize_and_parse(self): self.assertIsNotNone(doc) def test_extract(self): + filename = self.output_dir / self.out_file_2 + if filename.exists(): + filename.unlink() self.bp.extract() sections = self.bp.get_sections() @@ -94,6 +95,9 @@ def test_extract(self): age = next((item for item in assets if item["name"] == "Oldest Boiler"), None) self.assertEqual(age['value'], '2010') + filename = self.output_dir / self.out_file_2 + self.bp.save(filename) + def test_set_asset_defs(self): num_assets_to_extract = 9 test_assets_file = Path(__file__).parent / 'files' / 'test_asset_defs.json' @@ -134,5 +138,7 @@ def test_extract_no_ns(self): def test_save(self): filename = self.output_dir / self.out_file + if filename.exists(): + filename.unlink() self.bp.save(filename) self.assertTrue(filename.exists())