Пример #1
0
    async def test_reuse_session(self):
        session_class = Mock(return_value=self._session_mock)
        client_maker = _HttpClientMaker(session_class)

        async with client_maker as session1:
            async with client_maker as session2:
                self.assertEqual(session1, self._session_mock)
                self.assertEqual(session2, self._session_mock)
                session_class.assert_called_once()
Пример #2
0
async def test_user_create_success(mock_user_model_create_user: mock.Mock, mock_utcnow: mock.Mock):
    mock_utcnow.return_value = datetime(2019, 1, 1, 23, 59, tzinfo=UTC)
    mock_user_model_create_user.return_value = fixtures.user_fixture()

    result = await domain.create_user(fixtures.new_user_fixture())

    assert result == fixtures.user_fixture()
    mock_utcnow.assert_called_once()
    mock_user_model_create_user.assert_called_once_with(
        fixtures.new_user_fixture(), datetime(2019, 1, 1, 23, 59, tzinfo=UTC)
    )