示例#1
0
 def test_decision_editor_set_on_update(self):
     # Create the decision
     user1 = UserFactory()
     decision = DecisionFactory(author=user1, editor=user1)
     # Have a different user update it
     user2 = UserFactory()
     request = RequestFactory()
     request.user = user2
     decision_update_view = DecisionUpdate()
     decision_update_view.request = request
     decision_update_view.object = decision
     decision_update_view.get_object = lambda: decision
     decision_update_view.last_status = 'dummy'
     form = DecisionForm(instance=decision)
     form.cleaned_data = {'watch': True}
     decision_update_view.form_valid(form)
     self.assertEqual(decision.editor, user2)
示例#2
0
 def test_decision_editor_set_on_update(self):
     # Create the decision
     user1 = UserFactory()
     decision = DecisionFactory(author=user1,
                                editor=user1)
     # Have a different user update it
     user2 = UserFactory()
     request = RequestFactory()
     request.user = user2
     decision_update_view = DecisionUpdate()
     decision_update_view.request = request
     decision_update_view.object = decision
     decision_update_view.get_object = lambda: decision
     decision_update_view.last_status = 'dummy'
     form = DecisionForm(instance=decision)
     form.cleaned_data = {'watch': True, 'minor_edit': False}
     decision_update_view.form_valid(form)
     self.assertEqual(decision.editor, user2)
示例#3
0
 def test_user_can_unwatch_a_decision(self):
     org_user = OrganizationUserFactory()
     org = org_user.organization
     user = org_user.user
     decision = DecisionFactory(organization=org)
     # Confirm decision has a single watcher
     self.assertEqual(decision.watchers.count(), 1)
     # Get the view ready
     request = RequestFactory()
     request.user = user
     decision_update_view = DecisionUpdate()
     decision_update_view.request = request
     decision_update_view.object = decision
     decision_update_view.get_object = lambda: decision
     decision_update_view.last_status = 'dummy'
     form = DecisionForm(instance=decision)
     form.cleaned_data = {'watch': False}
     # Run the form_valid method to stop observing
     decision_update_view.form_valid(form)
     self.assertEqual(decision.watchers.count(), 0)
示例#4
0
 def test_user_can_unwatch_a_decision(self):
     org_user = OrganizationUserFactory()
     org = org_user.organization
     user = org_user.user
     decision = DecisionFactory(organization=org)
     # Confirm decision has a single watcher
     self.assertEqual(decision.watchers.count(), 1)
     # Get the view ready
     request = RequestFactory()
     request.user = user
     decision_update_view = DecisionUpdate()
     decision_update_view.request = request
     decision_update_view.object = decision
     decision_update_view.get_object = lambda: decision
     decision_update_view.last_status = 'dummy'
     form = DecisionForm(instance=decision)
     form.cleaned_data = {'watch': False, 'minor_edit': False}
     # Run the form_valid method to stop observing
     decision_update_view.form_valid(form)
     self.assertEqual(decision.watchers.count(), 0)