예제 #1
0
def test_equality():
    """Test the equality of legend parameters."""
    leg_par = LegendParameters(0, 1000)
    leg_par_dup = leg_par.duplicate()

    assert leg_par is not leg_par_dup
    assert leg_par == leg_par_dup
    leg_par_dup.segment_count = 3
    assert leg_par != leg_par_dup
예제 #2
0
def test_continuous_legend():
    """Test the LegendParameter continuous_legend property."""
    leg_par = LegendParameters()
    leg_par.continuous_legend = True

    assert leg_par.continuous_legend is True
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.continuous_legend is True

    leg_par.continuous_legend = False
    assert leg_par.continuous_legend is False

    with pytest.raises(Exception):
        leg_par = LegendParameters(continuous_legend='yes')
    with pytest.raises(Exception):
        leg_par.continuous_legend = 'yes'
예제 #3
0
def test_font():
    """Test the LegendParameter font property."""
    leg_par = LegendParameters()
    leg_par.font = 'Times'

    assert leg_par.font == 'Times'
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.font == 'Times'

    leg_par.font = 'Courier'
    assert leg_par.font == 'Courier'

    with pytest.raises(Exception):
        leg_par = LegendParameters(font=0)
    with pytest.raises(Exception):
        leg_par.font = 0
예제 #4
0
def test_decimal_count():
    """Test the LegendParameter decimal_count property."""
    leg_par = LegendParameters()
    leg_par.decimal_count = 3

    assert leg_par.decimal_count == 3
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.decimal_count == 3

    leg_par.decimal_count = 0
    assert leg_par.decimal_count == 0

    with pytest.raises(Exception):
        leg_par = LegendParameters(decimal_count='2')
    with pytest.raises(Exception):
        leg_par.decimal_count = '2'
예제 #5
0
def test_ordinal_dictionary():
    """Test the LegendParameter ordinal_dictionary property."""
    leg_par = LegendParameters(min=0, max=1)
    leg_par.ordinal_dictionary = {0: 'False', 1: 'True'}

    assert leg_par.ordinal_dictionary == {0: 'False', 1: 'True'}
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.ordinal_dictionary == {0: 'False', 1: 'True'}

    leg_par.ordinal_dictionary = {0: 'No', 1: 'Yes'}
    assert leg_par.ordinal_dictionary == {0: 'No', 1: 'Yes'}

    with pytest.raises(Exception):
        leg_par = LegendParameters(ordinal_dictionary=['False', 'True'])
    with pytest.raises(Exception):
        leg_par.ordinal_dictionary = ['False', 'True']
예제 #6
0
def test_title():
    """Test the LegendParameter title property."""
    leg_par = LegendParameters(title='m2')

    assert leg_par.title == 'm2'
    assert leg_par.is_title_default is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.title == 'm2'

    leg_par.title = 'm2'
    assert leg_par.title == 'm2'

    with pytest.raises(Exception):
        leg_par = LegendParameters(title=2)
    with pytest.raises(Exception):
        leg_par.title = 2
예제 #7
0
    def test_vertical(self):
        """Test the LegendParameter continuous_legend property."""
        leg_par = LegendParameters()
        leg_par.vertical = False

        assert leg_par.vertical is False
        leg_par_copy = leg_par.duplicate()
        assert leg_par_copy.vertical is False

        leg_par.vertical = True
        assert leg_par.vertical is True

        with pytest.raises(Exception):
            leg_par = LegendParameters(vertical='yes')
        with pytest.raises(Exception):
            leg_par.vertical = 'yes'
예제 #8
0
def test_continuous_colors():
    """Test the LegendParameter continuous_colors property."""
    leg_par = LegendParameters()
    leg_par.continuous_colors = False

    assert not leg_par.continuous_colors
    leg_par_copy = leg_par.duplicate()
    assert not leg_par_copy.continuous_colors

    leg_par.continuous_colors = True
    assert leg_par.continuous_colors

    with pytest.raises(Exception):
        leg_par = LegendParameters(continuous_colors='yes')
    with pytest.raises(Exception):
        leg_par.continuous_colors = 'yes'
