Esempio n. 1
0
    def test_cells_survive(self):

        cells = mck.mock_cell_batch(2000)
        test_len = len(cells)

        cell.cells_survive(cells)
        assert len(cells) == test_len
Esempio n. 2
0
    def test_cells_consume_energy(self):

        cells = mck.mock_cell_batch(2000)
        test_energy = [cells[i].energy_level for i in range(len(cells))]

        cell.cells_consume_energy(cells)
        energy = [cells[i].energy_level for i in range(len(cells))]

        assert energy != test_energy
Esempio n. 3
0
    def test_get_value(self):
        cells = mck.mock_cell_batch()

        cell_dict = {}
        helper.map_cells_to_dict(cells, cell_dict)

        for cell in cells:
            val, _ = helper.get_value(cell_dict, cell.id)
            assert val == cell, "KeyError"
Esempio n. 4
0
    def test_feed_cells(self):

        cells = mck.mock_cell_batch(500)
        test_energy = sum([cell.energy_level for cell in cells])

        for time_step in range(100):
            env.feed_cells(cells, time_step)
        energy = sum([cell.energy_level for cell in cells])

        assert energy > test_energy
Esempio n. 5
0
    def test_map_cells_to_dict(self):

        cells = mck.mock_cell_batch()

        cell_dict = {}
        helper.map_cells_to_dict(cells, cell_dict)

        assert cell_dict, "ReturnError"
        assert len(cell_dict) == len(cells), "RangeError"
        for cell in cells:
            assert cell_dict[cell.id] == cell, "KeyError"
Esempio n. 6
0
    def test_move_cells(self):

        cells = mck.mock_cell_batch()
        test_position = [(cell.pos.x, cell.pos.y, cell.pos.z)
                         for cell in cells]

        id_to_cell_dict = {}
        helper.map_cells_to_dict(cells, id_to_cell_dict)

        env.move_cells(cells, id_to_cell_dict)
        assert [(cell.pos.x, cell.pos.y, cell.pos.z)
                for cell in cells] != test_position
Esempio n. 7
0
    def test_move_cell_and_connected_cells(self):

        cells = mck.mock_cell_batch()
        single_cell = cells[random.randint(0, len(cells))]
        test_position = (single_cell.pos.x, single_cell.pos.y,
                         single_cell.pos.z)

        id_to_cell_dict = {}
        helper.map_cells_to_dict(cells, id_to_cell_dict)
        moved_dict = {}

        env.move_cell_and_connected_cells(single_cell, id_to_cell_dict,
                                          moved_dict)
        assert (single_cell.pos.x, single_cell.pos.y,
                single_cell.pos.z) != test_position
Esempio n. 8
0
    def test_cells_divide(self):

        num = 0

        for _ in range(10):
            cells = mck.mock_cell_batch(2000)
            test_len = len(cells)

            for single_cell in cells:
                single_cell.energy_level += random.randint(100, 500)

            with pytest.raises(AttributeError):
                cell.cells_divide(cells)

            if len(cells) != test_len:
                num += 1

        assert num != 0