def test_parse_workflows(self): """Test parsing WORKFLOWS.""" from pinball_ext.workflow.parser import PyWorkflowParser params =\ {'workflows_config': 'tests.pinball_ext.workflow.parser_test.WORKFLOWS'} py_workflow_parser = PyWorkflowParser(params) py_workflow_parser.parse_workflows() self.assertEquals(3, len(py_workflow_parser.workflows)) self.assertEquals(2, len( py_workflow_parser.workflows['some_workflow'].jobs)) self.assertEquals(3, len( py_workflow_parser.workflows['some_other_workflow'].jobs)) self.assertEquals(3, len( py_workflow_parser.workflows['another_workflow'].jobs)) self.assertEquals(24 * 60 * 60, py_workflow_parser.workflows['some_workflow']. schedule.recurrence_seconds) self.assertEquals(60 * 60, py_workflow_parser.workflows['some_other_workflow']. schedule.recurrence_seconds) self.assertEquals(60 * 60, py_workflow_parser.workflows['another_workflow']. schedule.recurrence_seconds) self.assertEquals(py_workflow_parser.workflows_config_str, 'tests.pinball_ext.workflow.parser_test.WORKFLOWS')
def test_parse_workflows(self): """Test parsing WORKFLOWS.""" from pinball_ext.workflow.parser import PyWorkflowParser params =\ {'workflows_config': 'tests.pinball_ext.workflow.parser_test.WORKFLOWS'} py_workflow_parser = PyWorkflowParser(params) py_workflow_parser.parse_workflows() self.assertEquals(3, len(py_workflow_parser.workflows)) self.assertEquals( 2, len(py_workflow_parser.workflows['some_workflow'].jobs)) self.assertEquals( 3, len(py_workflow_parser.workflows['some_other_workflow'].jobs)) self.assertEquals( 3, len(py_workflow_parser.workflows['another_workflow'].jobs)) self.assertEquals( 24 * 60 * 60, py_workflow_parser.workflows['some_workflow']. schedule.recurrence_seconds) self.assertEquals( 60 * 60, py_workflow_parser.workflows['some_other_workflow']. schedule.recurrence_seconds) self.assertEquals( 60 * 60, py_workflow_parser.workflows['another_workflow'].schedule. recurrence_seconds) self.assertEquals(py_workflow_parser.workflows_config_str, 'tests.pinball_ext.workflow.parser_test.WORKFLOWS')
def test_get_workflow_tokens(self): from pinball_ext.workflow.parser import PyWorkflowParser params =\ {'workflows_config': 'tests.pinball_ext.workflow.parser_test.WORKFLOWS'} py_workflow_parser = PyWorkflowParser(params) workflow_tokens = py_workflow_parser.get_workflow_tokens( 'some_workflow') # Two job tokens and one event token. self.assertEqual(3, len(workflow_tokens))
def test_get_schedule_token(self): # Due to a wired interaction between tests caused by dynamic module # imports, the following import statement cannot be placed at the top # level. E.g., see # http://stackoverflow.com/questions/9722343/python-super-behavior-not-dependable from pinball_ext.workflow.parser import PyWorkflowParser params =\ {'workflows_config': 'tests.pinball_ext.workflow.parser_test.WORKFLOWS'} py_workflow_parser = PyWorkflowParser(params) schedule_token = py_workflow_parser.get_schedule_token('some_workflow') self.assertEqual('/schedule/workflow/some_workflow', schedule_token.name)
def test_pinball_config_parses(self): from pinball_ext.workflow.parser import PyWorkflowParser params =\ {'workflows_config': 'pinball_ext.examples.workflows.WORKFLOWS'} py_workflow_parser = PyWorkflowParser(params) py_workflow_parser.parse_workflows()