Exemplo n.º 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)
Exemplo n.º 2
0
 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}))
Exemplo n.º 3
0
 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')
Exemplo n.º 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)
Exemplo n.º 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}))
Exemplo n.º 6
0
 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)
Exemplo n.º 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))
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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()))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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()))
Exemplo n.º 21
0
 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)
Exemplo n.º 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)
Exemplo n.º 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)