Example #1
0
    def assertConsistent(self, system, ground, type_spec=None):
        """Assert that the system and ground are consistent i.e., they
        have the same order-variant dicts. We test raw dicts,
        and Spec dicts and if present type specific dicts"""

        # Test dicts
        self.assertEquals(to_frozenset(system),
                          to_frozenset(ground))
        # Test Specs
        self.assertEquals(to_frozenset(system),
                          to_frozenset([specs.Spec(d)
                                        for d in ground]))
        if type_spec is not None:
            # Type specific spec
            self.assertEquals(to_frozenset(system),
                              to_frozenset([type_spec(d)
                                            for d in ground]))
Example #2
0
    def test_workflow_add_task_dict(self):
        """Adding task dicts should show up in Workflow.steps"""
        wf = specs.Workflow()

        wf.add_task(self.add, 'add')
        task_list = [{'name': 'add', 'task': self.add}]
        # Steps should be equal to a list of dicts
        self.assertEquals(wf['steps'], task_list)
        self.assertEquals(wf.steps, task_list)

        # Steps should be equal to a list of Spec() dicts
        self.assertEquals(wf['steps'], [specs.Spec(t) for t in task_list])
        self.assertEquals(wf.steps, [specs.Spec(t) for t in task_list])

        # Steps should be equal to a list of StepSpec() dicts
        self.assertEquals(wf['steps'], [specs.StepSpec(t) for t in task_list])
        self.assertEquals(wf.steps, [specs.StepSpec(t) for t in task_list])

        # No duplicate nodes
        with self.assertRaises(specs.DuplicateTaskException):
            wf.add_task(self.add, 'add')

        # Test with multiple tasks of the same type (different name)
        wf.add_task(self.add, 'add2')
        task_list += [{'name': 'add2', 'task': self.add}]

        self.assertEquals(to_frozenset(wf['steps']), to_frozenset(task_list))
        self.assertEquals(to_frozenset(wf.steps), to_frozenset(task_list))

        self.assertEquals(to_frozenset(wf['steps']),
                          to_frozenset([specs.Spec(t) for t in task_list]))
        self.assertEquals(to_frozenset(wf.steps),
                          to_frozenset([specs.Spec(t) for t in task_list]))

        # Steps should be equal to a list of StepSpec() dicts
        self.assertEquals(to_frozenset(wf['steps']),
                          to_frozenset([specs.StepSpec(t) for t in task_list]))
        self.assertEquals(to_frozenset(wf.steps),
                          to_frozenset([specs.StepSpec(t) for t in task_list]))