コード例 #1
0
    def test_not_found(self, ctx, mock_member_repository: MagicMock,
                       member_manager: MemberManager):
        # Given...
        mock_member_repository.search_member_by = MagicMock(return_value=([],
                                                                          0))

        # When...
        with raises(MemberNotFoundError):
            member_manager.get_logs(ctx, TEST_USERNAME)
コード例 #2
0
    def test_fetch_failed(self, ctx, mock_logs_repository: MagicMock,
                          mock_member_repository: MagicMock,
                          sample_member: Member,
                          member_manager: MemberManager):
        # Given...
        mock_member_repository.search_member_by = MagicMock(
            return_value=([sample_member], 1))
        mock_logs_repository.get_logs = MagicMock(side_effect=LogFetchError)

        # When...
        result = member_manager.get_logs(ctx, TEST_USERNAME)

        # Expect use case to 'fail open', do not throw any error, assume there is no log.
        assert [] == result
コード例 #3
0
    def test_happy_path(self, ctx, mock_logs_repository: MagicMock,
                        mock_member_repository: MagicMock,
                        sample_member: Member, member_manager: MemberManager):
        # Given...
        mock_member_repository.search_member_by = MagicMock(
            return_value=([sample_member], 1))

        # When...
        result = member_manager.get_logs(ctx, TEST_USERNAME)

        # Expect...
        assert TEST_LOGS == result
        mock_logs_repository.get_logs.assert_called_once_with(
            ctx, TEST_USERNAME, [])