コード例 #1
0
ファイル: test_nxos.py プロジェクト: arizvisa/saltstack-salt
    def test_user_absent_user_does_not_exist(self):
        """ UT: nxos module:user_absent method - remove user """

        username = "******"

        side_effect = MagicMock(side_effect=[""])

        with patch.dict(nxos_state.__opts__, {"test": False}):
            with patch.dict(nxos_state.__salt__, {"nxos.cmd": side_effect}):

                result = nxos_state.user_absent(username)

                self.assertEqual(result["name"], "daniel")
                self.assertTrue(result["result"])
                self.assertEqual(result["changes"], {})
                self.assertEqual(result["comment"], "User does not exist")
コード例 #2
0
ファイル: test_nxos.py プロジェクト: arizvisa/saltstack-salt
    def test_user_absent_test_opts(self):
        """ UT: nxos module:user_absent method - remove user """

        username = "******"

        side_effect = MagicMock(side_effect=["daniel", "remove_user", ""])

        with patch.dict(nxos_state.__opts__, {"test": True}):
            with patch.dict(nxos_state.__salt__, {"nxos.cmd": side_effect}):

                result = nxos_state.user_absent(username)

                self.assertEqual(result["name"], "daniel")
                self.assertEqual(result["result"], None)
                self.assertEqual(result["changes"]["old"], "daniel")
                self.assertEqual(result["changes"]["new"], "")
                self.assertEqual(result["comment"], "User will be removed")
コード例 #3
0
ファイル: test_nxos.py プロジェクト: mcalmer/salt
def test_user_absent_user_does_not_exist():
    """
    user_absent method - remove user
    """

    username = "******"

    side_effect = MagicMock(side_effect=[""])

    with patch.dict(nxos_state.__opts__, {"test": False}):
        with patch.dict(nxos_state.__salt__, {"nxos.get_user": side_effect}):

            result = nxos_state.user_absent(username)

            assert result["name"] == "daniel"
            assert result["result"]
            assert result["changes"] == {}
            assert result["comment"] == "User does not exist"
コード例 #4
0
def test_user_absent_test_opts():
    """
    user_absent method - remove user with opts
    """

    username = "******"

    side_effect = MagicMock(side_effect=["daniel", "remove_user", ""])

    with patch.dict(nxos_state.__opts__, {"test": True}):
        with patch.dict(nxos_state.__salt__, {"nxos.cmd": side_effect}):

            result = nxos_state.user_absent(username)

            assert result["name"] == "daniel"
            assert result["result"] is None
            assert result["changes"]["old"] == "daniel"
            assert result["changes"]["new"] == ""
            assert result["comment"] == "User will be removed"
コード例 #5
0
ファイル: test_nxos.py プロジェクト: mcalmer/salt
def test_user_absent():
    """
    user_absent method - remove user
    """

    username = "******"

    salt_mock = {
        "nxos.get_user": MagicMock(side_effect=["daniel", ""]),
        "nxos.remove_user": MagicMock(side_effect=["remove_user"]),
    }

    with patch.dict(nxos_state.__opts__, {"test": False}):
        with patch.dict(nxos_state.__salt__, salt_mock):

            result = nxos_state.user_absent(username)

            assert result["name"] == "daniel"
            assert result["result"]
            assert result["changes"]["old"] == "daniel"
            assert result["changes"]["new"] == ""
            assert result["comment"] == "User removed"