Ejemplo n.º 1
0
  def run(self):
    env = self.state.document.settings.env
    module_path = self.content[0]
    os.chdir(startingCWD) #Note: Allow for relative imports.
    module = load_source(getRandomChars(16), module_path) #ToDo: Ensure that the random string is a available-module-name.
    setBase(module) #Fix: This is a hot-fix for force-configuring the loaded scripts, as ec hooks only into module imports.
    moduleID = "ec-%d-%s" % (env.new_serialno('ec'), module.__ec_member__.Config['name'])

    return getModuleTree(module.__ec_member__, moduleID, basename(module_path)) #ToDo: Pass optional titles through the directives.
Ejemplo n.º 2
0
  def test_walk(self):
    from targets import simple
    from ec import interface

    interface.setBase(simple)

    expected = set(['task1', 'group1', 'ex', 'hex'])
    got = set()

    for Member in walk(simple.__ec_member__):
      got.add(Member.Config['name'])

    assert(expected == got)
Ejemplo n.º 3
0
def inject(sharedBase=None, **Settings):

  import sys
  from json import dumps
  from urllib import quote

  from ec import interface
  from ec.ec import settings

  import delegator # #Note: An ec module is used, instead of making the call directly, so to utilize ec's features like debugging etc.

  if sharedBase:
    delegator.setSharedBase(sharedBase)

  if Settings:
    settings(**Settings)

  Args = sys.argv[1:]

  interface.setBase(delegator)
  interface.call('makeCall %s %s' % (Args[0], quote(dumps(Args[1:]))), silent=False)
Ejemplo n.º 4
0
r"""
Tests ec.interface.

Note:
  This test might fail when tested over the devlopment dir (or its symlinks), hence it should be run on the installed package.
"""
import unittest

from ec import interface
from ec.modules.classes import HandledException

from targets import simple
from support.helpers import expect_exception

# Main
interface.setBase(simple)

class TestInterface(unittest.TestCase):
  def setUp(self):
    pass

  def tearDown(self):
    pass

  def test_call(self):
    assert(interface.call('task1 arg1=1') == (1, 2))

  def test_positional_args(self):
    assert(interface.call('task1 1') == (1, 2))

  def test_mixed_args(self):