import copy
import unittest
from unittest.mock import MagicMock
from nose.tools import eq_

from helix.calculators.seismic_calculator import SeismicCalculator
from helix.calculators.subarray_graph import SubarrayGraph
from helix.calculators.subarray_helper import extract_subarray
from helix.constants.anchor_type import AnchorType
from helix.constants.module_type_constants.single_tilt_128_cell_constants import SingleTilt128CellConstants
from helix.constants.module_type_constants.single_tilt_96_cell_constants import SingleTilt96CellConstants
from helix.constants.module_type_constants.single_tilt_pseries_constants import SingleTiltPSeriesConstants
from helix.constants.system_type import SystemType
from helix.models.subarray import Subarray
from test.fixtures.sample_arrays import *


class SeismicCalculatorSingleTiltTest(unittest.TestCase):
    def setUp(self):
        self.values = MagicMock()
        self.system_type = SystemType.singleTilt
        self.values.system_type.return_value = self.system_type
        self.values.anchor_type.return_value = AnchorType.OMG_PowerGrip_Plus
        self.values.module_system_constants.return_value = SingleTilt96CellConstants()
        self.values.spectral_response.return_value = 2.5
        self.values.importance_factor.return_value = 1

        """
        Generated using:
        height: 100
        length: 1000
        width: 1500
        parapet: 0
        wind_speed: 150
        exposure: C
        anchor: OMG PowerGrip Plus
        ballast_block_weight: 14
        pressure: 20
        spectral_response: 1.02
        """

        self.panels = [
            Panel(panel_type=PanelType.Corner, wind_anchors=1, pressure=3.68, subarray=0),
            Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=18.27, subarray=0),
            Panel(panel_type=PanelType.Corner, wind_anchors=0, pressure=18.27, subarray=0),
            Panel(panel_type=PanelType.NorthSouth, wind_anchors=0, pressure=16.48, subarray=1),
            Panel(panel_type=PanelType.Middle, wind_anchors=0, pressure=17.07, subarray=1),
            Panel(panel_type=PanelType.EastWest, wind_anchors=0, pressure=12.89, subarray=1),
            Panel(panel_type=PanelType.EastWest, wind_anchors=0, pressure=8.00, subarray=2),
            Panel(panel_type=PanelType.NorthSouth, wind_anchors=3, pressure=7.23, subarray=2)
        ]

        self.graph_repository = MagicMock()
        self.subject = SeismicCalculator(self.values, self.graph_repository)

    def test_computes_seismic_anchors_per_subarray(self):
        self.values.spectral_response.return_value = 1.02

        eq_(self.subject.required_force_seismic_anchors(0, self.panels), 2)
        eq_(self.subject.required_force_seismic_anchors(1, self.panels), 0)
        eq_(self.subject.required_force_seismic_anchors(2, self.panels), 0)

    def test_computes_seismic_anchors_per_subarray_for_geometrically_constrained_arrays(self):
        copy_long_array_wind_anchors = copy.deepcopy(long_array_wind_anchors)
        self.values.spectral_response.return_value = 1

        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_long_array_wind_anchors, self.system_type)
        eq_(self.subject.required_geometric_seismic_anchors(0, copy_long_array_wind_anchors), 1)

    def test_assign_seismic_anchors_when_required_seismic_anchors_is_0_sets_panels_seismic_anchors(self):
        subarray0 = Subarray(subarray_number=0, required_seismic_anchors=0)
        subarray1 = Subarray(subarray_number=1, required_seismic_anchors=0)
        subarray2 = Subarray(subarray_number=2, required_seismic_anchors=0)

        self.subject.assign_seismic_anchors(subarray0, self.panels)
        self.subject.assign_seismic_anchors(subarray1, self.panels)
        self.subject.assign_seismic_anchors(subarray2, self.panels)

        for panel in self.panels:
            eq_(panel.seismic_anchors, 0)

    def test_computes_required_seismic_anchors_calculates_geometric_constraints_when_at_least_one_seismic_anchor(self):
        panels = [
            Panel(coordinate=Coordinate(0, 3), wind_anchors=0, seismic_anchors=1, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(2, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 3), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(0, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(2, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 2), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(0, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(2, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 1), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(0, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(1, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
            Panel(coordinate=Coordinate(2, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0), Panel(coordinate=Coordinate(3, 0), wind_anchors=0, seismic_anchors=0, panel_type=PanelType.Middle, pressure=2.26, subarray=0),
        ]

        eq_(self.subject.required_force_seismic_anchors(0, panels), 6)

    def test_computes_seismic_anchor_interval_correctly_on_96cell(self):
        self.values.spectral_response.return_value = 0.2
        eq_(self.subject.seismic_anchor_interval(), 15)
        # this would actually return a negative number, but short-circuit to return 15

        self.values.spectral_response.return_value = 1.02
        eq_(self.subject.seismic_anchor_interval(), 12)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 7)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 5)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 4)

    def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_96cell(self):
        self.values.importance_factor.return_value = 1.5
        self.values.spectral_response.return_value = 1.0
        eq_(self.subject.seismic_anchor_interval(), 7)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 4)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 3)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 2)

    def test_computes_seismic_anchor_interval_correctly_on_128cell(self):
        self.values.module_system_constants.return_value = SingleTilt128CellConstants()
        self.subject = SeismicCalculator(self.values, None)

        self.values.spectral_response.return_value = 0.2
        eq_(self.subject.seismic_anchor_interval(), 15)
        # this would actually return a negative number, but short-circuit to return 15

        self.values.spectral_response.return_value = 1.02
        eq_(self.subject.seismic_anchor_interval(), 14)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 8)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 5)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 4)

    def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_128cell(self):
        self.values.module_system_constants.return_value = SingleTilt128CellConstants()
        self.subject = SeismicCalculator(self.values, None)

        self.values.importance_factor.return_value = 1.5
        self.values.spectral_response.return_value = 1.0
        eq_(self.subject.seismic_anchor_interval(), 8)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 4)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 3)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 2)

    def test_computes_seismic_anchor_interval_correctly_on_p_series(self):
        self.values.module_system_constants.return_value = SingleTiltPSeriesConstants()
        self.subject = SeismicCalculator(self.values, None)

        self.values.spectral_response.return_value = 0.2
        eq_(self.subject.seismic_anchor_interval(), 15)
        # this would actually return a negative number, but short-circuit to return 15

        self.values.spectral_response.return_value = 1.02
        eq_(self.subject.seismic_anchor_interval(), 13)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 7)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 5)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 4)

    def test_computes_seismic_anchor_interval_taking_importance_factor_into_account_on_p_series(self):
        self.values.module_system_constants.return_value = SingleTiltPSeriesConstants()
        self.subject = SeismicCalculator(self.values, None)

        self.values.importance_factor.return_value = 1.5
        self.values.spectral_response.return_value = 1.0
        eq_(self.subject.seismic_anchor_interval(), 8)

        self.values.spectral_response.return_value = 1.5
        eq_(self.subject.seismic_anchor_interval(), 4)

        self.values.spectral_response.return_value = 2.0
        eq_(self.subject.seismic_anchor_interval(), 3)

        self.values.spectral_response.return_value = 2.5
        eq_(self.subject.seismic_anchor_interval(), 2)

    def test_assign_seismic_anchors(self):
        copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
        copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)

        [setattr(panel, 'subarray', 1) for panel in copy_four_by_four_no_wind_anchors]
        [setattr(panel, 'subarray', 2) for panel in copy_six_by_seven_no_wind_anchors]
        panels = copy_four_by_four_no_wind_anchors + copy_six_by_seven_no_wind_anchors

        subarrays = [
            Subarray(subarray_number=1, required_seismic_anchors=2),
            Subarray(subarray_number=2, required_seismic_anchors=1)
        ]

        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
        output = self.subject.assign_seismic_anchors(subarrays[0], panels)

        eq_(len(output), len(panels))

        subarray_1_panels = extract_subarray(panels, 1)
        subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
        eq_(subarray1_seismic_anchors, 3)

        subarray_2_panels = extract_subarray(panels, 2)
        subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
        eq_(subarray2_seismic_anchors, 0)

        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
        panels_with_assigned_seismic_anchors = self.subject.assign_seismic_anchors(subarrays[1], panels)

        eq_(len(panels_with_assigned_seismic_anchors), len(panels))

        subarray_1_panels = extract_subarray(panels, 1)
        subarray1_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_1_panels if panel.seismic_anchors)
        eq_(subarray1_seismic_anchors, 3)

        subarray_2_panels = extract_subarray(panels, 2)
        subarray2_seismic_anchors = sum(panel.seismic_anchors for panel in subarray_2_panels if panel.seismic_anchors)
        eq_(subarray2_seismic_anchors, 5)

    def test_assign_anchors_to_subarray_four_by_four_no_wind_anchors(self):
        copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_four_by_four_no_wind_anchors, Subarray(required_seismic_anchors=3))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 3)

    def test_assign_anchors_to_subarray_six_by_seven_no_wind_anchors(self):
        copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=3))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1 ,coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 5)

    def test_assign_anchors_to_subarray_no_wind_anchors_funny_shape(self):
        copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=3))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 6)

    def test_assign_anchors_to_subarray_no_seismic_anchors_required(self):
        copy_four_by_four_no_wind_anchors = copy.deepcopy(four_by_four_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_four_by_four_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_four_by_four_no_wind_anchors, Subarray(required_seismic_anchors=0))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 0)

    def test_assign_anchors_to_subarray_with_neck(self):
        copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=20))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
                                                                                                                                                          Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 20)

    def test_assign_anchors_to_subarray_with_neck_more_than_one_walk(self):
        copy_dumbell_no_wind_anchors = copy.deepcopy(dumbell_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_dumbell_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_dumbell_no_wind_anchors, Subarray(required_seismic_anchors=30))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 8), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 8), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 7), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 7), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 7), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0),
                                                                                                                                                          Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 30)

    def test_assign_anchors_to_subarray_no_wind_anchors_more_than_one_walk_through_funny_shape(self):
        copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=20))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 20)

    def test_assign_anchors_to_subarray_when_not_all_anchors_fit_on_perimeter(self):
        copy_c_shape_no_wind_anchors = copy.deepcopy(c_shape_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_no_wind_anchors, Subarray(required_seismic_anchors=30))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 30)

    def test_assign_anchors_to_subarray_rectangle_when_not_all_anchors_fit_on_perimeter(self):
        copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=30))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 30)

    def test_assign_anchors_to_subarray_with_wind_anchors_funny_shape(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=2))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 2)

    def test_assign_anchors_to_subarray_with_wind_anchors_more_than_one_walk_through_funny_shape(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=10))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 10)

    def test_assign_anchors_to_subarray_wind_anchors_when_not_all_anchors_fit_on_perimeter(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=25))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 25)

    def test_assign_anchors_to_subarray_wind_anchors_filling_array_completely(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=30))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 30)

    def test_assign_anchors_to_subarray_wind_anchors_overfilling_array(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=35))

        expected_result = [
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=2, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=1, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 35)

    def test_assign_anchors_to_subarray_places_anchors_when_wind_anchors_but_no_required_anchors(self):
        copy_c_shape_with_wind_anchors = copy.deepcopy(c_shape_with_wind_anchors)
        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_c_shape_with_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_c_shape_with_wind_anchors, Subarray(required_seismic_anchors=0))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=1),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=1, coordinate=Coordinate(3, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=1),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 2) # TODO why is this 2, not 0?

    def test_assign_anchors_to_subarray_ignores_geometric_constraint_when_sds_below_1(self):
        copy_six_by_seven_no_wind_anchors = copy.deepcopy(six_by_seven_no_wind_anchors)
        self.values.spectral_response.return_value = 0.9

        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_no_wind_anchors, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_no_wind_anchors, Subarray(required_seismic_anchors=1))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=1, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 1)

    def test_assign_anchors_to_subarray_places_no_seismic_anchors_when_sds_less_1_and_required_anchors_0(self):
        copy_six_by_seven_single_wind_anchor_not_at_bottom_left = copy.deepcopy(six_by_seven_single_wind_anchor_not_at_bottom_left)
        self.values.spectral_response.return_value = 0.9

        self.graph_repository.subarray_graph.return_value = SubarrayGraph(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, self.system_type)
        result = self.subject.assign_anchors_to_subarray(copy_six_by_seven_single_wind_anchor_not_at_bottom_left, Subarray(required_seismic_anchors=0))

        expected_result = [
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 6), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 6), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 5), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 5), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 4), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 4), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 3), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 3), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 2), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 2), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 1), wind_anchors=1), Panel(seismic_anchors=0, coordinate=Coordinate(1, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 1), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 1), wind_anchors=0),
            Panel(seismic_anchors=0, coordinate=Coordinate(0, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(1, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(2, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(3, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(4, 0), wind_anchors=0), Panel(seismic_anchors=0, coordinate=Coordinate(5, 0), wind_anchors=0),
        ]
        eq_(result, expected_result)

        seismic_anchors = sum(x.seismic_anchors for x in result)
        eq_(seismic_anchors, 0)
