Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…c-preimporter into develop
  • Loading branch information
kflemin committed Apr 8, 2022
2 parents 008f6b2 + a2d0b2d commit df3e8f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/test_buildingsync_asset_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"""
import unittest
from pathlib import Path
from shutil import rmtree

from buildingsync_asset_extractor.processor import BSyncProcessor

Expand All @@ -46,13 +45,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)
Expand All @@ -66,6 +64,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()
Expand All @@ -90,6 +91,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'
Expand Down Expand Up @@ -130,5 +134,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())

0 comments on commit df3e8f8

Please sign in to comment.