Beispiel #1
0
    def test_get_run_info(self):
        trial = Trial()
        trial.add_resource(Resource('ra', data='some_data'))
        trial.add_resource(Resource('rb'))
        task_1 = Task([trial], plugin_1, 'plugin_category')

        self.assertTrue(task_1.is_ready)
        result = task_1.get_run_info()
        self.assertFalse(task_1.is_ready)

        self.assertEqual(len(task_1.locking_keys.keys()), 2)
        self.assertTrue(task_1.provides[0] in 
                task_1.locking_keys.keys())
        self.assertTrue(task_1.provides[1] in 
                task_1.locking_keys.keys())
Beispiel #2
0
    def test_get_args(self):
        '''_get_args checks out 'requirements' and returns them in a list.'''
        trial = Trial()
        trial.add_resource(Resource('ra', data='some_data'))
        trial.add_resource(Resource('rb'))
        task_1 = Task([trial], plugin_1, 'plugin_category')

        self.assertTrue(task_1.is_ready)

        result = task_1._get_args()

        self.assertTrue(task_1.is_ready)
        
        self.assertTrue('some_data' in result)
        self.assertTrue(trial.rb.data in result)
        self.assertEqual(len(result), 2)
Beispiel #3
0
class FauxPlugin(object):
    def __init__(self, requires, provides):
        self.name = 'Faux Plugin'
        self.requires = requires
        self.provides = provides
        self.is_stochastic = False
        self.is_pooling = False
        self.unpool_as = None
        self.silent_pooling = False

plugin_1 = FauxPlugin(requires=['ra', 'rb'],
                      provides=['pb', 'pa'])
plugin_2 = FauxPlugin(requires=['rb'],
                      provides=['ra', 'pa'])

trial_1 = Trial()
trial_1.add_resource(Resource('ra', data='some_data'))
trial_1.add_resource(Resource('rb'))

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

    def test_constructor_1(self):
        '''Resources created on trial by task if plugin produces them.'''
        trial = Trial()
        self.assertFalse(hasattr(trial, 'pa'))
        self.assertFalse(hasattr(trial, 'pb'))

        task_1 = Task([trial], plugin_1, 'plugin_category')
        self.assertTrue(hasattr(trial, 'pa'))