def test_ensure_command_called(self):
        """
        Testing that command is executed with correct args
        :return:
        """
        set_module_args({
            'operation': "Upload",
            'opsName': 'Uploading_testi',
            'DN': "PLMN-PLMN/MRBTS-746",
        })

        with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
            stdout = 'configuration updated'
            stderr = ''
            return_code = 0
            mock_run_command.return_value = return_code, stdout, stderr  # successful execution

            with self.assertRaises(AnsibleExitJson) as result:
                netact_cm_command.main()
            print(result.exception.args)
            self.assertTrue(result.exception.args[0]['changed'])  # ensure result is changed

        mock_run_command.assert_called_once_with(
            ['/opt/oss/bin/racclimx.sh', '-op', 'Upload', '-opsName', 'Uploading_testi',
             '-DN', 'PLMN-PLMN/MRBTS-746'],
            check_rc=True)
    def test_ensure_backupPlanName_outputs_correctly(self):
        """
        Testing that command is executed with correct args
        :return:
        """
        set_module_args({
            'operation': "Provision",
            'opsName': 'Provision_test',
            'WS': "PLMN-PLMN/MRBTS-746",
            'createBackupPlan': "Yes",
            'backupPlanName': "backupPlanName"
        })

        with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
            stdout = 'configuration updated'
            stderr = ''
            return_code = 0
            mock_run_command.return_value = return_code, stdout, stderr  # successful execution

            with self.assertRaises(AnsibleExitJson) as result:
                netact_cm_command.main()
            print(result.exception.args)
            self.assertTrue(result.exception.args[0]['changed'])  # ensure result is changed

        mock_run_command.assert_called_once_with(
            ['/opt/oss/bin/racclimx.sh', '-op', 'Provision', '-opsName', 'Provision_test',
             '-WS', 'PLMN-PLMN/MRBTS-746', '-createBackupPlan', 'true', '-backupPlanName', 'backupPlanName'],
            check_rc=True)
 def test_module_fail_when_required_args_missing(self):
     """
     Testing that command is failing if args are missing
     :return:
     """
     with self.assertRaises(AnsibleFailJson):
         set_module_args({})
         netact_cm_command.main()
         self.assertTrue(False)
    def test_withwrongargs(self):
        """
        Testing that wrong attribute causing error
        :return:
        """
        set_module_args({
            'operation': "Upload",
            'opsName': 'Uploading_testi',
            'MR': "PLMN-PLMN/MRBTS-746",
            'abc': 'abc'
        })

        with self.assertRaises(AnsibleFailJson):
            with patch.object(basic.AnsibleModule, 'run_command') as mock_run_command:
                stdout = 'configuration updated'
                stderr = ''
                return_code = 0
                mock_run_command.return_value = return_code, stdout, stderr  # successful execution

                with self.assertRaises(AnsibleExitJson) as result:
                    netact_cm_command.main()
                self.assertTrue(result.exception.args[0]['changed'])  # ensure result is changed

            self.assertFalse(True)  # ensure result is changed