예제 #9
0
def test_text_height():
    """Test the LegendParameter text_height property."""
    leg_par = LegendParameters()
    leg_par.text_height = 0.25

    assert leg_par.text_height == 0.25
    assert leg_par.is_text_height_default is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.text_height == 0.25

    leg_par.text_height = 2
    assert leg_par.text_height == 2

    with pytest.raises(Exception):
        leg_par = LegendParameters(text_height=0)
    with pytest.raises(Exception):
        leg_par.text_height = 0
예제 #10
0
def test_segment_width():
    """Test the LegendParameter segment_width property."""
    leg_par = LegendParameters()
    leg_par.segment_width = 3

    assert leg_par.segment_width == 3
    assert leg_par.is_segment_width_default is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.segment_width == 3

    leg_par.segment_width = 2
    assert leg_par.segment_width == 2

    with pytest.raises(Exception):
        leg_par = LegendParameters(segment_width=0)
    with pytest.raises(Exception):
        leg_par.segment_width = 0
예제 #11
0
def test_base_plane():
    """Test the LegendParameter base_plane property."""
    leg_par = LegendParameters(
        base_plane=Plane(Vector3D(0, 0, 0), Point3D(10, 10, 0)))

    assert leg_par.base_plane.o == Point3D(10, 10, 0)
    assert leg_par.is_base_plane_default is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.base_plane.o == Point3D(10, 10, 0)

    leg_par.base_plane = Plane(Vector3D(0, 0, 0), Point3D(-10, -10, 0))
    assert leg_par.base_plane.o == Point3D(-10, -10, 0)

    with pytest.raises(Exception):
        leg_par = LegendParameters(base_plane=Point3D(-10, -10, 0))
    with pytest.raises(Exception):
        leg_par.base_plane = Point3D(-10, -10, 0)
예제 #12
0
def test_segment_height():
    """Test the LegendParameter segment_height property."""
    leg_par = LegendParameters()
    leg_par.segment_height = 3

    assert leg_par.segment_height == 3
    assert not leg_par.is_segment_height_default
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.segment_height == 3

    leg_par.segment_height = 2
    assert leg_par.segment_height == 2

    with pytest.raises(Exception):
        leg_par = LegendParameters(segment_height=0)
    with pytest.raises(Exception):
        leg_par.segment_height = 0
예제 #13
0
def test_init_legend_parameters():
    """Test the initialization of LegendParameter objects."""
    leg_par = LegendParameters(0, 1000)
    str(leg_par)  # Test the LegendParameters representation

    assert leg_par.min == 0
    assert leg_par.max == 1000
    assert leg_par.is_segment_count_default is True
    assert leg_par.is_title_default is True
    assert leg_par.is_base_plane_default is True
    assert leg_par.is_segment_height_default is True
    assert leg_par.is_segment_width_default is True
    assert leg_par.is_text_height_default is True

    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.min == leg_par.min
    assert leg_par_copy.max == leg_par.max
    assert leg_par_copy.segment_count == leg_par.segment_count
예제 #14
0
def test_colors():
    """Test the LegendParameter colors property."""
    leg_par = LegendParameters(colors=[Color(0, 0, 0), Color(255, 255, 255)])

    assert len(leg_par.colors) == 2
    assert leg_par.colors[0] == Color(0, 0, 0)
    assert leg_par.colors[1] == Color(255, 255, 255)

    leg_par_copy = leg_par.duplicate()
    assert len(leg_par_copy.colors) == 2
    assert leg_par_copy.colors[0] == Color(0, 0, 0)
    assert leg_par_copy.colors[1] == Color(255, 255, 255)

    leg_par.colors = [Color(0, 0, 0), Color(100, 100, 100)]
    assert leg_par.colors[1] == Color(100, 100, 100)

    with pytest.raises(Exception):
        leg_par = LegendParameters(colors=[0, 1])
    with pytest.raises(Exception):
        leg_par.colors = [0, 1]