Files
old-krovovi-kalkulator/test/helpers/panel_presenter_test.py
2018-01-15 13:31:00 +01:00

306 lines
36 KiB
Python

import unittest
import mock
from numpy.testing import assert_array_equal, assert_equal
from helix.constants.module_type import ModuleType
from helix.models.coordinate import Coordinate
from helix.models.panel import Panel
from helix.models.subarray import Subarray
from helix.presenters.panel_presenter import ProjectPresenter
from helix.constants.system_type import SystemType
from helix.constants.panel_type import PanelType
from test.test_helpers import feature_is_always_active
import flask_featureflags
flask_featureflags.is_active = feature_is_always_active
class PanelPresenterTest(unittest.TestCase):
def test_get_table_data_single_tilt_96cell(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
panels = [
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Middle, coordinate=Coordinate(0, 2), pressure=1.17, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=1),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(3, 1), pressure=1.17, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=2),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(2, 1), pressure=1.17, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=3),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 1), pressure=1.17, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=4),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(0, 1), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=5),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(3, 0), pressure=1.17, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=6),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 0), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=7),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 0), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=8),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(0, 0), pressure=1.17, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=9),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 1), pressure=2.56, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=10),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 1), pressure=2.56, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=11),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Middle, coordinate=Coordinate(1, 1), pressure=2.56, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=12),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(0, 1), pressure=2.56, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=13),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 0), pressure=2.56, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=14),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(2, 0), pressure=2.56, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=15),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.NorthSouth, coordinate=Coordinate(1, 0), pressure=2.56, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=16)
]
subarrays = [
Subarray(subarray_number=1, origin=Coordinate(0, 0), start_row=0, size=9),
Subarray(subarray_number=2, origin=Coordinate(0, 2), start_row=9, size=7)
]
expected = [
{'x': 0, 'y': 1, 'width': 1, 'height': 1, 'data': {'panel_id': 1, 'panel_type': 4, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 3, 'y': 2, 'width': 1, 'height': 1, 'data': {'panel_id': 2, 'panel_type': 2, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 2, 'y': 2, 'width': 1, 'height': 1, 'data': {'panel_id': 3, 'panel_type': 2, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 0, 'link_trays': 0, 'psf': 1.17, 'subarray': 1}},
{'x': 1, 'y': 2, 'width': 1, 'height': 1, 'data': {'panel_id': 4, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 4, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 0, 'y': 2, 'width': 1, 'height': 1, 'data': {'panel_id': 5, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 3, 'y': 3, 'width': 1, 'height': 1, 'data': {'panel_id': 6, 'panel_type': 3, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 0, 'link_trays': 1, 'psf': 1.17, 'subarray': 1}},
{'x': 2, 'y': 3, 'width': 1, 'height': 1, 'data': {'panel_id': 7, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 1, 'y': 3, 'width': 1, 'height': 1, 'data': {'panel_id': 8, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 0, 'y': 3, 'width': 1, 'height': 1, 'data': {'panel_id': 9, 'panel_type': 1, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 3, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 3, 'y': 0, 'width': 1, 'height': 1, 'data': {'panel_id': 10, 'panel_type': 1, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 1, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 2, 'y': 0, 'width': 1, 'height': 1, 'data': {'panel_id': 11, 'panel_type': 3, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 1, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 1, 'y': 0, 'width': 1, 'height': 1, 'data': {'panel_id': 12, 'panel_type': 4, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 0, 'link_trays': 0, 'psf': 2.56, 'subarray': 2}},
{'x': 0, 'y': 0, 'width': 1, 'height': 1, 'data': {'panel_id': 13, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 4, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 3, 'y': 1, 'width': 1, 'height': 1, 'data': {'panel_id': 14, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 2, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 2, 'y': 1, 'width': 1, 'height': 1, 'data': {'panel_id': 15, 'panel_type': 1, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 0, 'link_trays': 1, 'psf': 2.56, 'subarray': 2}},
{'x': 1, 'y': 1, 'width': 1, 'height': 1, 'data': {'panel_id': 16, 'panel_type': 2, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 3, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
]
received = self.subject.get_panel_data(panels, subarrays)
assert_array_equal(received, expected)
def test_get_buildings_data(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
buildings = [ [ Coordinate(0,0), Coordinate(60,0), Coordinate(60,60), Coordinate(0,60) ] ] # big square
expected_buildings = [[
{'x': 0, '_Coordinate__rounded_x': 0, 'y': 60, '_Coordinate__rounded_y': 0, 'rotation': 0.0},
{'x': 60, '_Coordinate__rounded_x': 60, 'y': 60, '_Coordinate__rounded_y': 0, 'rotation': 0.0},
{'x': 60, '_Coordinate__rounded_x': 60, 'y': 0, '_Coordinate__rounded_y': 60, 'rotation': 0.0},
{'x': 0, '_Coordinate__rounded_x': 0, 'y': 0, '_Coordinate__rounded_y': 60, 'rotation': 0.0}
]]
actual_buildings = self.subject.get_buildings(buildings,60)
assert_array_equal(actual_buildings,expected_buildings)
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
def test_get_corners_box_building(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
buildings = [ [ [0, 0], [60, 0], [60,60], [0, 60] ] ] # big square
expected_corners = [[
{'x': 0, 'y': 0, 'length_cw': 60, 'length_ccw':60, 'angle':90},
{'x': 60, 'y': 0, 'length_cw': 60, 'length_ccw':60, 'angle':90},
{'x': 60, 'y': 60, 'length_cw': 60, 'length_ccw':60, 'angle':90},
{'x': 0, 'y': 60, 'length_cw': 60, 'length_ccw':60, 'angle':90}
]]
actual_corners = self.subject.get_corners(buildings)
assert_array_equal(actual_corners,expected_corners)
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
def test_get_corners_box_building_rotated_30_degrees(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
buildings = [ [ [0, 0], [51.96, 30], [21.96, 81.96], [-30, 51.96] ] ] # big square
expected_corners = [[
{'x': 0, 'y': 0, 'length_cw': 59.99867998547968, 'length_ccw':59.99867998547968, 'angle':90},
{'x': 51.96, 'y': 30, 'length_cw': 59.99867998547968, 'length_ccw':59.998679985479676, 'angle':90},
{'x': 21.96, 'y': 81.96, 'length_cw': 59.998679985479676, 'length_ccw':59.998679985479676, 'angle':90},
{'x': -30, 'y': 51.96, 'length_cw': 59.998679985479676, 'length_ccw':59.99867998547968, 'angle':90}
]]
actual_corners = self.subject.get_corners(buildings)
assert_array_equal(actual_corners,expected_corners)
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
def test_get_corners_building(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
buildings = [ [ [-3.42, 1.51], [-1.66, -1.64], [4.22, -0.87], [-0.8, 5.64]] ]
expected_corners = [[
{'x': -3.42, 'y': 1.51, 'length_cw': 4.890940604832571, 'length_ccw':3.6083375673570233, 'angle':118.41626123074676},
{'x': -1.66, 'y': -1.64, 'length_cw': 3.6083375673570233, 'length_ccw':5.930202357424239, 'angle':111.73284308914215},
{'x': 4.22, 'y': -0.87, 'length_cw': 5.930202357424239, 'length_ccw':8.22073597678456, 'angle':59.823982400990424},
{'x': -0.8, 'y': 5.64, 'length_cw': 8.22073597678456, 'length_ccw':4.890940604832571, 'angle':70.02691327912069}
]]
actual_corners = self.subject.get_corners(buildings)
assert_array_equal(actual_corners,expected_corners)
#@mock.patch('flask_featureflags.is_active',side_effect=feature_is_always_active)
def test_get_corners_wild_building_with_big_angles(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
buildings = [ [ [-3.58, 3.32], [-0.78, -2.9], [-1.56,0.88], [0.66, -2.16], [1.5, 1.16], [2.72, 2.36], [-0.8, 5.64] ] ]
expected_corners = [[
{'x': -3.58, 'y': 3.32, 'length_cw': 3.6208838699963852, 'length_ccw':6.821172919667115, 'angle':105.6106862572924},
{'x': -0.78, 'y': -2.9, 'length_cw': 6.821172919667115, 'length_ccw':3.8596372886580936, 'angle':12.576112527956795},
{'x': 0.66, 'y': -2.16, 'length_cw': 3.7643060449437424, 'length_ccw':3.424616766880639, 'angle':50.33783308603299},
{'x': 2.72, 'y': 2.36, 'length_cw': 1.7112568480505783, 'length_ccw':4.811319985201567, 'angle':87.50512700090906},
{'x': -0.8, 'y': 5.64, 'length_cw': 4.811319985201567, 'length_ccw':3.6208838699963852, 'angle':97.17527350158382}
]]
actual_corners = self.subject.get_corners(buildings)
print(actual_corners)
assert_array_equal(actual_corners,expected_corners)
def test_get_max_y(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell96)
panels = [
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Middle, coordinate=Coordinate(0, 2), pressure=1.17, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=1),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(3, 1), pressure=1.17, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=2),
]
buildings = [ [ Coordinate(-60,-60), Coordinate(60,-60), Coordinate(60,60), Coordinate(-60,60) ] ] # big square
expected_max_y = 60
actual_max_y = self.subject.get_max_y(buildings,panels)
assert_equal(actual_max_y, expected_max_y)
expected_max_y = 2
actual_max_y = self.subject.get_max_y([],panels)
assert_equal(actual_max_y, expected_max_y)
def test_get_table_data_single_tilt_128cell(self):
self.subject = ProjectPresenter(SystemType.singleTilt, ModuleType.Cell128)
panels = [
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Middle, coordinate=Coordinate(0, 2), pressure=1.17, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=1),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(3, 1), pressure=1.17, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=2),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(2, 1), pressure=1.17, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=3),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 1), pressure=1.17, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=4),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(0, 1), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=5),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(3, 0), pressure=1.17, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=6),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 0), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=7),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 0), pressure=1.17, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=8),
Panel(wind_zone=0, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(0, 0), pressure=1.17, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=9),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 1), pressure=2.56, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=10),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 1), pressure=2.56, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=11),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Middle, coordinate=Coordinate(1, 1), pressure=2.56, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=12),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(0, 1), pressure=2.56, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=13),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 0), pressure=2.56, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=14),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(2, 0), pressure=2.56, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=15),
Panel(wind_zone=3, subarray=2, panel_type=PanelType.NorthSouth, coordinate=Coordinate(1, 0), pressure=2.56, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=16)
]
subarrays= [
Subarray(subarray_number=1, origin=Coordinate(0, 0), start_row=0, size=9),
Subarray(subarray_number=2, origin=Coordinate(0, 2), start_row=9, size=7)
]
expected = [
{'x': 0.0, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 1, 'panel_type': 4, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 4.5, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 2, 'panel_type': 2, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 3.0, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 3, 'panel_type': 2, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 0, 'link_trays': 0, 'psf': 1.17, 'subarray': 1}},
{'x': 1.5, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 4, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 4, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 0.0, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 5, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 4.5, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 6, 'panel_type': 3, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 0, 'link_trays': 1, 'psf': 1.17, 'subarray': 1}},
{'x': 3.0, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 7, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 1.5, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 8, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 0.0, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 9, 'panel_type': 1, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'A', 'cross_trays': 3, 'link_trays': 2, 'psf': 1.17, 'subarray': 1}},
{'x': 4.5, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 10, 'panel_type': 1, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 1, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 3.0, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 11, 'panel_type': 3, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 1, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 1.5, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 12, 'panel_type': 4, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 0, 'link_trays': 0, 'psf': 2.56, 'subarray': 2}},
{'x': 0.0, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 13, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 4, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 4.5, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 14, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 2, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
{'x': 3.0, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 15, 'panel_type': 1, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 0, 'link_trays': 1, 'psf': 2.56, 'subarray': 2}},
{'x': 1.5, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 16, 'panel_type': 2, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'D', 'cross_trays': 3, 'link_trays': 2, 'psf': 2.56, 'subarray': 2}},
]
received = self.subject.get_panel_data(panels, subarrays)
assert_array_equal(received, expected)
def test_get_table_data_dual_tilt_96cell(self):
self.subject = ProjectPresenter(SystemType.dualTilt, ModuleType.Cell96)
panels =[
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Middle, coordinate=Coordinate(0, 2), pressure=1.23, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=1),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(3, 1), pressure=1.23, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=2),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(2, 1), pressure=1.23, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=3),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 1), pressure=1.23, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=4),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(0, 1), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=5),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(3, 0), pressure=1.23, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=6),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 0), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=7),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 0), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=8),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(0, 0), pressure=1.23, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=9),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 1), pressure=3.14, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=10),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 1), pressure=3.14, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=11),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Middle, coordinate=Coordinate(1, 1), pressure=3.14, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=12),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(0, 1), pressure=3.14, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=13),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 0), pressure=3.14, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=14),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(2, 0), pressure=3.14, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=15),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.NorthSouth, coordinate=Coordinate(1, 0), pressure=3.14, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=16)
]
subarrays = [
Subarray(subarray_number=1, origin=Coordinate(0, 0), start_row=0, size=9),
Subarray(subarray_number=2, origin=Coordinate(0, 2), start_row=9, size=7)
]
expected = [
{'x': 0.0, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 1, 'panel_type': 4, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 2, 'panel_type': 2, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 3.0, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 3, 'panel_type': 2, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 0, 'link_trays': 0, 'psf': 1.23, 'subarray': 1}},
{'x': 1.5, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 4, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 4, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 0.0, 'y': 2, 'width': 1.5, 'height': 1, 'data': {'panel_id': 5, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 6, 'panel_type': 3, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 0, 'link_trays': 1, 'psf': 1.23, 'subarray': 1}},
{'x': 3.0, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 7, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 1.5, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 8, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 0.0, 'y': 3, 'width': 1.5, 'height': 1, 'data': {'panel_id': 9, 'panel_type': 1, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 3, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 10, 'panel_type': 1, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 1, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 3.0, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 11, 'panel_type': 3, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 1, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 1.5, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 12, 'panel_type': 4, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 0, 'link_trays': 0, 'psf': 3.14, 'subarray': 2}},
{'x': 0.0, 'y': 0, 'width': 1.5, 'height': 1, 'data': {'panel_id': 13, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 4, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 4.5, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 14, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 2, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 3.0, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 15, 'panel_type': 1, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 0, 'link_trays': 1, 'psf': 3.14, 'subarray': 2}},
{'x': 1.5, 'y': 1, 'width': 1.5, 'height': 1, 'data': {'panel_id': 16, 'panel_type': 2, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 3, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
]
received = self.subject.get_panel_data(panels, subarrays)
assert_array_equal(received, expected)
def test_get_table_data_dual_tilt_128cell(self):
self.subject = ProjectPresenter(SystemType.dualTilt, ModuleType.Cell128)
panels =[
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Middle, coordinate=Coordinate(0, 2), pressure=1.23, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=1),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(3, 1), pressure=1.23, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=2),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.NorthSouth, coordinate=Coordinate(2, 1), pressure=1.23, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=3),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 1), pressure=1.23, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=4),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(0, 1), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=5),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(3, 0), pressure=1.23, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=6),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 0), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=7),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(1, 0), pressure=1.23, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=8),
Panel(wind_zone=4, subarray=1, panel_type=PanelType.Corner, coordinate=Coordinate(0, 0), pressure=1.23, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=9),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 1), pressure=3.14, ballast=20, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=10),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.EastWest, coordinate=Coordinate(2, 1), pressure=3.14, ballast=17, presented_link_tray=2, cross_tray=1, wind_anchors=0, seismic_anchors=1, id=11),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Middle, coordinate=Coordinate(1, 1), pressure=3.14, ballast=0, presented_link_tray=0, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=12),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(0, 1), pressure=3.14, ballast=47, presented_link_tray=2, cross_tray=4, wind_anchors=0, seismic_anchors=1, id=13),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(3, 0), pressure=3.14, ballast=22, presented_link_tray=2, cross_tray=2, wind_anchors=0, seismic_anchors=1, id=14),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.Corner, coordinate=Coordinate(2, 0), pressure=3.14, ballast=8, presented_link_tray=1, cross_tray=0, wind_anchors=0, seismic_anchors=1, id=15),
Panel(wind_zone=1, subarray=2, panel_type=PanelType.NorthSouth, coordinate=Coordinate(1, 0), pressure=3.14, ballast=35, presented_link_tray=2, cross_tray=3, wind_anchors=0, seismic_anchors=1, id=16)
]
subarrays = [
Subarray(subarray_number=1, origin=Coordinate(0, 0), start_row=0, size=9),
Subarray(subarray_number=2, origin=Coordinate(0, 2), start_row=9, size=7)
]
expected = [
{'x': 0.0, 'y': 1.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 1, 'panel_type': 4, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 3.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 2, 'panel_type': 2, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 1, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 3.0, 'y': 3.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 3, 'panel_type': 2, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 0, 'link_trays': 0, 'psf': 1.23, 'subarray': 1}},
{'x': 1.5, 'y': 3.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 4, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 4, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 0.0, 'y': 3.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 5, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 4.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 6, 'panel_type': 3, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 0, 'link_trays': 1, 'psf': 1.23, 'subarray': 1}},
{'x': 3.0, 'y': 4.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 7, 'panel_type': 3, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 1.5, 'y': 4.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 8, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 2, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 0.0, 'y': 4.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 9, 'panel_type': 1, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'E', 'cross_trays': 3, 'link_trays': 2, 'psf': 1.23, 'subarray': 1}},
{'x': 4.5, 'y': 0.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 10, 'panel_type': 1, 'ballast': 20, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 1, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 3.0, 'y': 0.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 11, 'panel_type': 3, 'ballast': 17, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 1, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 1.5, 'y': 0.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 12, 'panel_type': 4, 'ballast': 0, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 0, 'link_trays': 0, 'psf': 3.14, 'subarray': 2}},
{'x': 0.0, 'y': 0.0, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 13, 'panel_type': 1, 'ballast': 47, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 4, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 4.5, 'y': 1.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 14, 'panel_type': 1, 'ballast': 22, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 2, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
{'x': 3.0, 'y': 1.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 15, 'panel_type': 1, 'ballast': 8, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 0, 'link_trays': 1, 'psf': 3.14, 'subarray': 2}},
{'x': 1.5, 'y': 1.5, 'width': 1.5, 'height': 1.5, 'data': {'panel_id': 16, 'panel_type': 2, 'ballast': 35, 'wind_anchors': 0, 'seismic_anchors': 1, 'wind_zones': 'B', 'cross_trays': 3, 'link_trays': 2, 'psf': 3.14, 'subarray': 2}},
]
received = self.subject.get_panel_data(panels, subarrays)
assert_array_equal(received, expected)