import pytest
import itertools
from backend.grid_manager import Cell, GridManager, StoreType
from backend.box import Box

# python -m pytest C:\Users\johny\PycharmProjects\grid-pair-management\tests\test_grid_manager.py

cell_init_data = [(StoreType.matrix, 42),
                  (StoreType.hashed, 123)]

# TODO: add only first object
cell_add_pairs = [(StoreType.hashed, 42, {1, 3, 5}, {(1, 3), (3, 1), (1, 5), (5, 1), (3, 5), (5, 3)}, 6,
                   {(1, 3), (3, 1), (1, 5), (5, 1), (3, 5), (5, 3), (1, 6), (6, 1), (3, 6), (6, 3), (5, 6), (6, 5)}),
                  (StoreType.hashed, 42, {2, 4}, {(2, 4), (4, 2)}, 6,
                   {(2, 4), (4, 2), (2, 6), (6, 2), (4, 6), (6, 4)}),
                  (StoreType.matrix, 3, {0, 2}, [[False, False, True], [False, False, False], [True, False, False]],
                   1, [[False, True, True], [True, False, True], [True, True, False]]),
                  (StoreType.matrix, 2, {0}, [[False, False], [False, False]], 1,
                   [[False, True], [True, False]])]

cell_remove_pairs = [(StoreType.hashed, 42, {1, 3, 5}, {(1, 3), (3, 1), (1, 5), (5, 1), (3, 5), (5, 3)}, 3,
                      {(1, 5), (5, 1)}),
                     (StoreType.hashed, 42, {2, 4}, {(2, 4), (4, 2)}, 2, set()),
                     (StoreType.matrix, 3, {0, 1, 2}, [[False, True, True], [True, False, True], [True, True, False]],
                      1, [[False, False, True], [False, False, False], [True, False, False]]),
                     (StoreType.matrix, 2, {0, 1}, [[False, True], [True, False]], 1,
                      [[False, False], [False, False]])]

grid_init_data = [(StoreType.matrix, 10, 600, 600, 100, 6, 6),
                  (StoreType.hashed, 5, 300, 300, 50, 6, 6),
                  (StoreType.matrix, 10, 1000, 600, 100, 10, 6),
                  (StoreType.matrix, 10, 600, 600, 64, 9, 9),
                  (StoreType.hashed, 10, 300, 600, 25, 12, 24),
                  (StoreType.matrix, 10, 1000, 600, 0, 0, 0),
                  (StoreType.matrix, 10, 1000, 0, 100, 10, 0),
                  (StoreType.matrix, 10, 0, 600, 100, 0, 6)]

grid_cell_data = [(100, 200, 25, 4, 8),
                  (100, 200, 9, 11, 22),
                  (100, 200, 8, 12, 25),
                  (100, 200, 0, 0, 0),
                  (0, 200, 10, 0, 20),
                  (100, 0, 10, 10, 0)]

grid_add_box_data = [(Box(1, [(0, 0), (400, 400), (0, 400), (400, 0)]), 0, 8, 0, 8),
                     (Box(1, [(50, 0), (100, 0), (200, 52), (50, 580), (100, 512), (242, 300)]), 1, 4, 0, 11)]

grid_add_boxes_data = [
    ([Box(1, [(0, 0), (400, 400), (0, 400), (400, 0)]),
      Box(2, [(0, 0), (200, 200), (0, 200), (200, 0)])],
     0, 4, 0, 4, [1, 2]),
    ([Box(1, [(0, 0), (400, 400), (0, 400), (400, 0)]),
      Box(2, [(0, 0), (200, 200), (0, 200), (200, 0)]),
      Box(3, [(100, 100), (200, 200), (100, 200), (200, 100)])],
     2, 4, 2, 4, [1, 2, 3])
]

grid_remove_box_data = [