Esempio n. 1
0
 def test_registry_item_create_handler(self):
     self._test_basic_handling(handlers.registry_item_create_handler)
     body = fixtures.REGISTRY_ITEM_CREATE[0].copy()
     msg = Message(Mock(), body, headers=fixtures.make_headers())
     handlers.registry_item_create_handler(msg, body)
     entries = RegistryEntry.objects.all()
     self.assertEqual(1, entries.count())
Esempio n. 2
0
 def setUp(self):
     self.headers = fixtures.make_headers()
     self.body = fixtures.REC_INIT_QUERY.copy()
     self.correlation_id = self.headers["correlation_id"]
     self.object_id = self.body["dpn_object_id"]
     self.node = self.headers["from"]
     self.reply_key = self.headers["reply_key"]
Esempio n. 3
0
 def setUp(self):
     self.headers = fixtures.make_headers()
     self.body = fixtures.REC_TRANSFER_REQUEST.copy()
     self.correlation_id = self.headers["correlation_id"]
     self.object_id = "some-uuid-that-actually-looks-like-a-uuid"
     self.node = self.headers["from"]
     self.reply_key = self.headers["reply_key"]
Esempio n. 4
0
 def setUp(self):
     self.req = Message(
         KombuMock(), 
         fixtures.REP_LOCATION_REPLY.copy(),
         headers=fixtures.make_headers()
     )
     self.action = SendFileAction.objects.all()[0]
Esempio n. 5
0
    def test_validation(self):

        for k, v in self.fail_headers.items():
            tst_data = fixtures.make_headers()
            for val in v:  # Test Bad Values
                tst_data[k] = val
                frm = MsgHeaderForm(tst_data.copy())
                msg = "Expected a value of %r in %s to be invalid." % (val, k)
                self.assertFalse(frm.is_valid(), "%s" % msg)
            del tst_data[k]
            frm = MsgHeaderForm(tst_data)
            msg = "Expected missing field %s to be invalid." % k
            self.assertFalse(frm.is_valid(), "%s" % msg)

        frm = MsgHeaderForm(data=fixtures.make_headers())
        self.assertTrue(frm.is_valid())
Esempio n. 6
0
 def test_replication_available_reply_handler(self):
     self._test_basic_handling(handlers.replication_available_reply_handler)
     msg = Message(Mock(), fixtures.REP_AVAILABLE_REPLY_ACK.copy(),
                   headers=fixtures.make_headers())
     # It should throw a workflow error if because no matching ingest
     self.assertRaises(DPNWorkflowError,
                       handlers.replication_available_reply_handler,
                       msg, fixtures.REP_AVAILABLE_REPLY_ACK)
Esempio n. 7
0
 def test_replication_verify_reply_handler(self):
     self._test_basic_handling(handlers.replication_verify_reply_handler)
     msg = Message(Mock(), fixtures.REP_VERIFICATION_REPLY.copy(),
                        headers=fixtures.make_headers())
     self.assertRaises(DPNWorkflowError,
                       handlers.replication_verify_reply_handler,
                       msg, fixtures.REP_VERIFICATION_REPLY.copy()
     )
Esempio n. 8
0
 def test_replication_transfer_reply_handler(self):
     self._test_basic_handling(handlers.replication_transfer_reply_handler)
     msg = Message(Mock(), fixtures.REP_TRANSFER_REPLY_ACK.copy(),
                   headers=fixtures.make_headers())
     self.assertRaises(DPNWorkflowError,
                       handlers.replication_transfer_reply_handler,
                       msg, fixtures.REP_TRANSFER_REPLY_ACK.copy()
     )
Esempio n. 9
0
 def setUp(self):
     self.req = Message(KombuMock(), 
         fixtures.REP_TRANSFER_REPLY_ACK.copy(),
         headers=fixtures.make_headers())
     self.fixity_value = (
         "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
     )
     self.bad_fixity_value = "000111ccc"
     self.ingest_dir_out= "dummy_dir"
