Example #1
0
    def test_failure(self, mocker):
        sync_mock = mocker.patch.object(tessen, 'sync')
        sync_mock.side_effect = errors.Error('Bad error')
        set_module_args(state='enabled')

        with pytest.raises(AnsibleFailJson):
            tessen.main()
Example #2
0
    def test_disabled(self, mocker):
        sync_mock = mocker.patch.object(tessen, 'sync')
        sync_mock.return_value = True, {}
        set_module_args(state='disabled')

        with pytest.raises(AnsibleExitJson):
            tessen.main()

        _client, path, payload, check_mode = sync_mock.call_args[0]
        assert path == '/api/core/v2/tessen'
        assert payload == dict(opt_out=True)
        assert check_mode is False