Ejemplo n.º 1
0
def test_constructor():
    job = generate_testjob()
    result = Result(job=job,
                    solver_type=SolverType.FFD,
                    time_us=100,
                    lengths=[(100, 100, 100), (200, 200, 200)])
    assert result
Ejemplo n.º 2
0
def test_valid():
    job = generate_testjob()
    result = Result(job=job,
                    solver_type=SolverType.FFD,
                    time_us=100,
                    lengths=[(100, 100, 100), (200, 200, 200)])
    result.assert_valid()
Ejemplo n.º 3
0
def test_iterator():
    job: Job = generate_testjob()

    resulting_list = []
    for length in job.iterate_sizes():
        resulting_list.append(length)

    assert resulting_list == [500, 500, 200, 200, 200, 200]
Ejemplo n.º 4
0
def test_FFD():
    job = generate_testjob()

    orig_job = job.copy(deep=True)
    solved = _solve_FFD(job)

    assert solved == [[500, 500, 200, 200], [200, 200]]
    assert orig_job == job
Ejemplo n.º 5
0
def test_invalid():
    job = generate_testjob()
    invalid_result = Result(job=job,
                            solver_type=SolverType.FFD,
                            time_us=-1,
                            lengths=[(100, 100, 100), (200, 200, 200)])
    with pytest.raises(ValueError):
        invalid_result.assert_valid()
Ejemplo n.º 6
0
def test_equal():
    job = generate_testjob()
    result1 = Result(job=job,
                     solver_type=SolverType.FFD,
                     time_us=100,
                     lengths=[(100, 100, 100), (200, 200, 200)])
    result2 = Result(job=job,
                     solver_type=SolverType.FFD,
                     time_us=200,
                     lengths=[(100, 100, 100), (200, 200, 200)])
    assert result1 == result2
Ejemplo n.º 7
0
def test_exactly():
    job = generate_testjob()
    result1 = Result(job=job,
                     solver_type=SolverType.FFD,
                     time_us=100,
                     lengths=[(100, 100, 100), (200, 200, 200)])
    result2 = Result(job=job,
                     solver_type=SolverType.FFD,
                     time_us=200,
                     lengths=[(100, 100, 100), (200, 200, 200)])
    result3 = Result(job=job,
                     solver_type=SolverType.FFD,
                     time_us=200,
                     lengths=[(100, 100, 100), (200, 200, 200)])
    assert not result1.exactly(result2)
    assert result2.exactly(result3)
Ejemplo n.º 8
0
def test_full():
    reply = client.post("/solve", generate_testjob().json())
    assert reply.status_code == 200
    json_result = reply.json()

    assert Result.parse_obj(json_result) == generate_testresult()
Ejemplo n.º 9
0
def test_too_long():
    job = generate_testjob()
    job.target_sizes[job.max_length + 1] = 4
    with pytest.raises(ValueError):
        job.assert_valid()
Ejemplo n.º 10
0
def test_invalid():
    invalid_job = generate_testjob()
    invalid_job.max_length = -1
    with pytest.raises(ValueError):
        invalid_job.assert_valid()
Ejemplo n.º 11
0
def test_valid():
    job1 = generate_testjob()
    job1.assert_valid()
Ejemplo n.º 12
0
def test_equal_hash():
    job1 = generate_testjob()
    job2 = generate_testjob()

    assert hash(job1) == hash(job2)
Ejemplo n.º 13
0
def test_job_length():
    job1 = generate_testjob()

    assert len(job1) == 6
Ejemplo n.º 14
0
def test_job_equal():
    job1 = generate_testjob()
    job2 = generate_testjob()

    assert job1 == job2