import unittest

from nose.tools import eq_

from helix.models.coordinate import Coordinate
from helix.models.dxf.graph_node import GraphNode
from helix.models.panel import Panel
from helix.models.dxf.graph_node_store import GraphNodeStore


class GraphNodeStoreTest(unittest.TestCase):
    def setUp(self):
        self.subject = GraphNodeStore()

    def test_find_coordinate(self):
        node_one = GraphNode(Panel(coordinate=Coordinate(2, 104, rotation=1.07)), 0, 0)
        node_two = GraphNode(Panel(coordinate=Coordinate(2, 105, rotation=1.07)), 0, 0)
        node_three = GraphNode(Panel(coordinate=Coordinate(3, 104, rotation=1.07)), 0, 0)

        self.subject.add_node(node_one)
        self.subject.add_node(node_two)
        self.subject.add_node(node_three)

        eq_(self.subject.find_coordinate(Coordinate(2, 104, rotation=1.07)), node_one)
        eq_(self.subject.find_coordinate(Coordinate(2, 105, rotation=1.07)), node_two)
        eq_(self.subject.find_coordinate(Coordinate(3, 104, rotation=1.07)), node_three)
        eq_(self.subject.find_coordinate(Coordinate(20, 104, rotation=1.07)), None)
