Exemplo n.º 1
0
 def test_notify_to_requester_not_send_notification_if_report_is_now_visible(
         self, mock_send, report_admin):
     request = HttpRequest()
     cache_report = Report(id=1, visible_from_requester=False)
     report = Report(id=1, visible_from_requester=True)
     report_admin.notify_to_requester(request,
                                      report,
                                      cached_obj=cache_report,
                                      change=True)
     mock_send.assert_called_once_with(request)
Exemplo n.º 2
0
 def test_notify_to_requester_return_false_with_method_unknown(
         self, mock_send, report_admin):
     method = 'fake'
     with pytest.raises(TypeError) as excinfo:
         report_admin.notify_to_requester(HttpRequest(),
                                          Report(),
                                          method=method)
     assert '"{}" not available'.format(method) in str(excinfo.value)
     assert mock_send.called is False
Exemplo n.º 3
0
 def test_notify_to_requester_not_send_notification_if_new_report_and_not_is_visible(
         self, mock_send, report_admin):
     report = Report(visible_from_requester=False)
     report_admin.notify_to_requester(HttpRequest(), report, change=False)
     assert mock_send.called is False
Exemplo n.º 4
0
 def test_notify_to_requester_send_notification_if_new_report_and_is_visible(
         self, mock_send, report_admin):
     request = HttpRequest()
     report = Report(visible_from_requester=True)
     report_admin.notify_to_requester(request, report, change=False)
     mock_send.assert_called_once_with(request)
Exemplo n.º 5
0
def report(operator):
    obj = Report()
    obj.content = "bla"
    obj.sender = operator
    obj.save()
    return Message.objects.get(pk=obj.pk)