def _rightcuboid(self, variant, labels, name, **kwargs): RECEDING_ANGLE = mmlib_cfg.oblique_projection.RECEDING_AXIS_ANGLE # dimensions are: width, height, depth build_data = {0: {'dimensions': (2.5, 0.5, 1), 'α': 60, 'boundingbox': (-0.2, -0.5, 1.05, 1.05)}, 1: {'dimensions': (0.5, 0.8, 1.3), 'α': 70, 'baseline': '12pt', 'boundingbox': (-0.2, -0.5, 1, 1.2)}, 2: {'dimensions': (0.5, 0.6, 1.4), 'α': 60, 'baseline': '11pt', 'boundingbox': (-0.2, -0.6, 1, 1.2)}, 3: {'dimensions': (2, 1, 0.5), 'baseline': '13pt', 'boundingbox': (-0.2, -0.5, 1, 1.35)}, 4: {'dimensions': (0.75, 1.25, 0.5), 'baseline': '16pt', 'boundingbox': (-0.2, -0.5, 1, 1.65)}, 5: {'dimensions': (1, 0.5, 1.25), 'α': 70, 'baseline': '8pt', 'boundingbox': (-0.2, -0.5, 1, 0.9)} }[variant] rc = RightCuboid(dimensions=build_data['dimensions'], name=name, thickness=kwargs.get('thickness', 'thick')) rc.setup_labels(labels) label_vertices = kwargs.get('label_vertices', False) direction = kwargs.get('direction', 'top-right') op = ObliqueProjection(rc, direction=direction, α=build_data.get('α', RECEDING_ANGLE), label_vertices=label_vertices) op.baseline = build_data.get('baseline', '10pt') op.boundingbox = build_data.pop('boundingbox', None) return rc, op
def test_draw_vertices_error(rc): op = ObliqueProjection(rc) with pytest.raises(TypeError) as excinfo: op.draw_vertices = 'true' assert str(excinfo.value) == 'draw_vertices must be a boolean; '\ 'found <class \'str\'> instead.'
def test_topright_projection(rc): """Check the default projection of a right cuboid is correct.""" assert ObliqueProjection(rc, label_vertices=True).drawn == r"""
def test_instanciation_object3D_error(rc): """Check errors when instanciating a new ObliqueProjection.""" with pytest.raises(TypeError) as excinfo: ObliqueProjection('a') assert str(excinfo.value) == 'object3D must be a Polyhedron, found '\ '\'a\' instead.'
def test_instanciation_direction_error(rc): with pytest.raises(ValueError) as excinfo: ObliqueProjection(rc, direction='undefined') assert str(excinfo.value) == 'Allowed values for direction argument are '\ '{}. Found \'undefined\' instead.'.format(config.DIRECTION_VALUES)
def test_instanciation_angle_error(rc): """Check errors when instanciating a new ObliqueProjection.""" with pytest.raises(TypeError) as excinfo: ObliqueProjection(α='a') assert str(excinfo.value) == 'Angle α must be a number. Found '\ '\'a\' instead.'
def test_draw_thick_and_blue(rc): """Check the default projection of a right cuboid is correct.""" assert ObliqueProjection(rc, color='RoyalBlue', thickness='very thick').drawn == r"""
def test_bottomright_edges_labeling(rc): """Check edges' labeling for a bottom-right projection.""" rc.setup_labels((4, 7, 25)) assert ObliqueProjection(rc, direction='bottom-right').drawn == r"""
def test_topleft_edges_labeling(rc): """Check edges' labeling for a top-left projection.""" rc.setup_labels((4, 7, 25)) assert ObliqueProjection(rc, direction='top-left').drawn == r"""
def test_topright_edges_labeling(rc): """Check edges' labeling for a top-right projection.""" rc.setup_labels((4, 7, 25)) assert ObliqueProjection(rc).drawn == r"""
def test_bottomright_projection(rc): """Check bottom-right projection of a right cuboid is correct.""" assert ObliqueProjection(rc, label_vertices=True, direction='bottom-right').drawn == r"""
def test_topleft_projection(rc): """Check top-left projection of a right cuboid is correct.""" assert ObliqueProjection(rc, label_vertices=True, direction='top-left').drawn == r"""