Skip to content

Commit

Permalink
Merge branch 'hotfix/2024-10-03_template_refactor_fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven-Eardley committed Oct 10, 2024
2 parents bd4bf46 + 02f50ee commit c89ca6c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def test_01_maned_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')

publisher_template = re.escape(templates.EMAIL_NOTIFICATION)
publisher_to = re.escape(owner.email)
Expand Down Expand Up @@ -401,7 +401,7 @@ def test_01_maned_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 2

# Clear the stream for the next part
Expand Down Expand Up @@ -552,7 +552,7 @@ def test_02_ed_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')

publisher_template = templates.EMAIL_NOTIFICATION
publisher_to = re.escape(owner.email)
Expand Down Expand Up @@ -590,7 +590,7 @@ def test_02_ed_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 1

# Clear the stream for the next part
Expand Down Expand Up @@ -935,7 +935,7 @@ def test_01_maned_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')

publisher_template = templates.EMAIL_NOTIFICATION
publisher_to = re.escape(owner.email)
Expand Down Expand Up @@ -985,7 +985,7 @@ def test_01_maned_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 2

# Clear the stream for the next part
Expand Down Expand Up @@ -1124,7 +1124,7 @@ def test_02_ed_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')

publisher_template = templates.EMAIL_NOTIFICATION
publisher_to = re.escape(owner.email)
Expand Down Expand Up @@ -1162,7 +1162,7 @@ def test_02_ed_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 1

# Clear the stream for the next part
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def test_01_maned_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 2
ctx.pop()

Expand Down Expand Up @@ -1378,7 +1378,7 @@ def test_02_ed_review_emails(self):
assEd_email_matched = re.search(email_log_regex % (assEd_template, assEd_to, assEd_subject),
info_stream_contents,
re.DOTALL)
assert bool(assEd_email_matched)
assert bool(assEd_email_matched), info_stream_contents.strip('\x00')
assert len(re.findall(email_count_string, info_stream_contents)) == 1

ctx.pop()
61 changes: 55 additions & 6 deletions doajtest/unit/application_processors/test_readonly_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,63 @@ def tearDown(self):
super(TestReadOnlyJournal, self).tearDown()
lcc.lookup_code = self.old_lookup_code

###########################################################
# Tests on the publisher's re-journal form
###########################################################
def test_01_readonly_journal_success(self):
"""Give the read-only journal form a full workout"""
def test_01_unknown_context(self):
""" Pulling the wrong context gives an exception """

with self.assertRaises(AttributeError):
formulaic_context = JournalFormFactory.context("readonly")
fc = formulaic_context.processor(source=models.Journal(**JOURNAL_SOURCE))

def test_02_editor_readonly_journal(self):
""" Tests on the editor's read-only journal form """

# we start by constructing it from source
formulaic_context = JournalFormFactory.context("editor_readonly")
fc = formulaic_context.processor(source=models.Journal(**JOURNAL_SOURCE))
assert isinstance(fc, ReadOnlyJournal)
assert fc.form is not None
assert fc.source is not None
assert fc.form_data is None

# now construct it from form data (with a known source)
journal_obj = models.Journal(**JOURNAL_SOURCE)
journal_bibjson_obj = journal_obj.bibjson()
fc = formulaic_context.processor(
formdata=JOURNAL_FORM,
source=journal_obj
)

assert isinstance(fc, ReadOnlyJournal)
assert fc.form is not None
assert fc.source is not None
assert fc.form_data is not None

# see that form has the correct info from an object (after all, that's the only point of having the form)
assert fc.form.title.data == journal_bibjson_obj.title
assert fc.form.pissn.data == journal_bibjson_obj.pissn
assert fc.form.eissn.data == journal_bibjson_obj.eissn

# test each of the workflow components individually ...

# run the validation
assert fc.validate(), fc.form.errors

# run the crosswalk (no need to look in detail, xwalks are tested elsewhere)
fc.form2target()
assert fc.target is None # can't edit data using this form

# patch the target with data from the source
fc.patch_target()
assert fc.target is None # can't edit data using this form

# shouldn't be able to finalise, can't edit data using this form
self.assertRaises(Exception, fc.finalise)

def test_03_maned_readonly_journal(self):
""" Tests on the managing editor's read-only journal form """

# we start by constructing it from source
formulaic_context = JournalFormFactory.context("readonly")
formulaic_context = JournalFormFactory.context("admin_readonly")
fc = formulaic_context.processor(source=models.Journal(**JOURNAL_SOURCE))
assert isinstance(fc, ReadOnlyJournal)
assert fc.form is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_consume_success(self):
assert n.classification == constants.NOTIFICATION_CLASSIFICATION_ASSIGN
assert n.long is not None
assert n.short is not None
assert n.action is not None
assert n.action is None # view.editor.journal_page has been removed
assert not n.is_seen()

def test_consume_fail(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_consume_success(self):
eg.set_editor("editor")
eg.save(blocking=True)

event = models.Event(constants.EVENT_JOURNAL_EDITOR_GROUP_ASSIGNED, context={"journal" : app.data})
event = models.Event(constants.EVENT_JOURNAL_EDITOR_GROUP_ASSIGNED, context={"journal": app.data})
JournalEditorGroupAssignedNotify.consume(event)

time.sleep(1)
Expand All @@ -54,7 +54,7 @@ def test_consume_success(self):
assert n.classification == constants.NOTIFICATION_CLASSIFICATION_ASSIGN
assert n.long is not None
assert n.short is not None
assert n.action is not None
assert n.action is None # view.editor.journal_page has been removed
assert not n.is_seen()

def test_consume_fail(self):
Expand Down
5 changes: 5 additions & 0 deletions doajtest/unit/test_application_forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
NOTE: This test has been disabled due to the removal of the /editor/journal route (see portality.view.editor#51)
"""

import pytest

from doajtest import helpers
Expand Down Expand Up @@ -38,6 +42,7 @@ def test_disable_edit_note_except_editing_user(user_id, expected_result):

class TestEditableNote(DoajTestCase):

@pytest.mark.skip(reason="Untestable: we don't have the editor.journal_page route enabled") # FIXME: permanently?
def test_note_textarea_disabled_correctly(self):
pwd = 'password123'
acc = models.Account(**AccountFixtureFactory.make_editor_source())
Expand Down
4 changes: 3 additions & 1 deletion portality/events/consumers/journal_assed_assigned_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def consume(cls, event):
notification.short = svc.short_notification(cls.ID).format(
issns=journal.bibjson().issns_as_text()
)
notification.action = url_for("editor.journal_page", journal_id=journal.id)

# No action possible due to page removed (see portality.view.editor.journal_page(journal_id))
# notification.action = url_for("editor.journal_page", journal_id=journal.id)

svc.notify(notification)
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def consume(cls, event):
notification.short = svc.short_notification(cls.ID).format(
issns=journal.bibjson().issns_as_text()
)
notification.action = url_for("editor.journal_page", journal_id=journal.id)

# No action possible due to page removed (see portality.view.editor.journal_page(journal_id))
# notification.action = url_for("editor.journal_page", journal_id=journal.id)

svc.notify(notification)

0 comments on commit c89ca6c

Please sign in to comment.