Ejemplo n.º 1
0
def test_build_log():
    try:
        user = User.get_user_by_username("rbuser")
    except UserNotFoundException:
        user = User("rbuser", "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_log([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]["end_time"] == job1.get_end_time().isoformat()
    assert answer[0]["creator"] == job1.get_user().get_username()
    assert answer[0]["status"] == job1.get_status().name
    assert answer[0]["error"] == job1.get_error()

    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]["end_time"] == job2.get_end_time().isoformat()
    assert answer[1]["creator"] == job2.get_user().get_username()
    assert answer[1]["status"] == job2.get_status().name
    assert answer[1]["error"] == job2.get_error()
Ejemplo n.º 2
0
def test_getters():
    job = Job('storageA', 'storageB', '~/.data/', [True, True, True], user)
    another_job = Job.get_job_by_id(job.get_job_id())
    assert another_job.get_job_id() == job.get_job_id()
    assert another_job.get_source_alias() == job.get_source_alias()
    assert another_job.get_target_alias() == job.get_target_alias()
    assert another_job.get_source_relative_path(
    ) == job.get_source_relative_path()
    assert another_job.get_start_time() == job.get_start_time()
    assert another_job.get_end_time() == job.get_end_time()
    assert another_job.get_enqueue_time() == job.get_enqueue_time()
    assert another_job.get_status() == job.get_status()
    assert another_job.has_start_notification() == job.has_start_notification()
    assert another_job.has_end_notification() == job.has_end_notification()
    assert another_job.has_error_notification() == job.has_error_notification()
    assert another_job.get_user().get_username() == job.get_user(
    ).get_username()
Ejemplo n.º 3
0
def test_build_job():
    try:
        user = User.get_user_by_username("rbuser")
    except UserNotFoundException:
        user = User("rbuser", "token")
    job = Job('storageA', 'storageB', '~/.data/', [True, True, True], user)
    job.set_status(JobStatus.QUEUED)
    timestamp = datetime.datetime.now()
    job.set_enqueue_time(timestamp)

    answer = json.loads(rb.build_job(job))
    assert answer["job_id"] == job.get_job_id()
    assert answer["source"] == job.get_source_alias(
    ) + ":" + job.get_source_relative_path()
    assert answer["target"] == job.get_target_alias()
    assert answer["enqueue_time"] == job.get_enqueue_time().isoformat()
    assert answer["creator"] == job.get_user().get_username()
    assert answer["status"] == job.get_status().name
    return