Skip to content

Commit

Permalink
Fix test_page_encoding test
Browse files Browse the repository at this point in the history
Don't assume that the history has unencoded id 1.

Broken by commit 85630e2 .

Fix the following error:

```
______________ TestPageJsonEncodingIntegration.test_page_encoding ______________

self = <integration.test_page_revision_json_encoding.TestPageJsonEncodingIntegration object at 0x7fe178521190>
history_id = '529fd61ab1c6cc36'

    def test_page_encoding(self, history_id: str):
        request = dict(
            slug="mypage",
            title="MY PAGE",
            content=f"""<p>Page!<div class="embedded-item" id="History-{history_id}"></div></p>""",
        )
        page_response = self._post("pages", request, json=True)
        api_asserts.assert_status_code_is_ok(page_response)
        sa_session = self._app.model.session
        page_revision = sa_session.scalars(select(model.PageRevision).filter_by(content_format="html")).all()[0]
>       assert '''id="History-1"''' in page_revision.content, page_revision.content
E       AssertionError: <p>Page!</p><div class="embedded-item history placeholder" id="History-2"><p class="title">Embedded Galaxy History - 'test_history'</p><p class="content">[Do not edit this block; Galaxy will fill it in with the annotated History when it is displayed]</p></div><p></p>
E       assert 'id="History-1"' in '<p>Page!</p><div class="embedded-item history placeholder" id="History-2"><p class="title">Embedded Galaxy History - \'test_history\'</p><p class="content">[Do not edit this block; Galaxy will fill it in with the annotated History when it is displayed]</p></div><p></p>'
E        +  where '<p>Page!</p><div class="embedded-item history placeholder" id="History-2"><p class="title">Embedded Galaxy History - \'test_history\'</p><p class="content">[Do not edit this block; Galaxy will fill it in with the annotated History when it is displayed]</p></div><p></p>' = <galaxy.model.PageRevision(1) at 0x7fe0d74d81d0>.content

test/integration/test_page_revision_json_encoding.py:33: AssertionError
```
  • Loading branch information
nsoranzo committed Mar 4, 2024
1 parent 73d5032 commit 031a859
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/integration/test_page_revision_json_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
exported API values are encoded though.
"""

import re

from sqlalchemy import select

from galaxy import model
Expand All @@ -21,6 +23,7 @@ def setUp(self):
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)

def test_page_encoding(self, history_id: str):
history_num_re = re.compile(r'id="History-\d+"')
request = dict(
slug="mypage",
title="MY PAGE",
Expand All @@ -30,13 +33,13 @@ def test_page_encoding(self, history_id: str):
api_asserts.assert_status_code_is_ok(page_response)
sa_session = self._app.model.session
page_revision = sa_session.scalars(select(model.PageRevision).filter_by(content_format="html")).all()[0]
assert '''id="History-1"''' in page_revision.content, page_revision.content
assert history_num_re.search(page_revision.content), page_revision.content
assert f'''id="History-{history_id}"''' not in page_revision.content, page_revision.content

show_page_response = self._get("pages/{}".format(page_response.json()["id"]))
api_asserts.assert_status_code_is_ok(show_page_response)
content = show_page_response.json()["content"]
assert '''id="History-1"''' not in content, content
assert not history_num_re.search(content), content
assert f'''id="History-{history_id}"''' in content, content

def test_page_encoding_markdown(self, history_id: str):
Expand Down

0 comments on commit 031a859

Please sign in to comment.