algebraic-auction-studio-fo.../tests/test_aas.py

32 lines
1.0 KiB
Python

import unittest
import sys, os
# Ensure local src is importable when running tests without installation
SRC_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))
if SRC_PATH not in sys.path:
sys.path.insert(0, SRC_PATH)
from algebraic_auction_studio_for_robotic_fle.dsl import build_example_dsl
from algebraic_auction_studio_for_robotic_fle.solver import solve
class TestAAS(unittest.TestCase):
def test_basic_dsl_build(self):
dsl = build_example_dsl()
self.assertTrue(len(dsl.agents) >= 1)
self.assertTrue(len(dsl.tasks) >= 1)
self.assertIsNotNone(dsl.objective)
def test_solver_allocations(self):
dsl = build_example_dsl()
allocations = solve(dsl.agents, dsl.tasks)
self.assertIsInstance(allocations, dict)
# allocations map agent_id -> task_id (or nothing)
for aid, tid in allocations.items():
self.assertIsInstance(aid, str)
self.assertIsInstance(tid, str)
if __name__ == '__main__':
unittest.main()