Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 4, 2021
1 parent e511e12 commit a839bb4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

from spinn_front_end_common.interface.config_setup import unittest_setup
from spinn_front_end_common.utilities.report_functions.write_json_machine \
import (WriteJsonMachine, MACHINE_FILENAME)
import (write_json_machine, MACHINE_FILENAME)
from spinn_front_end_common.interface.interface_functions import (
SpallocAllocator)
spalloc_allocator)


class TestWriteJson(unittest.TestCase):
Expand Down Expand Up @@ -114,11 +114,9 @@ def testSpin4(self):

machine = trans.get_machine_details()

jsonAlgo = WriteJsonMachine()

folder = "spinn4"
self._remove_old_json(folder)
filename = jsonAlgo(machine, folder)
filename = write_json_machine(machine, folder)

self.json_compare(filename, "spinn4.json")

Expand All @@ -132,7 +130,7 @@ def testSpin4(self):

folder = "spinn4_fiddle"
self._remove_old_json(folder)
filename = jsonAlgo(machine, folder)
filename = write_json_machine(machine, folder)

self.json_compare(filename, "spinn4_fiddle.json")
trans.close()
Expand All @@ -144,10 +142,9 @@ def testSpin2(self):
"Machine", "spalloc_user", "Integration testing ok to kill")
set_config("Machine", "spalloc_port", self.spin2Port)

spallocAlgo = SpallocAllocator()
try:
(hostname, version, _, _, _, _, _, m_allocation_controller) = \
spallocAlgo(spalloc_server=self.spalloc, n_chips=20)
spalloc_allocator(spalloc_server=self.spalloc, n_chips=20)
except (JobDestroyedError):
self.skipTest("Skipping as getting Job failed")

Expand All @@ -157,11 +154,9 @@ def testSpin2(self):

m_allocation_controller.close()

jsonAlgo = WriteJsonMachine()

folder = "spinn2"
self._remove_old_json(folder)
filename = jsonAlgo(machine, folder)
filename = write_json_machine(machine, folder)

self.json_compare(filename, "spinn2.json")
trans.close()
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import socket
from threading import Thread
import json
from spinn_utilities.config_holder import set_config
from spinn_front_end_common.interface.config_setup import unittest_setup
from spinn_front_end_common.interface.interface_functions import (
SpallocMaxMachineGenerator)
spalloc_max_machine_generator)


class _MockSpallocServer(Thread):
Expand Down Expand Up @@ -63,26 +64,27 @@ def test_single_board(self):
server = _MockSpallocServer(
"test", 1, 1, [(0, 0, 1), (0, 0, 2)], [], ["default"])
server.start()
generator = SpallocMaxMachineGenerator()
machine = generator("localhost", server.port)
set_config("Machine", "spalloc_port", server.port)
machine = spalloc_max_machine_generator("localhost")
self.assertEqual(machine.max_chip_x, 7)
self.assertEqual(machine.max_chip_y, 7)

def test_multiboard(self):
server = _MockSpallocServer(
"test", 1, 1, [], [], ["default"])
server.start()
generator = SpallocMaxMachineGenerator()
machine = generator("localhost", server.port)
set_config("Machine", "spalloc_port", server.port)
machine = spalloc_max_machine_generator("localhost")
self.assertEqual(machine.max_chip_x, 11)
self.assertEqual(machine.max_chip_y, 11)

def test_specific_board(self):
server = _MockSpallocServer(
"test", 3, 2, [], [], ["test"])
server.start()
generator = SpallocMaxMachineGenerator()
machine = generator("localhost", server.port, "test")
set_config("Machine", "spalloc_port", server.port)
set_config("Machine", "spalloc_machine", "test")
machine = spalloc_max_machine_generator("localhost")
self.assertEqual(machine.max_chip_x, (12 * 3) - 1)
self.assertEqual(machine.max_chip_y, (12 * 2) - 1)

Expand Down

0 comments on commit a839bb4

Please sign in to comment.