<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import unittest

from pyext_adaptor.test_pyext import TestPyext

from command import Command


class CommandTest(unittest.TestCase):
  def DoTest(self, config_data, expected, *args):
    pyext = TestPyext()
    command = Command(pyext)
    command.outlet_dict.update(out=1)
    exec config_data in globals(), command.config_dict
    result = command.config_dict.get('result')(*args)
    self.assertEqual(pyext.outputs, expected)

  def testSimple(self):
    self.DoTest('result = Output("out", "foo", 1)', [('foo', 1)])

  def testRef(self):
    self.DoTest("""
result = Ref('bar')
bar = Output("out", "foo", 1)
""", [('foo', 1)])

  def testMap(self):
    config_data = """
result = Map(cmd1=Output('out', 'hello'))
"""
    self.DoTest(config_data, [('hello', )], 'cmd1')

if __name__ == '__main__':
    unittest.main()
</pre></body></html>