def test_cleanup_abandoned_uploadjobs(self):
        """Test the cleanup_uploadjobs method."""
        right_now = now()
        crc = 12345
        size = 100
        def_size = 100
        for uid in range(0, 10):
            suser = self.factory.make_user(
                username='testuser_%d' % uid, max_storage_bytes=1024)
            user = self.gw.get_user(suser.id)
            vgw = user._gateway.get_root_gateway()
            root = vgw.get_root()
            new_hash = self.factory.get_fake_hash(os.urandom(100))
            file1 = vgw.make_file(root.id, 'file1-%d' % uid)
            up1 = vgw.make_uploadjob(file1.id, file1.content_hash, new_hash,
                                     crc, size, def_size,
                                     multipart_key=uuid.uuid4())
            # change the when_started date for the test.
            uploadjob = UploadJob.objects.get(id=up1.id)
            uploadjob.when_last_active = right_now - timedelta(10)
            uploadjob.save()
        # check that filtering by date works as expected.
        date = right_now - timedelta(9)
        jobs = self.gw.get_abandoned_uploadjobs(date)
        self.assertEqual(len(jobs), 10)
        self.gw.cleanup_uploadjobs(jobs)
        jobs = self.gw.get_abandoned_uploadjobs(date)
        self.assertEqual(len(jobs), 0)