def test_rename_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) original_view_name = "test_rename_view" v = jk.create_view(original_view_name, SectionedView) try: expected_section_name = "MyNewSection" v.add_section("hudson.plugins.sectioned_view.TextSection", expected_section_name) expected_view_name = "test_rename_view2" v.rename(expected_view_name) assert jk.find_view(original_view_name) is None finally: tmp = jk.find_view(original_view_name) if tmp: tmp.delete() with clean_view(v): assert v.name == expected_view_name tmp_view = jk.find_view(expected_view_name) assert tmp_view is not None assert tmp_view.name == expected_view_name result = tmp_view.sections assert result is not None assert isinstance(result, list) assert len(result) == 1 assert result[0].name == expected_section_name
def test_find_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) expected_name = "all" v = jk.find_view(expected_name) assert isinstance(v, AllView)
def test_find_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) expected_name = "all" v = jk.find_view(expected_name) assert v is not None assert v.name == expected_name
def test_find_missing_view(self): # test logic j = Jenkins(self.mock_jenkins_data_io) View = j.find_view("DoesNotExist") # verification self.assertEqual(View, None, "No valid view should have been found.")
def test_clone_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) original_view_name = "test_clone_view" vw1 = jk.create_view(original_view_name, SectionedView) with clean_view(vw1): expected_section_name = "MyNewSection" vw1.add_section("hudson.plugins.sectioned_view.TextSection", expected_section_name) expected_view_name = "test_clone_view2" vw2 = vw1.clone(expected_view_name) assert vw2 is not None with clean_view(vw2): tmp_view = jk.find_view(expected_view_name) assert tmp_view is not None assert tmp_view.name == expected_view_name result = tmp_view.sections assert result is not None assert isinstance(result, list) assert len(result) == 1 assert result[0].name == expected_section_name
def test_delete_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) expected_view_name = "test_delete_view" vw = jk.create_view(expected_view_name, ListView) vw.delete() assert jk.find_view(expected_view_name) is None
def test_find_view_primary_view(self): # test logic j = Jenkins(self.mock_jenkins_data_io) View = j.find_view(self.primary_view_name) # verification self.assertNotEqual(View, None, "code should return a valid pyjen.view object") self.assertEqual(View.name, self.primary_view_name, "incorrect view returned by jenkins object") self.mock_jenkins_data_io.clone.assert_called_once_with(self.primary_view_url)
def test_rename_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) original_view_name = "test_rename_view1" vw = jk.create_view(original_view_name, ListView) try: expected_name = "test_rename_view2" vw.rename(expected_name) assert jk.find_view(original_view_name) is None finally: tmp = jk.find_view(original_view_name) if tmp: tmp.delete() with clean_view(vw): assert vw.name == expected_name tmp_view = jk.find_view(expected_name) assert tmp_view is not None assert tmp_view.name == expected_name
def test_find_missing_view(jenkins_env): jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"])) v = jk.find_view("DoesNotExist") assert v is None