def test_disable_custom_workspace(self): sample_xml = """ <project> <actions/> <description/> <keepDependencies>false</keepDependencies> <properties/> <scm class="hudson.scm.NullSCM"/> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers class="vector"/> <concurrentBuild>false</concurrentBuild> <customWorkspace>my/test/workspace</customWorkspace> <builders/> <publishers/> <buildWrappers/> </project>""" j = JobXML(sample_xml) j.disable_custom_workspace() actual_xml = j.XML self.assertTrue("<customWorkspace>" not in actual_xml)
def test_new_custom_workspace(self): custom_workspace_path = "something/else" j = JobXML(self.__test_config) j.custom_workspace = custom_workspace_path actual_xml = j.XML self.assertTrue("<customWorkspace>" + custom_workspace_path + "</customWorkspace>" in actual_xml)
def test_disable_empty_custom_workspace(self): # our sample config does not have a custom workspace j = JobXML(self.__test_config) # make sure disabling custom workspace when none exists doesn't fail j.disable_custom_workspace() actual_xml = j.XML self.assertTrue("<customWorkspace>" not in actual_xml)
def custom_workspace(self, path): """Defines a new custom workspace for the job :param str path: new custom workspace path """ xml = self.config_xml jobxml = JobXML(xml) jobxml.custom_workspace = path self.config_xml = jobxml.xml