コード例 #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_by_username(ctx, TEST_USERNAME)

        # Expect...
        mock_member_repository.search_member_by.assert_called_once_with(
            ctx, username=TEST_USERNAME)
コード例 #2
0
    def test_happy_path(self, ctx, 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_by_username(ctx, TEST_USERNAME)

        # Expect...
        assert sample_member == result
        mock_member_repository.search_member_by.assert_called_once_with(
            ctx, username=TEST_USERNAME)