Example #1
0
 def test_unjoin_domain_already_unjoined(self):
     """
         Test unjoining a computer from an Active Directory domain
     """
     with patch("salt.utils.winapi.Com", MagicMock()), patch.object(
         self.WMI, "Win32_ComputerSystem", return_value=[MockWMI_ComputerSystem()]
     ), patch.object(wmi, "WMI", Mock(return_value=self.WMI)), patch(
         "salt.modules.win_system.get_domain_workgroup",
         MagicMock(return_value={"Workgroup": "WORKGROUP"}),
     ):
         self.assertEqual(win_system.unjoin_domain(), "Already joined to WORKGROUP")
Example #2
0
 def test_unjoin_domain(self):
     """
         Test unjoining a computer from an Active Directory domain
     """
     with patch("salt.utils.winapi.Com", MagicMock()), patch.object(
         self.WMI, "Win32_ComputerSystem", return_value=[MockWMI_ComputerSystem()]
     ), patch.object(wmi, "WMI", Mock(return_value=self.WMI)), patch(
         "salt.modules.win_system.get_domain_workgroup",
         MagicMock(return_value={"Domain": "contoso.com"}),
     ):
         self.assertDictEqual(
             win_system.unjoin_domain(),
             {"Workgroup": "WORKGROUP", "Restart": False},
         )