Skip to content

Feature/pagination#80

Open
michelthies wants to merge 4 commits into
mainfrom
feature/pagination
Open

Feature/pagination#80
michelthies wants to merge 4 commits into
mainfrom
feature/pagination

Conversation

@michelthies
Copy link
Copy Markdown
Contributor

Added pagitation to the public, private and user timelines.

@michelthies michelthies marked this pull request as draft April 5, 2024 14:59
@michelthies michelthies marked this pull request as ready for review April 5, 2024 15:06
@fridge7809
Copy link
Copy Markdown
Collaborator

This feature currently breaks 2 test cases because it relies on the flash messages.

  1. test_app_timelines
  2. test_api_get_latest_msgs

It would also break the api since it relies on the latest message counter. We need to change the implementation of some logic to make the tests pass.

collected 13 items

tests/maxitwit_test.py ....F.......F                                                                                                                                                                 [100%]

================================================================================================= FAILURES =================================================================================================
_________________________________________________________________________________________ test_api_get_latest_msgs _________________________________________________________________________________________

    def test_api_get_latest_msgs():
        username = "a"
        query = {"no": 20, "latest": 4}
        url = f"{API_URL}:{API_PORT}/msgs"
        response = requests.get(url, headers=HEADERS, params=query)
>       assert response.status_code == 200
E       assert 500 == 200
E        +  where 500 = <Response [500]>.status_code

tests/maxitwit_test.py:184: AssertionError
____________________________________________________________________________________________ test_app_timelines ____________________________________________________________________________________________

    def test_app_timelines():
        """Make sure that timelines work"""
        _, http_session = register_and_login("foo", "default")
        add_message(http_session, "the message by foo")
        logout(http_session)
        _, http_session = register_and_login("bar", "default")
        add_message(http_session, "the message by bar")
        r = http_session.get(f"{APP_URL}:{APP_PORT}/public")
        assert "the message by foo" in r.text
        assert "the message by bar" in r.text

        # bar's timeline should just show bar's message
        r = http_session.get(f"{APP_URL}:{APP_PORT}/")
        assert "the message by foo" not in r.text
        assert "the message by bar" in r.text

        # now let's follow foo
        r = http_session.get(f"{APP_URL}:{APP_PORT}/foo/follow", allow_redirects=True)
        # Needed to modify &#34; to &quot;
        assert "You are now following &quot;foo&quot;" in r.text

        # we should now see foo's message
        r = http_session.get(f"{APP_URL}:{APP_PORT}/")
        assert "the message by foo" in r.text
        assert "the message by bar" in r.text

        # but on the user's page we only want the user's message
        r = http_session.get(f"{APP_URL}:{APP_PORT}/bar")
>       assert "the message by foo" not in r.text
E       assert 'the message by foo' not in '<!DOCTYPE h...body></html>'
E
E         'the message by foo' is contained here:
E           ></strong>the message by foo<small>&mdash; 2024-04-08 @ 10:44</small></p></li></ul><div class="pagination"><div class="pagination-btn"><!-- first page link--><!-- prev page link--></div><div class="pagination-numbers"><!-- page number links--><span class="current">1</span></div><div class="pagination-btn"><!-- next page link--><!-- last page link--></div></div></div><div class="footer">Maxitwit &mdash; An Express application</div></div></body></html>
E         ?           ++++++++++++++++++

tests/maxitwit_test.py:353: AssertionError
========================================================================================= short test summary info ==========================================================================================
FAILED tests/maxitwit_test.py::test_api_get_latest_msgs - assert 500 == 200
FAILED tests/maxitwit_test.py::test_app_timelines - assert 'the message by foo' not in '<!DOCTYPE h...body></html>'
======================================================================================= 2 failed, 11 passed in 8.06s =======================================================================================
[+] Running 4/4
 ✔ Container test_server         Removed                                                                                                                                                              10.3s
 ✔ Container test_api            Removed                                                                                                                                                              10.3s
 ✔ Container maxitwit-test_db-1  Removed                                                                                                                                                               0.3s
 ✔ Network maxitwit-test         Removed                                                                                                                                                               0.1s
ls
Dockerfile.api		Vagrantfile		compose.yaml		node_modules		prisma			sql			tests
Dockerfile.app		__pycache__		coverage		out			prometheus.yml		src			tests_compose.yaml
Dockerfile.test		build_docker_images.sh	db			package-lock.json	remote_files		test.sh			wait_for_compose.sh
ReadMe.md		commitlint.co

@fridge7809
Copy link
Copy Markdown
Collaborator

@michelthies michelthies added the help wanted Extra attention is needed label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants