def test_from_and_to_dict():
    modifier = Plastic('polygon_material')
    polygon = Polygon('default_polygon', vertices, modifier=modifier)
    polygon_dict = polygon.to_dict()

    # check values in dictionary
    assert polygon_dict['identifier'] == 'default_polygon'
    assert polygon_dict['modifier'] == modifier.to_dict()
    assert polygon_dict['vertices'] == tuple(tuple(pt) for pt in vertices)

    polygon_from_dict = Polygon.from_dict(polygon_dict)

    assert polygon_from_dict.to_radiance() == polygon.to_radiance()
예제 #2
0
def test_from_and_to_dict():
    modifier = Plastic('source_material')
    source = Source('default_source', modifier=modifier)
    source_dict = source.to_dict()

    # check values in dictionary
    assert source_dict['identifier'] == 'default_source'
    assert source_dict['modifier'] == modifier.to_dict()
    assert source_dict['direction'] == (0, 0, -1)
    assert source_dict['angle'] == 0.533

    source_from_dict = Source.from_dict(source_dict)

    assert source_from_dict.to_radiance() == source.to_radiance()
예제 #3
0
def test_from_and_to_dict():
    modifier = Plastic('sphere_material')
    sphere = Sphere('default_sphere', modifier=modifier)
    sphere_dict = sphere.to_dict()

    # check values in dictionary
    assert sphere_dict['identifier'] == 'default_sphere'
    assert sphere_dict['modifier'] == modifier.to_dict()
    assert sphere_dict['center_pt'] == (0, 0, 0)
    assert sphere_dict['radius'] == 10

    sphere_from_dict = Sphere.from_dict(sphere_dict)

    assert sphere_from_dict.to_radiance() == sphere.to_radiance()
예제 #4
0
def test_from_and_to_dict():
    modifier = Plastic('cylinder_material')
    cylinder = Cylinder('default_cylinder', modifier=modifier)
    cylinder_dict = cylinder.to_dict()

    # check values in dictionary
    assert cylinder_dict['identifier'] == 'default_cylinder'
    assert cylinder_dict['modifier'] == modifier.to_dict()
    assert cylinder_dict['center_pt_start'] == (0, 0, 0)
    assert cylinder_dict['center_pt_end'] == (0, 0, 10)
    assert cylinder_dict['radius'] == 10

    cylinder_from_dict = Cylinder.from_dict(cylinder_dict)

    assert cylinder_from_dict.to_radiance() == cylinder.to_radiance()
예제 #5
0
def test_from_and_to_dict():
    modifier = Plastic('cone_material')
    cone = Cone('default_cone', modifier=modifier)
    cone_dict = cone.to_dict()

    # check values in dictionary
    assert cone_dict['identifier'] == 'default_cone'
    assert cone_dict['modifier'] == modifier.to_dict()
    assert cone_dict['center_pt_start'] == (0, 0, 0)
    assert cone_dict['center_pt_end'] == (0, 0, 10)
    assert cone_dict['radius_start'] == 10
    assert cone_dict['radius_end'] == 0

    cone_from_dict = Cone.from_dict(cone_dict)

    assert cone_from_dict.to_radiance() == cone.to_radiance()
예제 #6
0
def test_from_and_to_dict():
    modifier = Plastic('ring_material')
    ring = Ring('default_ring', modifier=modifier)
    ring_dict = ring.to_dict()

    # check values in dictionary
    assert ring_dict['identifier'] == 'default_ring'
    assert ring_dict['modifier'] == modifier.to_dict()
    assert ring_dict['center_pt'] == (0, 0, 0)
    assert ring_dict['normal_vector'] == (0, 0, 1)
    assert ring_dict['radius_inner'] == 5
    assert ring_dict['radius_outer'] == 10

    ring_from_dict = Ring.from_dict(ring_dict)

    assert ring_from_dict.to_radiance() == ring.to_radiance()