Example #1
0
def test_build_queue():
    try:
        user = User.get_user_by_username("rbuser2")
    except UserNotFoundException:
        user = User("rbuser2", "token")

    job1 = Job('storageA', 'storageB', '~/.data/', [True, True, True], user)
    job1_id = job1.get_job_id()
    job1.set_status(JobStatus.DONE)
    timestamp = datetime.datetime.now()
    job1.set_enqueue_time(timestamp)
    job1.set_end_time(timestamp)

    job2 = Job('storageA', 'storageB', '~/.data/', [True, True, True], user)
    job2_id = job2.get_job_id()
    job2.set_status(JobStatus.DONE)
    timestamp = datetime.datetime.now()
    job2.set_enqueue_time(timestamp)
    job2.set_end_time(timestamp)

    job1 = Job.get_job_by_id(job1_id)
    job2 = Job.get_job_by_id(job2_id)
    answer = json.loads(rb.build_queue([job1, job2]))

    job1 = Job.get_job_by_id(job1_id)
    assert answer[0]["job_id"] == job1.get_job_id()
    assert answer[0]["source"] == job1.get_source_alias(
    ) + ":" + job1.get_source_relative_path()
    assert answer[0]["target"] == job1.get_target_alias()
    assert answer[0]["enqueue_time"] == job1.get_enqueue_time().isoformat()
    assert answer[0]["creator"] == job1.get_user().get_username()
    assert answer[0]["priority"] == job1.get_priority()
    assert answer[0]["status"] == job1.get_status().name

    job2 = Job.get_job_by_id(job2_id)
    assert answer[1]["job_id"] == job2.get_job_id()
    assert answer[1]["source"] == job2.get_source_alias(
    ) + ":" + job2.get_source_relative_path()
    assert answer[1]["target"] == job2.get_target_alias()
    assert answer[1]["enqueue_time"] == job2.get_enqueue_time().isoformat()
    assert answer[1]["creator"] == job2.get_user().get_username()
    assert answer[1]["priority"] == job2.get_priority()
    assert answer[1]["status"] == job2.get_status().name
Example #2
0
def test_set_priority():
    """
    /SA1010/
    """
    try:
        user = User.get_user_by_username("priorityuser1")
    except UserNotFoundException:
        user = Administrator("priorityuser1", "token")

    job = Job('storageA', 'storageB', '~/.data/', [True, True, True], user)
    job_id = job.get_job_id()
    job.set_status(JobStatus.QUEUED)

    request = {"job_id": job_id, "priority": 3}

    json_string = json.dumps(request)
    app.set_priority(json_string)

    job = Job.get_job_by_id(job_id)
    assert job.get_priority() == 3