Skip to content

Commit a24919b

Browse files
committed
Completes default construction set test
1 parent 9d481c5 commit a24919b

File tree

2 files changed

+61
-23
lines changed

2 files changed

+61
-23
lines changed

src/osut/osut.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -778,20 +778,20 @@ def genMass(sps=None, ratio=2.0) -> bool:
778778
return True
779779

780780

781-
def holdsConstruction(set=None, bse=None, gr=False, ex=False, tp=""):
781+
def holdsConstruction(set=None, base=None, gr=False, ex=False, type=""):
782782
"""Validates whether a default construction set holds an opaque base
783783
construction.
784784
785785
Args:
786786
set (openstudio.model.DefaultConstructionSet):
787787
A default construction set.
788-
bse (openstudio.model.ConstructionBase):
788+
base (openstudio.model.ConstructionBase):
789789
A construction base.
790790
gr (bool):
791791
Whether ground-facing surface.
792792
ex (bool):
793793
Whether exterior-facing surface.
794-
tp:
794+
type:
795795
A surface type ("Wall", "Floor", "RoofCeiling").
796796
797797
Returns:
@@ -805,21 +805,21 @@ def holdsConstruction(set=None, bse=None, gr=False, ex=False, tp=""):
805805

806806
if not isinstance(set, cl1):
807807
return oslg.invalid("set" , mth, 1, CN.DBG, False)
808-
if not isinstance(bse, cl2):
808+
if not isinstance(base, cl2):
809809
return oslg.invalid("base", mth, 2, CN.DBG, False)
810810
if gr not in [True, False]:
811811
return oslg.invalid("ground", mth, 3, CN.DBG, False)
812812
if ex not in [True, False]:
813813
return oslg.invalid("exterior", mth, 4, CN.DBG, False)
814814

815815
try:
816-
tp = str(tp)
816+
type = str(type)
817817
except ValueError as e:
818-
return oslg.mismatch("surface type", tp, str, mth, CN.DBG, False)
818+
return oslg.mismatch("surface type", type, str, mth, CN.DBG, False)
819819

820-
type = tp.lower()
820+
type = type.lower()
821821

822-
if tp not in ["floor", "wall", "roofceiling"]:
822+
if type not in ["floor", "wall", "roofceiling"]:
823823
return oslg.invalid("surface type", mth, 5, CN.DBG, False)
824824

825825
constructions = None
@@ -839,15 +839,15 @@ def holdsConstruction(set=None, bse=None, gr=False, ex=False, tp=""):
839839
if type == "roofceiling":
840840
if constructions.roofCeilingConstruction():
841841
construction = constructions.roofCeilingConstruction().get()
842-
if construction == bse: return True
842+
if construction == base: return True
843843
elif type == "floor":
844844
if constructions.floorConstruction():
845845
construction = constructions.floorConstruction().get()
846-
if construction == bse: return True
846+
if construction == base: return True
847847
else:
848848
if constructions.wallConstruction():
849849
construction = constructions.wallConstruction().get()
850-
if construction == bse: return True
850+
if construction == base: return True
851851

852852
return False
853853

@@ -872,7 +872,7 @@ def defaultConstructionSet(s=None):
872872
if not s.isConstructionDefaulted():
873873
oslg.log(CN.WRN, "construction not defaulted (%s)" % mth)
874874
return None
875-
if s.construction():
875+
if not s.construction():
876876
return oslg.empty("construction", mth, CN.WRN)
877877
if not s.space():
878878
return oslg.empty("space", mth, CN.WRN)
@@ -881,7 +881,7 @@ def defaultConstructionSet(s=None):
881881
base = s.construction().get()
882882
space = s.space().get()
883883
type = s.surfaceType()
884-
bnd = s.outsideBoundaryCondition().downcase()
884+
bnd = s.outsideBoundaryCondition().lower()
885885

886886
ground = True if s.isGroundSurface() else False
887887
exterior = True if bnd == "outdoors" else False

tests/test_osut.py

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,8 @@ def test07_construction_thickness(self):
854854
self.assertEqual(o.status(), 0)
855855
self.assertFalse(o.logs())
856856

857+
del(model)
858+
857859
def test08_holds_constructions(self):
858860
o = osut.oslg
859861
self.assertEqual(o.status(), 0)
@@ -930,12 +932,50 @@ def test08_holds_constructions(self):
930932
self.assertEqual(o.logs()[0]["message"], m6)
931933
self.assertEqual(o.clean(), DBG)
932934

933-
# def test09_construction_set(self):
934-
# o = osut.oslg
935-
# self.assertEqual(o.status(), 0)
936-
# self.assertEqual(o.reset(DBG), DBG)
937-
# self.assertEqual(o.level(), DBG)
938-
# self.assertEqual(o.status(), 0)
935+
del(model)
936+
del(mdl)
937+
938+
def test09_construction_set(self):
939+
o = osut.oslg
940+
self.assertEqual(o.status(), 0)
941+
self.assertEqual(o.reset(DBG), DBG)
942+
self.assertEqual(o.level(), DBG)
943+
self.assertEqual(o.status(), 0)
944+
945+
version = int("".join(openstudio.openStudioVersion().split(".")))
946+
translator = openstudio.osversion.VersionTranslator()
947+
948+
m = "construction not defaulted (osut.defaultConstructionSet)"
949+
950+
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
951+
path = openstudio.path("./tests/files/osms/in/5ZoneNoHVAC.osm")
952+
model = translator.loadModel(path)
953+
self.assertTrue(model)
954+
model = model.get()
955+
956+
for s in model.getSurfaces():
957+
set = osut.defaultConstructionSet(s)
958+
self.assertTrue(set)
959+
self.assertEqual(o.status(), 0)
960+
961+
del(model)
962+
963+
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- #
964+
path = openstudio.path("./tests/files/osms/out/seb2.osm")
965+
model = translator.loadModel(path)
966+
self.assertTrue(model)
967+
model = model.get()
968+
969+
for s in model.getSurfaces():
970+
set = osut.defaultConstructionSet(s)
971+
self.assertFalse(set)
972+
self.assertTrue(o.is_warn())
973+
974+
for l in o.logs(): self.assertEqual(l["message"], m)
975+
976+
self.assertEqual(o.clean(), DBG)
977+
978+
del(model)
939979

940980
# def test10_glazing_airfilms(self):
941981
# o = osut.oslg
@@ -1036,6 +1076,7 @@ def test12_insulating_layer(self):
10361076
self.assertTrue(len(o.logs()), 1)
10371077
self.assertTrue(m0 in o.logs()[0]["message"])
10381078
self.assertEqual(o.clean(), DBG)
1079+
del(model)
10391080

10401081
# def test13_spandrels(self):
10411082
# o = osut.oslg
@@ -1281,10 +1322,7 @@ def test36_roller_shades(self):
12811322
#
12821323
# file = File.join(__dir__, "files/osms/out/seb_ext5.osm")
12831324
# model.save(file, true)
1284-
1285-
1286-
1287-
1325+
del(model)
12881326

12891327
if __name__ == "__main__":
12901328
unittest.main()

0 commit comments

Comments
 (0)