def test_end_date_in_the_past(self): owner = UserFactory.create() EventFactory.create(end=now() - timedelta(days=3), owner=owner) with patch('remo.events.tasks.send_remo_mail') as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_end_date_in_the_past(self): owner = UserFactory.create() EventFactory.create(end=now() - timedelta(days=3), owner=owner) with patch("remo.events.tasks.send_remo_mail") as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_end_date_in_the_future(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end + timedelta(days=2), owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_end_date_in_the_future(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end + timedelta(days=2), owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(not mail_mock.called)
def test_with_existing_action_item(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end, owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_with_existing_action_item(self): owner = UserFactory.create() EventFactory.create(start=self.start, end=self.end, owner=owner) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_with_existing_action_item(self): owner = UserFactory.create() end = now() - timedelta(days=1) EventFactory.create(end=end, owner=owner) with patch("remo.events.tasks.send_remo_mail") as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch("remo.events.tasks.send_remo_mail") as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_post_event_metrics(self): model = ContentType.objects.get_for_model(Event) items = ActionItem.objects.filter(content_type=model) ok_(not items.exists()) start = now() - timedelta(days=4) end = now() - timedelta(days=1) user = UserFactory.create(groups=['Rep']) EventFactory.create(owner=user, start=start, end=end) notify_event_owners_to_input_metrics() items = ActionItem.objects.filter(content_type=model) eq_(items.count(), 1)
def test_with_existing_action_item(self): owner = UserFactory.create() end = now() - timedelta(days=1) EventFactory.create(end=end, owner=owner) with patch('remo.events.tasks.send_remo_mail') as mail_mock: notify_event_owners_to_input_metrics() ok_(mail_mock.called) with patch('remo.events.tasks.send_remo_mail') as mail_mock1: notify_event_owners_to_input_metrics() ok_(not mail_mock1.called)
def test_post_event_metrics(self): model = ContentType.objects.get_for_model(Event) items = ActionItem.objects.filter(content_type=model) ok_(not items.exists()) start = now() - timedelta(days=4) end = now() - timedelta(days=1) user = UserFactory.create(groups=['Rep']) event = EventFactory.create(owner=user, start=start, end=end) notify_event_owners_to_input_metrics() items = ActionItem.objects.filter(content_type=model, object_id=event.id) eq_(items.count(), 1)
def test_base(self): owner = UserFactory.create() event = EventFactory.create(start=self.start, end=self.end, owner=owner) subject = ('[Reminder] Please add the actual metrics for event {0}'.format(event.name)) template = 'email/event_creator_notification_to_input_metrics.jinja' with patch('remo.events.tasks.send_remo_mail.delay') as mail_mock: notify_event_owners_to_input_metrics() eq_(mail_mock.call_count, 1) expected_call_list = [call(subject=subject, recipients_list=[owner.id], email_template=template, data={'event': event})] eq_(mail_mock.call_args_list, expected_call_list)
def test_base(self): owner = UserFactory.create() end = now() - timedelta(days=1) event = EventFactory.create(end=end, owner=owner) subject = "[Reminder] Please add the actual metrics for event {0}".format(event.name) template = "email/event_creator_notification_to_input_metrics.txt" with patch("remo.events.tasks.send_remo_mail") as mail_mock: notify_event_owners_to_input_metrics() eq_(mail_mock.call_count, 1) expected_call_list = [ call(subject=subject, recipients_list=[owner.id], email_template=template, data={"event": event}) ] eq_(mail_mock.call_args_list, expected_call_list)
def test_base(self): owner = UserFactory.create() event = EventFactory.create(end=now(), owner=owner) subject = ('[Reminder] Please add the actual metrics for event {0}' .format(event.name)) template = 'email/event_creator_notification_to_input_metrics.txt' with patch('remo.events.tasks.send_remo_mail') as mail_mock: notify_event_owners_to_input_metrics() eq_(mail_mock.call_count, 1) expected_call_list = [call(subject=subject, recipients_list=[owner.id], email_template=template, data={'event': event})] eq_(mail_mock.call_args_list, expected_call_list)
def test_resolve_post_event_metrics(self): model = ContentType.objects.get_for_model(Event) items = ActionItem.objects.filter(content_type=model) ok_(not items.exists()) start = now() - timedelta(days=4) end = now() - timedelta(days=1) user = UserFactory.create(groups=['Rep']) event = EventFactory.create(owner=user, start=start, end=end) notify_event_owners_to_input_metrics() items = ActionItem.objects.filter(content_type=model, object_id=event.id) eq_(items.count(), 1) EventMetricOutcomeFactory.create(event=event) for item in items: ok_(item.completed) ok_(item.resolved)