-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit_test.py
More file actions
50 lines (41 loc) · 1.48 KB
/
unit_test.py
File metadata and controls
50 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from gml_parser import *
from PVcalc import *
import unittest
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
self.gmldoc = read_gml('data/barnet8.gml')
self.buildings = extractElements(self.gmldoc)
def test_calcArea(self):
coordinates = extractCoordinates(self.buildings[0])
self.assertTrue(calcArea(coordinates)>0)
def setUpPVcalc(self):
buildingArea = calcBuildingArea(self.building)
self.area = calcAreaSolarPanels(buildingArea)
self.irr = solarIrradiance()
self.eta = efficiency()
self.Eg = calcEnergyGenerated(self.irr, self.area, self.eta)
def calcMoneySaved(self):
self.P = powerInstalled(self.area)
self.M = moneySaved(self.Eg,self.P)
print "area = %f" % self.area
print "irradiance = %f" % self.irr
print "efficiency = %f" % self.eta
print "Power rating = %f kW" % self.P
print "Money saved = %f" % self.M
self.assertTrue(self.M>0)
def calcCost(self):
self.cost = calcCostSolarPanels(self.P)
def calcTimeForBreakEven(self):
self.t = self.cost/self.M
def test_loopOverBuildings(self):
for self.building in self.buildings:
print extractValue(self.building,'vmd:School')
self.setUpPVcalc()
self.calcMoneySaved()
self.calcCost()
print "Up front cost = %f" % self.cost
self.calcTimeForBreakEven()
print "time for breakeven = %f years" % self.t
print ""
if __name__ == '__main__':
unittest.main()