def do_POST(self): self._set_headers() payload = self.rfile.read(int(self.headers['Content-Length'])) # Hive object from request payload hive = MyHive(json.loads(payload)) orders = hive.get_orders() response = json.dumps(orders) print(response) try: # For python 3 out = bytes(response, "utf8") except TypeError: # For python 2 out = bytes(response) self.wfile.write(out) # json format sample: # {"1":{"act":"load","dir":"down"},"17":{"act":"load","dir":"up"}} return
def test_hive_makes_move(self): payload = self.load_json("15x15.json") hive = MyHive(payload) result = hive.get_orders() self.assertTrue(result)
def test_board_loads(self): payload = self.load_json("15x15.json") hive = MyHive(payload) self.assertEqual(15, hive.width) self.assertEqual(15, hive.height)
def test_hive(self): payload = get_simple() hive = MyHive(payload) self.assertTrue(hive)
def test_board_prints(self): payload = self.load_json("15x15.json") hive = MyHive(payload) hive.console_log()