Пример #1
0
def test_export_height_mismatch(tmpdir):
    p = utils.create_project(tmpdir, 'p', 2, 2)
    with open(p.layout_path, 'w') as f:
        Layout.create_new(f, 2, 1)

    with pytest.raises(ValueError):
        export_layout(p)
Пример #2
0
def test_layout():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 1, 3)
    layout.set_value(0, 0, 'RED')
    sut = create_sut(layout, 9)

    assert sut.layout.get_value(0, 0) == 'RED'
Пример #3
0
def test_set_value():
    f = create_pseudo_file('')
    sut = Layout.create_new(f, 1, 2)

    sut.set_value(0, 1, 'BLU')

    assert sut.get_value(0, 1) == 'BLU'
    verify_result(sut, f, 1, 2, [[None], ['BLU']])
Пример #4
0
def test_clear_value():
    f = create_pseudo_file('')
    sut = Layout.create_new(f, 1, 2)

    sut.set_value(0, 1, 'BLU')
    sut.clear_value(0, 1)

    assert sut.get_value(0, 1) is None
    verify_result(sut, f, 1, 2, [[None], [None]])
Пример #5
0
def test_create_new():
    f = create_pseudo_file('')
    sut = Layout.create_new(f, 3, 2)

    assert sut.width == 3
    assert sut.height == 2
    assert sut.values == [[None, None, None], [None, None, None]]

    verify_result(sut, f, 3, 2, [[None, None, None], [None, None, None]])
Пример #6
0
def test_try_set_edge():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 2, 3)
    sut = create_sut(layout, 9)

    sut.try_set(9, 0, 'RED')
    sut.try_set(0, 9, 'RED')

    assert len(sut.circles) == 0
Пример #7
0
def test_try_clear_valid():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 1, 3)
    layout.set_value(0, 0, 'RED')
    sut = create_sut(layout, 9)

    sut.try_clear(0, 0)

    assert len(sut.circles) == 0
Пример #8
0
def test_export_valid(tmpdir):
    baseline_path = utils.get_baseline_path('export_valid.png')
    p = utils.create_project(tmpdir, 'p', 2, 2)
    with open(p.layout_path, 'w') as f:
        layout = Layout.create_new(f, 2, 2)
        layout.set_value(0, 0, 'BLK')
        layout.set_value(1, 0, 'WHT')
        layout.set_value(0, 1, 'BLK')

    export_layout(p)

    assert filecmp.cmp(baseline_path, p.final_path) is True
Пример #9
0
def test_try_set_valid():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 1, 3)
    sut = create_sut(layout, 9)

    sut.try_set(0, 0, 'RED')

    assert len(sut.circles) == 1

    c1 = sut.circles[0]
    assert c1.fill_color == '#222222'
    assert c1.edge_color == '#333333'
Пример #10
0
def test_lines():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 2, 3)
    sut = create_sut(layout, 5)

    print()
    for line in sut.lines:
        print(f'({line.point1}) -> {line.point2}')

    assert len(sut.lines) == 3

    line1 = sut.lines[0]
    assert line1.point1 == (5, 0)
    assert line1.point2 == (5, 17)

    line2 = sut.lines[1]
    assert line2.point1 == (0, 5)
    assert line2.point2 == (11, 5)

    line3 = sut.lines[2]
    assert line3.point1 == (0, 11)
    assert line3.point2 == (11, 11)
Пример #11
0
def test_circles():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 1, 3)
    layout.set_value(0, 0, 'RED')
    layout.set_value(0, 2, 'BLU')
    sut = create_sut(layout, 9)

    assert len(sut.circles) == 2

    c1 = sut.circles[0]
    assert c1.topleft == (1, 1)
    assert c1.bottomright == (7, 7)
    assert c1.diameter == 6
    assert c1.fill_color == '#222222'
    assert c1.edge_color == '#333333'

    c2 = sut.circles[1]
    assert c2.topleft == (1, 21)
    assert c2.bottomright == (7, 27)
    assert c2.diameter == 6
    assert c2.fill_color == '#555555'
    assert c2.edge_color == '#666666'
Пример #12
0
def test_width():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 2, 3)
    sut = create_sut(layout, 5)

    assert sut.width == 11
Пример #13
0
def test_height():
    f = create_pseudo_file('')
    layout = Layout.create_new(f, 2, 3)
    sut = create_sut(layout, 5)

    assert sut.height == 17