示例#1
0
 def test_base(self):
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep, start_date=get_date(days=-1), is_unavailable=False)
     set_unavailability_flag()
     status = UserStatus.objects.get(user=rep)
     ok_(status.is_unavailable)
示例#2
0
文件: test_views.py 项目: seocam/remo
 def test_get_as_anonymous(self):
     user = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     client = Client()
     client.get(reverse('edit_availability',
                        kwargs={'display_name': display_name}))
示例#3
0
文件: test_views.py 项目: seocam/remo
 def test_get_as_owner(self):
     user = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     self.get(url=url, user=user)
     self.assertTemplateUsed('edit_availability.html')
示例#4
0
 def test_base(self):
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep, start_date=get_date(days=-1),
                              is_unavailable=False)
     set_unavailability_flag()
     status = UserStatus.objects.get(user=rep)
     ok_(status.is_unavailable)
示例#5
0
 def test_get_as_anonymous(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     client = Client()
     client.get(reverse('edit_availability',
                        kwargs={'display_name': display_name}))
示例#6
0
文件: test_views.py 项目: seocam/remo
 def test_get_as_other_rep(self):
     user = UserFactory.create()
     rep = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     self.get(url=url, user=rep)
示例#7
0
 def test_user_without_mentor(self):
     rep = UserFactory.create(userprofile__mentor=None)
     UserStatusFactory.create(user=rep)
     eq_(len(mail.outbox), 1)
     eq_(mail.outbox[0].subject,
         'Confirm if you are available for Reps activities')
     eq_(mail.outbox[0].to[0],
         '{0} <{1}>'.format(rep.get_full_name(), rep.email))
示例#8
0
 def test_get_as_owner(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     self.get(url=url, user=user)
     self.assertTemplateUsed('edit_availability.html')
示例#9
0
 def test_get_as_other_rep(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     rep = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     self.get(url=url, user=rep)
示例#10
0
 def test_user_without_mentor(self, mocked_mail):
     task = MagicMock()
     task.task_id = 1
     mocked_mail.return_value = task
     rep = UserFactory.create(userprofile__mentor=None)
     UserStatusFactory.create(user=rep)
     ok_(mocked_mail.called)
     eq_(mocked_mail.call_count, 1)
     data = mocked_mail.call_args_list[0][1]
     eq_(data['kwargs']['subject'], 'Confirm if you are available for Reps activities')
示例#11
0
 def test_get_as_other_rep(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     rep = UserFactory.create()
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     with self.login(rep) as client:
         client.get(url, user=rep)
示例#12
0
 def test_get_as_owner(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     with self.login(user) as client:
         response = client.get(url, user=user)
     self.assertJinja2TemplateUsed(response, 'edit_availability.jinja')
示例#13
0
 def test_get_as_owner(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     display_name = user.userprofile.display_name
     UserStatusFactory.create(user=user)
     url = reverse('edit_availability',
                   kwargs={'display_name': display_name})
     with self.login(user) as client:
         response = client.get(url, user=user)
     self.assertJinja2TemplateUsed(response, 'edit_availability.jinja')
示例#14
0
 def test_user_without_mentor(self, mocked_mail):
     task = MagicMock()
     task.task_id = 1
     mocked_mail.return_value = task
     rep = UserFactory.create(userprofile__mentor=None)
     UserStatusFactory.create(user=rep)
     ok_(mocked_mail.called)
     eq_(mocked_mail.call_count, 1)
     data = mocked_mail.call_args_list[0][1]
     eq_(data['kwargs']['subject'],
         'Confirm if you are available for Reps activities')
示例#15
0
    def test_with_user_unavailable(self):
        mentor = UserFactory.create(groups=["Mentor"])
        today = now().date()
        rep = UserFactory.create(
            groups=["Rep"], userprofile__mentor=mentor, userprofile__date_joined_program=get_date(days=-100)
        )
        UserStatusFactory.create(user=rep)
        NGReportFactory.create(user=rep, report_date=today - timedelta(weeks=5))

        with patch("remo.reports.utils.send_remo_mail") as mail_mock:
            send_first_report_notification()

        ok_(not mail_mock.called)
示例#16
0
 def test_base(self, mocked_mail):
     task = MagicMock()
     task.task_id = 1
     mocked_mail.return_value = task
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep)
     ok_(mocked_mail.called)
     eq_(mocked_mail.call_count, 2)
     data1 = mocked_mail.call_args_list[0][1]
     data2 = mocked_mail.call_args_list[1][1]
     eq_(data1['kwargs']['subject'], 'Confirm if you are available for Reps activities')
     eq_(data2['kwargs']['subject'], ('Reach out to {0} - expected to be available '
                                      'again').format(rep.get_full_name()))
示例#17
0
 def test_base(self):
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep)
     eq_(len(mail.outbox), 2)
     eq_(mail.outbox[0].subject,
         'Confirm if you are available for Reps activities')
     msg = ('Reach out to {0} - expected to be available again'
            .format(rep.get_full_name()))
     eq_(mail.outbox[1].subject, msg)
     eq_(mail.outbox[0].to[0],
         '{0} <{1}>'.format(rep.get_full_name(), rep.email))
     eq_(mail.outbox[1].to[0],
         '{0} <{1}>'.format(mentor.get_full_name(), mentor.email))
示例#18
0
 def test_base(self):
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep)
     eq_(len(mail.outbox), 2)
     eq_(mail.outbox[0].subject,
         'Confirm if you are available for Reps activities')
     msg = ('Reach out to {0} - expected to be available again'
            .format(rep.get_full_name()))
     eq_(mail.outbox[1].subject, msg)
     eq_(mail.outbox[0].to[0],
         '{0} <{1}>'.format(rep.get_full_name(), rep.email))
     eq_(mail.outbox[1].to[0],
         '{0} <{1}>'.format(mentor.get_full_name(), mentor.email))
示例#19
0
    def test_with_user_unavailable(self):
        mentor = UserFactory.create(groups=['Mentor'])
        today = now().date()
        rep = UserFactory.create(
            groups=['Rep'],
            userprofile__mentor=mentor,
            userprofile__date_joined_program=get_date(days=-100))
        UserStatusFactory.create(user=rep)
        NGReportFactory.create(user=rep,
                               report_date=today - timedelta(weeks=5))

        with patch('remo.reports.utils.send_remo_mail') as mail_mock:
            send_first_report_notification()

        ok_(not mail_mock.called)
示例#20
0
 def test_base(self, mocked_mail):
     task = MagicMock()
     task.task_id = 1
     mocked_mail.return_value = task
     mentor = UserFactory.create()
     rep = UserFactory.create(userprofile__mentor=mentor)
     UserStatusFactory.create(user=rep)
     ok_(mocked_mail.called)
     eq_(mocked_mail.call_count, 2)
     data1 = mocked_mail.call_args_list[0][1]
     data2 = mocked_mail.call_args_list[1][1]
     eq_(data1['kwargs']['subject'],
         'Confirm if you are available for Reps activities')
     eq_(data2['kwargs']['subject'],
         ('Reach out to {0} - expected to be available '
          'again').format(rep.get_full_name()))
示例#21
0
文件: test_forms.py 项目: seocam/remo
 def remove_unavailability_status(self):
     user = UserFactory.create()
     date = get_date()
     data = {'expected_date': date}
     user_status = UserStatusFactory.create(user=user, expected_date=date)
     form = UserStatusForm(data, instance=user_status)
     ok_(form.is_valid())
     ok_(not user_status.end_date)
     db_obj = form.save()
     eq_(db_obj.expected_date, get_date())
     eq_(db_obj.user.get_full_name(), user.get_full_name())
     ok_(db_obj.return_date)
示例#22
0
 def remove_unavailability_status(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     date = get_date()
     data = {'expected_date': date}
     user_status = UserStatusFactory.create(user=user, expected_date=date)
     form = UserStatusForm(data, instance=user_status)
     ok_(form.is_valid())
     ok_(not user_status.end_date)
     db_obj = form.save()
     eq_(db_obj.expected_date, get_date())
     eq_(db_obj.user.get_full_name(), user.get_full_name())
     ok_(db_obj.return_date)
示例#23
0
 def remove_unavailability_status(self):
     mentor = UserFactory.create()
     user = UserFactory.create(userprofile__mentor=mentor)
     start_date = get_date()
     expected_date = get_date(days=1)
     data = {'start_date': start_date,
             'expected_date': expected_date}
     user_status = UserStatusFactory.create(user=user,
                                            expected_date=expected_date,
                                            start_date=start_date)
     form = UserStatusForm(data, instance=user_status)
     ok_(form.is_valid())
     ok_(not user_status.end_date)
     db_obj = form.save()
     eq_(db_obj.expected_date, get_date())
     eq_(db_obj.user.get_full_name(), user.get_full_name())
     ok_(db_obj.return_date)