Skip to content
Snippets Groups Projects

Add notification settings

Merged decentral1se requested to merge daniell:develop into develop

Created by: daniell

Users get to decide which notifications they receive from econsensus.

Users can decide between various "levels" of notifications, from nothing to receiving notifications of minor edits.

Merge request reports

Approval is optional

Merged by avatar (Jan 4, 2025 11:40am UTC)

Merge details

  • Changes merged into develop with a7a7e6af.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Contributor

    Created by: daniell

    There are some unresolved UI issues that need to be sorted before merge.

  • Author Contributor

    Created by: martinburchell

    I merged this change into the latest develop branch and there are failing tests:

    ./manage.py test publicweb
    Creating test database for alias 'default'...
    ..................F..................FFFF...FF......................................F.....E............................................................................................................F......E..EEE..E.EE..................................................................E....EEEE......
    ======================================================================
    ERROR: test_sorting_header_links (tests.decision_list_test.DecisionListTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/decision_list_test.py", line 243, in test_sorting_header_links
        default_sort_order = default_sort_options[sort_query]
    KeyError: 'watch'
    
    ======================================================================
    ERROR: test_membership_checked_against_decision_id (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 408, in test_membership_checked_against_decision_id
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_basic_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 55, in test_process_email_basic_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_defined_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 77, in test_process_email_defined_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_empty_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 121, in test_process_email_empty_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_reply_to_comment_with_rating (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 251, in test_process_email_reply_to_comment_with_rating
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_reply_to_feedback_with_rating (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 178, in test_process_email_reply_to_feedback_with_rating
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_unrecognised_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 99, in test_process_email_unrecognised_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_include_watchers_not_run_for_minor_edits (tests.observation_manager_test.ObservationManagerTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/observation_manager_test.py", line 276, in test_include_watchers_not_run_for_minor_edits
        item = add_watchers(item)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/observation_manager_test.py", line 33, in add_watchers
        notice_type=notice_type
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 343, in add
        obj.save()
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
        result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
        return insert_query(self.model, objs, fields, **kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 912, in execute_sql
        cursor.execute(sql, params)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_econsensus`.`notification_observeditem`, CONSTRAINT `user_id_refs_id_8aaa082c` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')
    
    ======================================================================
    ERROR: test_comment_was_posted_adds_user_as_watcher_if_watch_selected (tests.add_comments_test.AddCommentsTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/add_comments_test.py", line 56, in test_comment_was_posted_adds_user_as_watcher_if_watch_selected
        comment_posted_signal_handler(Comment, request=request, comment=comment)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/models.py", line 378, in comment_posted_signal_handler
        user, decision, FEEDBACK_MAJOR_CHANGES
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/models.py", line 302, in additional_message_required
        notification_settings, _ = NotificationSettings.objects.get_or_create(user=user, organization=organization)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 134, in get_or_create
        return self.get_query_set().get_or_create(**kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 452, in get_or_create
        obj.save(force_insert=True, using=self.db)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
        result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
        return insert_query(self.model, objs, fields, **kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 912, in execute_sql
        cursor.execute(sql, params)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_econsensus`.`publicweb_notificationsettings`, CONSTRAINT `user_id_refs_id_4322c7f9edf8b912` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')
    
    ======================================================================
    ERROR: test_comment_was_posted_doesnt_add_user_as_watcher_if_watch_not_selected (tests.add_comments_test.AddCommentsTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/add_comments_test.py", line 96, in test_comment_was_posted_doesnt_add_user_as_watcher_if_watch_not_selected
        comment_posted_signal_handler(Comment, request=request, comment=comment)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/models.py", line 378, in comment_posted_signal_handler
        user, decision, FEEDBACK_MAJOR_CHANGES
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/models.py", line 302, in additional_message_required
        notification_settings, _ = NotificationSettings.objects.get_or_create(user=user, organization=organization)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 134, in get_or_create
        return self.get_query_set().get_or_create(**kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 452, in get_or_create
        obj.save(force_insert=True, using=self.db)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
        result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
        return insert_query(self.model, objs, fields, **kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 912, in execute_sql
        cursor.execute(sql, params)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_econsensus`.`publicweb_notificationsettings`, CONSTRAINT `user_id_refs_id_4322c7f9edf8b912` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')
    
    ======================================================================
    ERROR: test_comment_was_posted_doesnt_remove_watcher_if_watch_selected (tests.add_comments_test.AddCommentsTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/add_comments_test.py", line 150, in test_comment_was_posted_doesnt_remove_watcher_if_watch_selected
        notification.observe(decision, user_1, DECISION_CHANGE)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/notification/models.py", line 428, in observe
        observed_item.save()
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
        result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
        return insert_query(self.model, objs, fields, **kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 912, in execute_sql
        cursor.execute(sql, params)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_econsensus`.`notification_observeditem`, CONSTRAINT `user_id_refs_id_8aaa082c` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')
    
    ======================================================================
    ERROR: test_comment_was_posted_removes_watcher_if_watch_not_selected (tests.add_comments_test.AddCommentsTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/add_comments_test.py", line 109, in test_comment_was_posted_removes_watcher_if_watch_not_selected
        notification.observe(decision, user_1, DECISION_CHANGE)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/notification/models.py", line 428, in observe
        observed_item.save()
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 463, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/base.py", line 551, in save_base
        result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/manager.py", line 203, in _insert
        return insert_query(self.model, objs, fields, **kwargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/query.py", line 1593, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 912, in execute_sql
        cursor.execute(sql, params)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_econsensus`.`notification_observeditem`, CONSTRAINT `user_id_refs_id_8aaa082c` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`))')
    
    ======================================================================
    FAIL: test_edit_decision_description (tests.model_test.DecisionLastModifiedTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/.ve/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
        return func(*args, **keywargs)
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/model_test.py", line 53, in test_edit_decision_description
        self.assertTrue(orig_last_modified < self.last_modified())
    AssertionError: False is not True
    
    ======================================================================
    FAIL: test_changing_new_decisions_org_correct_email_content (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 131, in test_changing_new_decisions_org_correct_email_content
        self.assertEqual(len(outbox), new_org.users.all().count())
    AssertionError: 0 != 13
    
    ======================================================================
    FAIL: test_create_triggers_notification (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 74, in test_create_triggers_notification
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_emails_come_from_organization (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 258, in test_emails_come_from_organization
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_emails_contain_extra_header_info (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 311, in test_emails_contain_extra_header_info
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_notifications_dont_contain_amp (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 150, in test_notifications_dont_contain_amp
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_notifications_sent_to_author (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 159, in test_notifications_sent_to_author
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_all_sorts_result_in_one_arrow_present (tests.decision_list_test.DecisionListTest)
    Assert only one sort class is present in the decision list view
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/decision_list_test.py", line 35, in test_all_sorts_result_in_one_arrow_present
        + ' for page=' + page + ' sort_query=' + sort_query)
    AssertionError: 0 != 1 : Number of ascending sort arrows should be 1. But is 0 for page=discussion sort_query=watch
    
    ======================================================================
    FAIL: test_email_sent_out_on_email_decision (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 311, in test_email_sent_out_on_email_decision
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ----------------------------------------------------------------------
    Ran 299 tests in 81.433s
    
    FAILED (failures=9, errors=13)
    Destroying test database for alias 'default'...
    [09:47:55 econsensus]$
  • Author Contributor

    Created by: martinburchell

    I'll take a look at the failing tests

  • Author Contributor

    Created by: martinburchell

    I can't see an easy way to fix these tests without spending a lot of time so I'm handing this back to Daniel to fix

  • Author Contributor

    Created by: martinburchell

    I'm still getting failing tests when I merge this branch

    ======================================================================
    ERROR: test_membership_checked_against_decision_id (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 408, in test_membership_checked_against_decision_id
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_basic_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 55, in test_process_email_basic_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_defined_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 77, in test_process_email_defined_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_empty_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 121, in test_process_email_empty_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_reply_to_comment_with_rating (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 251, in test_process_email_reply_to_comment_with_rating
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_reply_to_feedback_with_rating (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 178, in test_process_email_reply_to_feedback_with_rating
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    ERROR: test_process_email_unrecognised_feedback (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 99, in test_process_email_unrecognised_feedback
        email = getattr(mail, 'outbox')[-1]
    IndexError: list index out of range
    
    ======================================================================
    FAIL: test_create_triggers_notification (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 75, in test_create_triggers_notification
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_emails_come_from_organization (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 229, in test_emails_come_from_organization
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_emails_contain_extra_header_info (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 282, in test_emails_contain_extra_header_info
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_notifications_dont_contain_amp (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 121, in test_notifications_dont_contain_amp
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_notifications_sent_to_author (tests.notification_test.NotificationTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/notification_test.py", line 130, in test_notifications_sent_to_author
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ======================================================================
    FAIL: test_email_sent_out_on_email_decision (tests.command_test.CommandTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/martinb/workspace/econsensus/django/econsensus/publicweb/tests/command_test.py", line 311, in test_email_sent_out_on_email_decision
        self.assertTrue(outbox)
    AssertionError: [] is not True
    
    ----------------------------------------------------------------------
    Ran 298 tests in 84.033s
    
    FAILED (failures=6, errors=7)
  • Author Contributor

    Created by: martinburchell

    I also get the failing tests on a clean checkout:

    cd /tmp/
    git clone https://github.com/daniell/econsensus.git
    cd econsensus/
    git checkout develop
    cd deploy/
    ./bootstrap.py 
    ./tasks.py deploy:dev_fasttests
    cd ../django/econsensus/
    ./manage.py test publicweb
  • decentral1se
    decentral1se @decentral1se started a thread on commit a7a7e6af
270 271 """
271 272 return "<feedback-%s@%s>" % (self.id, Site.objects.get_current().domain)
272 273
274
275 def send_decision_notifications(decision, users):
276 headers = {'Message-ID' : decision.get_message_id()}
277 headers.update(STANDARD_SENDING_HEADERS)
  • Author Contributor

    Created by: samastur

    It would probably be better if these was reversed since Message-ID changes each time and STANDARD_SENDING_HEADERS don't. As it is there is a risk that it won't get set if it is ever added by mistake to standard headers.

  • decentral1se
    decentral1se @decentral1se started a thread on commit a7a7e6af
  • 320 # No notification if the edit is minor
    321 # (An edit by someone other than the author never counts as minor.)
    322 pass
    357 # All watchers of parent get notified of new feedback.
    358 observation_manager.send_notifications(org_users, instance, FEEDBACK_NEW, extra_context, headers, from_email=instance.decision.get_email())
    323 359 else:
    324 from_email = instance.decision.get_email()
    325 send_observation_notices_for(instance, headers=headers, from_email=from_email)
    326 if instance.editor and not notification.is_observing(instance, instance.editor):
    327 send_notice_for(instance, instance.editor, 'feedback_change', headers=headers, from_email=from_email)
    328
    360 # An edit by someone other than the author never counts as minor
    361 if instance.author != instance.editor or not instance.minor_edit:
    362 observation_manager.send_notifications(org_users, instance, FEEDBACK_CHANGE, extra_context, headers, from_email=instance.decision.get_email())
    363 else:
    364 observation_manager.send_notifications(org_users, instance, MINOR_CHANGE, extra_context, headers, from_email=instance.decision.get_email())
    • Author Contributor

      Created by: samastur

      It might be more readable if 'if' statement is used only to set the type of feedback and then have just one send_notifications call.

      Since line is long (pep8!) it took me a while to see that these lines differ only in third argument.

  • decentral1se
    decentral1se @decentral1se started a thread on commit a7a7e6af
  • 5 FEEDBACK_CHANGE, DECISION_CHANGE, FEEDBACK_NEW, COMMENT_NEW, COMMENT_CHANGE,
    6 MINOR_CHANGE)
    7 from notification import models as notification
    8
    9 class ObservationManager(object):
    10 recipient_list = None
    11
    12 def __init__(self):
    13 self.recipient_list = set()
    14
    15 def _get_decision(self, item):
    16 if hasattr(item, 'content_object'):
    17 item = item.content_object
    18 if hasattr(item, 'decision'):
    19 item = item.decision
    20 return item
    • Author Contributor

      Created by: samastur

      My understanding: get decision from item.decision, item.content_object or item itself (in order of desirability)

      If yes, then it could be made more explicit with couple of 'elif's. If not, then there is a bug.

    Please register or sign in to reply
    Loading