

def test_node_deletion_subtask_progress(self):
    supertask = Task(uuid=str(uuid.uuid4()), name='super', status='running')
    self.db.add(supertask)
    task_deletion = supertask.create_subtask('node_deletion')
    task_provision = supertask.create_subtask('provision', weight=0.4)
    self.db.commit()
    subtask_progress = random.randint(1, 20)
    deletion_kwargs = {
        'task_uuid': task_deletion.uuid,
        'progress': subtask_progress,
        'status': 'running',
    }
    provision_kwargs = {
        'task_uuid': task_provision.uuid,
        'progress': subtask_progress,
        'status': 'running',
    }

    def progress_difference():
        self.receiver.provision_resp(**provision_kwargs)
        self.db.commit()
        self.db.refresh(task_provision)
        self.assertEqual(task_provision.progress, subtask_progress)
        self.db.refresh(supertask)
        progress_before_delete_subtask = supertask.progress
        self.receiver.remove_nodes_resp(**deletion_kwargs)
        self.db.commit()
        self.db.refresh(task_deletion)
        self.assertEqual(task_deletion.progress, subtask_progress)
        self.db.refresh(supertask)
        progress_after_delete_subtask = supertask.progress
        return abs((progress_after_delete_subtask - progress_before_delete_subtask))
    without_coeff = progress_difference()
    task_deletion.progress = 0
    task_deletion.weight = 0.5
    self.db.merge(task_deletion)
    task_provision.progress = 0
    self.db.merge(task_provision)
    supertask.progress = 0
    self.db.merge(supertask)
    self.db.commit()
    with_coeff = progress_difference()
    self.assertTrue(((without_coeff / with_coeff) < 2))

dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/integration/test_rpc_consumer.py TestConsumer.test_node_deletion_subtask_progress/original