Esempio n. 10
0
 def test_handle(self):
     tst_data = fixtures.REGISTRY_LIST_DATERANGE.copy()
     msg = Message(Mock(), tst_data, headers=fixtures.make_headers())
     handlers.registry_list_daterange_reply(msg, tst_data)
     entries = NodeEntry.objects.all()
     exp = len(fixtures.REG_SYNC_LIST)
     self.assertEqual(exp, entries.count(),
                      "Expected %d node entries but returned %d" %
                      (exp, entries.count()))
Esempio n. 11
0
 def test_replication_init_query_handler(self):
     self._test_basic_handling(handlers.replication_init_query_handler)
     msg = Message(Mock(), fixtures.REP_INIT_QUERY.copy(),
                   headers=fixtures.make_headers())
     try:
         handlers.replication_init_query_handler(msg,
                                                 fixtures.REP_INIT_QUERY.copy())
     except Exception as err:
         self.fail(
             "Unexpected exception handing a replication init query: %s" % err)
Esempio n. 12
0
 def test_recovery_init_query_handler(self):
     handler = handlers.recovery_init_query_handler
     tst_data = fixtures.REC_INIT_QUERY.copy()
     msg = Message(Mock(), tst_data, headers=fixtures.make_headers())
     
     self._test_basic_handling(handler)
     try:
         handler(msg, tst_data)
     except Exception as err:
         self.fail(
             "Unexpected exception handling a recovery init query: %s" % err)
Esempio n. 13
0
 def test_replication_location_cancel_handler(self):
     self._test_basic_handling(handlers.replication_location_cancel_handler)
     msg = Message(Mock(), fixtures.REP_LOCATION_CANCEL.copy(),
                   headers=fixtures.make_headers())
     # Needed workflow does not exist previous.  Positive case tested
     # in task
     self.assertRaises(DPNWorkflowError,
         handlers.replication_location_cancel_handler,
             msg,
             fixtures.REP_LOCATION_CANCEL.copy()
         )
Esempio n. 14
0
    def test_registry_entry_created_handler(self):
        self._test_basic_handling(handlers.registry_entry_created_handler)
        # these are actual entries sent from other nodes during test.
        for entry in fixtures.REGISTRY_ITEM_CREATE:
            msg = Message(Mock(), entry, headers=fixtures.make_headers())
            handlers.registry_item_create_handler(msg, entry.copy())

        registry_entries = RegistryEntry.objects.all()
        exp = len(fixtures.REGISTRY_ITEM_CREATE)
        self.assertEqual(exp, registry_entries.count(),
                         "Expect %d registry entries created but returned %d" % (
                             exp, registry_entries.count()))
Esempio n. 15
0
    def test_set_headers(self):
        msg = messages.DPNMessage()
        defaults = {
            "from": DPN_NODE_NAME,
            "reply_key": DPN_LOCAL_KEY,
            "correlation_id": None,
            "sequence": msg.sequence,
            "date": None,
            "ttl": None
        }
        for k, v in defaults.items():
            err = "Expected a value of %s for %s but returned %s" % \
                  (v, k, msg.headers[k])
            self.assertTrue(v == msg.headers[k], err)

        exp = fixtures.make_headers()
        msg.set_headers(**exp)
        for k, v in msg.headers.items():
            self.assertTrue(v == exp[k])
Esempio n. 16
0
 def _test_recovery_handler(self, handler, tst_data, error):
     msg = Message(Mock(), tst_data, headers=fixtures.make_headers())
     self._test_basic_handling(handler)
     self.assertRaises(error, handler, msg, tst_data)
Esempio n. 17
0
 def _test_basic_handling(self, func):
     # it should throw a DPNMessage Error for invalid messages.
     self.assertRaises(DPNMessageError, func, _msg(), {})
     msg = Message(Mock(), "{}", headers=fixtures.make_headers())
     self.assertRaises(DPNMessageError, func, msg, {})