def test_read_thumbnail_top_level_relationships(): with OCMFile(TEST_PACKAGE) as package: relationships = package.read_relationships( '/', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail' ) assert len(relationships) == 1 assert relationships[ 0].Type == 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail' assert relationships[0].Target == '/Metadata/thumbnail.png'
def test_read_gcode_top_level_relationships(): with OCMFile(TEST_PACKAGE) as package: relationships = package.read_relationships( '/', 'http://schemas.oneclickmetal.com/package/2020/relationships/mprint/gcode' ) assert len(relationships) == 1 assert relationships[ 0].Type == 'http://schemas.oneclickmetal.com/package/2020/relationships/mprint/gcode' assert relationships[0].Target == '/3D/model.gcode'
def test_read_description(): with OCMFile(TEST_PACKAGE) as package: assert package.job_description.creation_date == '2009-01-01T12:00:00+01:00' assert package.job_description.slicer_id == 'mprep-v0.0.1+4b3e5bf' assert package.job_description.job_id == '9a14926b-9783-482f-ac2a-31d8e3901833' assert package.job_description.estimated_print_time_seconds == 239232 assert package.job_description.powder_consumption == 4628 assert package.job_description.layer_count == 2314 parts = package.job_description.parts assert len(parts) == 3 assert any([ part.id == '3' and part.name == 'Part 3' and part.bounding_box is not None and part.bounding_box.x1 == 12.2 for part in parts ])
def test_read_parameters(): with OCMFile(TEST_PACKAGE) as package: assert package.job_parameters.material == 1 assert almost_equal(package.job_parameters.layer_height, 0.02) assert almost_equal(package.job_parameters.oxygen_level_target, 0.3) assert almost_equal(package.job_parameters.gas_circulation_speed, 1.5)
def test_read_gcode(): with OCMFile(TEST_PACKAGE) as package: gcode = package.read_part(package.gcode_part) assert gcode == b'G0 X0 Y0'
def test_read_all_top_level_relationships(): with OCMFile(TEST_PACKAGE) as package: relationships = package.read_relationships('/') assert len(relationships) == 2
def test_read_non_existing_part_relationships(): with OCMFile(TEST_PACKAGE) as package: with pytest.raises(PartNotFoundException): relationships = package.read_relationships('/3D/doesnt.exist')
def test_read_existing_part_without_relationships(): with OCMFile(TEST_PACKAGE) as package: relationships = package.read_relationships('/Metadata/thumbnail.png') assert relationships == []
def test_read_existing_part_relationships(): with OCMFile(TEST_PACKAGE) as package: relationships = package.read_relationships('/3D/model.gcode') assert len(relationships) == 3