How to use the mock.sentinel function in mock

To help you get started, we’ve selected a few mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / gax-python / tests / test__grpc_google_auth.py View on Github external
def test(self, default_mock):
        default_mock.return_value = (
            mock.sentinel.credentials, mock.sentinel.project)
        scopes = ['fake', 'scopes']

        got = _grpc_google_auth.get_default_credentials(scopes)

        self.assertEqual(got, mock.sentinel.credentials)
        default_mock.assert_called_once_with(scopes)
github testing-cabal / mock / tests / testpatch.py View on Github external
        @patch.object(Something, 'next_attribute', sentinel.Patched2)
        def test():
            self.assertEqual(Something.attribute, sentinel.Patched,
                             "unpatched")
            self.assertEqual(Something.next_attribute, sentinel.Patched2,
                             "unpatched")
github pignacio / issue2branch / test / test_trackers / test_bitbucket.py View on Github external
def test_description(self):
        eq_(self._issue().description, sentinel.description)
github mozilla-services / syncclient / tests / test_client.py View on Github external
resp.json.return_value = {
            'hashalg': mock.sentinel.hashalg,
            'id': mock.sentinel.id,
            'key': mock.sentinel.key,
            'uid': mock.sentinel.uid,
            'api_endpoint': mock.sentinel.api_endpoint
        }
        self.requests.get.return_value = resp
        client = SyncClient("bid_assertion", "client_state")

        self.hawk_auth.assert_called_with(algorithm=mock.sentinel.hashalg,
                                          id=mock.sentinel.id,
                                          key=mock.sentinel.key)

        assert client.user_id == mock.sentinel.uid
        assert client.api_endpoint == mock.sentinel.api_endpoint
github p1c2u / wykop-sdk / tests / unit / api / parsers / test_base.py View on Github external
def test_error(
            self,
            mock_get_response,
            mock_get_error,
            mock_resolve_exception,
            base_parser):
        data = mock.sentinel.data
        response = mock.sentinel.response
        error = Error(mock.sentinel.code, mock.sentinel.message)
        mock_get_response.return_value = response
        mock_get_error.return_value = error
        mock_resolve_exception.side_effect = WykopAPIError()

        with pytest.raises(WykopAPIError):
            base_parser.parse(data)

        mock_get_response.assert_called_once_with(data)
        mock_get_error.assert_called_once_with(response)
        mock_resolve_exception.assert_called_once_with(
            error.code, error.message, WykopAPIError)
github Akrog / gcs-client / tests / test_common.py View on Github external
def test_init_values(self):
        """Test that we can initialize values for new instances."""
        params = common.RetryParams(mock.sentinel.max_retries, 2, 3, 4, False)
        self.assertEqual(mock.sentinel.max_retries, params.max_retries)
        self.assertEqual(2, params.initial_delay)
        self.assertEqual(3, params.max_backoff)
        self.assertEqual(4, params.backoff_factor)
        self.assertFalse(params.randomize)
github googleapis / google-auth-library-python / tests / test_app_engine.py View on Github external
def test_sign(self, app_identity):
        app_identity.sign_blob.return_value = (
            mock.sentinel.key_id,
            mock.sentinel.signature,
        )

        signer = app_engine.Signer()
        to_sign = b"123"

        signature = signer.sign(to_sign)

        assert signature == mock.sentinel.signature
        app_identity.sign_blob.assert_called_with(to_sign)
github Sceptre / sceptre / tests / test_stack.py View on Github external
def setup_method(self, test_method):
        self.stack = Stack(
            name='dev/app/stack', project_code=sentinel.project_code,
            template_bucket_name=sentinel.template_bucket_name,
            template_key_prefix=sentinel.template_key_prefix,
            required_version=sentinel.required_version,
            template_path=sentinel.template_path, region=sentinel.region,
            profile=sentinel.profile, parameters={"key1": "val1"},
            sceptre_user_data=sentinel.sceptre_user_data, hooks={},
            s3_details=None, dependencies=sentinel.dependencies,
            role_arn=sentinel.role_arn, protected=False,
            tags={"tag1": "val1"}, external_name=sentinel.external_name,
            notifications=[sentinel.notification],
            on_failure=sentinel.on_failure, iam_role=sentinel.iam_role,
            stack_timeout=sentinel.stack_timeout,
            stack_group_config={}
        )
        self.stack._template = MagicMock(spec=Template)
github bdeeney / PikaChewie / tests / unit / test_agent.py View on Github external
def execute(self):
        self.agent.process(sentinel.channel, sentinel.method, sentinel.header,
                           sentinel.body)
github pignacio / issue2branch / test / test_trackers / test_bitbucket.py View on Github external
def test_get_issue_list_url(self):
        with patch.object(self.tracker, 'get_list_limit') as mock_get_limit:
            mock_get_limit.return_value = '12345'

            eq_(self.tracker.get_issue_list_url(sentinel.config, sentinel.options),
                "https://bitbucket.org/api/1.0/repositories/repo_user"
                "/repo_name/issues?limit=12345")
            mock_get_limit.assert_called_once_with(sentinel.config, sentinel.options)