def test_bad_action(self):
     """Item id 0 should always fail."""
     oid = 0
     action = outbound.initiate_ingest(oid, 342342342)
     self.failIfEqual(action.correlation_id, oid)
     self.failUnlessEqual(action.object_id, oid)
     self.failUnlessEqual(action.state, FAILED)
Beispiel #2
0
 def handle(self, *args, **options):
     while True:
         try:
             action = initiate_ingest(uuid4(),
                                      30441123)  # Faking these numbers obviously.
             print("Initiate Ingest Action for %s: %s" % (
             action.correlation_id, action.get_state_display()))
             if action.note:
                 print("   >>Note: %s" % action.note)
             print("Waiting for %s seconds." % options['repeat'])
             time.sleep(int(options[
                 'repeat']))  # Adding a delay so I can follow messages manually.
         except KeyboardInterrupt:
             break
     print("Stopping Heartbeat")
 def test_good_action(self):
     """Tests the successful request."""
     oid = uuid4()
     correlation_id = outbound.initiate_ingest(oid, 5023432)
     
     try:
         action = IngestAction.objects.get(correlation_id=correlation_id)
     except Exception as e:
         self.fail("initiate_ingest did not created a valid ingest action")    
         
     self.assertTrue(
         correlation_id, 
         "initiate_ingest did not return a correlation_id for a valid uuid"
     )
     
     self.assertEqual(
         correlation_id, 
         action.correlation_id, 
         "Correlation_id for created action did not matched returned id"
     )