Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom committed Oct 26, 2023
1 parent c57cbf2 commit c4ffa8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions openslides_backend/action/actions/motion/json_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ def validate_entry(self, entry: Dict[str, Any]) -> Dict[str, Any]:
if (
(text := entry.get("text"))
and type(text) == str
and not search("/^<\\w+[^>]*>[\\w\\W]*?<\\/\\w>$/", text)
and not search(r"^<\w+[^>]*>[\w\W]*?<\/\w>$", text)
):
entry["text"] = (
"<p>"
+ sub("/\\n/g", "<br />", sub("/\\n([ \\t]*\\n)+/g", "</p><p>", text))
+ sub(r"\n", "<br />", sub(r"\n([ \t]*\n)+", "</p><p>", text))
+ "</p>"
)

Expand Down Expand Up @@ -418,6 +418,12 @@ def validate_entry(self, entry: Dict[str, Any]) -> Dict[str, Any]:
errors = self.get_create_payload_integrity_error_message(
payload, meeting_id
)
if not (
self.row_state == ImportState.WARNING
or self.row_state == ImportState.ERROR
):
motion_id = self.datastore.reserve_id("motion")
self.apply_instance(payload, "motion/" + str(motion_id))

for err in errors:
entry = self._add_error_to_entry(entry, err)
Expand Down
4 changes: 2 additions & 2 deletions tests/system/action/motion/test_json_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def assert_dual_simple_create(
"submitter_usernames": [{"id": 1, "info": "generated", "value": "admin"}],
}
if is_set_number:
data.update({"number": {"info": ImportState.GENERATED, "value": "2"}})
data.update({"number": {"info": ImportState.GENERATED, "value": "3"}})
expected = {
"state": ImportState.NEW,
"messages": [],
Expand All @@ -334,7 +334,7 @@ def assert_dual_simple_create(
"submitter_usernames": [{"id": 1, "info": "generated", "value": "admin"}],
}
if is_set_number:
data.update({"number": {"info": ImportState.GENERATED, "value": "3"}})
data.update({"number": {"info": ImportState.GENERATED, "value": "4"}})
expected = {
"state": ImportState.NEW,
"messages": [],
Expand Down

0 comments on commit c4ffa8e

Please sign in to comment.