def test_get_summary__multiple_sources(self): other_project_config = mock.MagicMock() other_project_config.source.__str__.return_value = "other source" flow = FlowCoordinator.from_steps( self.project_config, [ StepSpec( "1/1", "other:test1", {}, None, other_project_config, from_flow="test", ), StepSpec("1/2", "test2", {}, None, self.project_config, from_flow="test"), ], ) assert ("1) flow: test" + "\n 1) task: other:test1 [from other source]" + "\n 2) task: test2 [from current folder]" ) == flow.get_summary()
def test_freeze(self): with temporary_dir() as path: os.mkdir(".git") os.makedirs("unpackaged/test") task = create_task(DeployBundles, {"path": path + "/unpackaged"}) step = StepSpec(1, "deploy_bundles", task.task_config, None) steps = task.freeze(step) self.assertEqual( [ { "is_required": True, "kind": "metadata", "name": "Deploy unpackaged/test", "path": "deploy_bundles.test", "step_num": "1.1", "task_class": "cumulusci.tasks.salesforce.UpdateDependencies", "task_config": { "options": { "dependencies": [ { "ref": task.project_config.repo_commit, "repo_name": "TestRepo", "repo_owner": "TestOwner", "subfolder": "unpackaged/test", } ] }, "checks": [], }, } ], steps, )
def to_spec(self, skip: bool = False): task_class = import_class(self.task_class) assert issubclass(task_class, BaseTask) return StepSpec( step_num=self.step_num, task_name=self. path, # skip from_flow path construction in StepSpec ctr task_config=self.task_config or {"options": {}}, task_class=task_class, skip=skip, )
def test_get_summary__substeps(self): flow = FlowCoordinator.from_steps( self.project_config, [ StepSpec("1", "test", {}, None, self.project_config, from_flow="test") ], ) assert flow.get_summary() == ""
def to_spec(self, project_config, skip: bool = False): if self.source: project_config = project_config.include_source(self.source) task_class = import_class(self.task_class) assert issubclass(task_class, BaseTask) return StepSpec( step_num=self.step_num, task_name=self.path, # skip from_flow path construction in StepSpec ctr task_config=self.task_config or {"options": {}}, task_class=task_class, skip=skip, project_config=project_config, )
def test_freeze_sets_kind(self): task = create_task( Deploy, { "path": "path", "namespace_tokenize": "ns", "namespace_inject": "ns", "namespace_strip": "ns", }, ) step = StepSpec( step_num=1, task_name="deploy", task_config=task.task_config, task_class=None, project_config=task.project_config, ) assert all(s["kind"] == "metadata" for s in task.freeze(step))
def test_freeze(self): task = create_task( UpdateDependencies, { "dependencies": [ { "name": "Install Test Product", "namespace": "ns", "version": "1.0", }, { "repo_owner": "SFDO-Tooling", "repo_name": "CumulusCI-Test", "ref": "abcdef", "subfolder": "src", }, ] }, ) step = StepSpec(1, "test_task", task.task_config, None, task.project_config) steps = task.freeze(step) self.assertEqual( [ { "is_required": True, "kind": "managed", "name": "Install Test Product", "path": "test_task.1", "step_num": "1.1", "source": None, "task_class": None, "task_config": { "options": { "dependencies": [{ "namespace": "ns", "version": "1.0" }], "include_beta": False, "purge_on_delete": True, "allow_newer": True, "allow_uninstalls": False, "security_type": "FULL", }, "checks": [], }, }, { "is_required": True, "kind": "metadata", "name": "Deploy src", "path": "test_task.2", "step_num": "1.2", "source": None, "task_class": None, "task_config": { "options": { "dependencies": [{ "ref": "abcdef", "repo_name": "CumulusCI-Test", "repo_owner": "SFDO-Tooling", "subfolder": "src", }], "include_beta": False, "purge_on_delete": True, "allow_newer": True, "allow_uninstalls": False, "security_type": "FULL", }, "checks": [], }, }, ], steps, )
def test_for_display(self): spec = StepSpec(1, "test_task", {}, None, skip=True) assert "1: test_task [SKIP]" == spec.for_display
def test_repr(self): spec = StepSpec(1, "test_task", {}, None, skip=True) assert "<!SKIP! StepSpec 1:test_task {}>" == repr(spec)
def test_from_steps(self): steps = [StepSpec("1", "test", {}, _TaskReturnsStuff)] flow = FlowCoordinator.from_steps(self.project_config, steps) self.assertEqual(1, len(flow.steps))
def test_freeze__bad_path(self): task = create_task(DeployBundles, {"path": "/bogus"}) step = StepSpec(1, "deploy_bundles", task.task_config, None) steps = task.freeze(step) self.assertEqual([], steps)