def test_delete_namespace(self):
        self.test_ns = [
            NS(c1, n1, delete=True, exists=True),
        ]

        openshift_namespaces.run(False, thread_pool_size=1)
        oc = self.oc_clients[c1]
        oc.delete_project.assert_called_with(n1)
        oc.new_project.assert_not_called()
 def test_dup_absent_namespace_all_deletes_should_do_nothing(self):
     self.test_ns = [
         NS(c1, n1, delete=True, exists=False),
         NS(c1, n1, delete=True, exists=False),
         NS(c1, n1, delete=True, exists=False),
     ]
     openshift_namespaces.run(False, thread_pool_size=1)
     oc = self.oc_clients[c1]
     oc.delete_project.assert_not_called()
     oc.new_project.assert_not_called()
    def test_error_handling_project_exists(self):
        oc = self.oc_clients.setdefault(c1, Mock(name=f"oc_{c1}"))
        oc.project_exists.side_effect = StatusCodeError("SomeError")
        self.oc_map.get.return_value = oc

        self.test_ns = [
            NS(c1, "project_raises_exception", delete=True, exists=False),
        ]
        f = io.StringIO()
        with self.assertRaises(SystemExit), contextlib.redirect_stderr(f):
            openshift_namespaces.run(False, thread_pool_size=1)
            self.assertIn("SomeError", f.getvalue())
    def test_dup_present_namespace_some_deletes_should_error(self):
        self.test_ns = [
            NS(c1, n1, delete=False, exists=True),
            NS(c1, n1, delete=True, exists=True),
            NS(c1, n1, delete=True, exists=True),
            NS(c1, n2, delete=False, exists=True),
        ]
        f = io.StringIO()
        with self.assertRaises(SystemExit), contextlib.redirect_stderr(f):
            openshift_namespaces.run(False, thread_pool_size=1)
            self.assertIn("Found multiple definitions", f.getvalue())

        oc = self.oc_clients[c1]
        oc.delete_project.assert_not_called()
        oc.new_project.assert_not_called()