import http.client
import requests
from unittest import mock

from stuff.mocks import build_mock


class TestBuildMock:

    def test_build_mock_successful(self):
        with build_mock(
            'requests.get',
            return_value=mock.Mock(
                status_code=http.client.OK.value,
                json=lambda: {'test': 'test'}
            )
        ):
            response = requests.get('test')

        assert response.status_code == http.client.OK.value
        assert response.json() == {'test': 'test'}
