예제 #1
0
    def test_document_saved_signal(self):
        """
        Tests that the document_saved signal is sent with arguments.
        """
        handler = Mock()

        document_saved.connect(handler, sender='test')
        document_saved.send(sender='test', doc_obj=self.doc_obj)

        handler.assert_called_once_with(sender='test',
                                        signal=document_saved,
                                        doc_obj=self.doc_obj)
예제 #2
0
    def test_update_monitors(self):
        """
        Tests the update_monitors signal receiver.
        """
        assert Monitor.objects.get(pk=3).status == 'RED'
        assert Monitor.objects.get(pk=4).status == 'RED'

        distillery = Distillery.objects.get(pk=1)
        doc_obj = DocumentObj(data={}, doc_id='1', collection=str(distillery))
        document_saved.send(sender='document_saved', doc_obj=doc_obj)

        self.assertEqual(Monitor.objects.get(pk=3).status, 'GREEN')
        self.assertEqual(Monitor.objects.get(pk=4).status, 'RED')