def test_all_shapes():
    layout = load_layout_file('test_all_shapes.kle')
    case = KeyboardCase(layout, ['dxf'])
    case.create_switch_layer('switch')
    case.export('switch', 'test_exports')

    # Basic checks
    assert case.name == '4ac3f3a2dc4d5b2225bf03f0f83f047960846a30'
    assert case.formats == ['dxf']
    assert case.kerf == 0
    assert case.layers == {'switch': {}}
    assert case.width == 247.65
    assert case.height == 95.25
    assert case.inside_width == 247.65
    assert case.inside_height == 95.25

    # Make sure the DXF matches the reference DXF
    assert filecmp.cmp('test_exports/switch_%s.dxf' % case.name, 'test_exports/switch_%s.dxf.knowngood' % case.name) == True

    return True
Example #2
0
def test_numpad():
    layout = load_layout_file('test_numpad.kle')
    layout[0]['name'] = 'test_numpad'
    case = KeyboardCase(layout, ['dxf'])
    case.create_switch_layer('switch')
    case.export('switch', 'test_exports')

    # Basic checks
    assert case.name == 'test_numpad'
    assert case.formats == ['dxf']
    assert case.kerf == 0
    assert case.layers == {'switch': {}}
    assert case.width == 76.2
    assert case.height == 95.25
    assert case.inside_width == 76.2
    assert case.inside_height == 95.25

    # Make sure the DXF matches the reference DXF
    assert filecmp.cmp('test_exports/switch_%s.dxf' % case.name, 'test_exports/switch_%s.dxf.knowngood' % case.name) == True

    return True
def test_all_features_poker():
    layout = load_layout_file('test_all_features_poker.kle')
    case = KeyboardCase(layout, ['dxf'])

    case.create_switch_layer('reinforcing')
    case.export('reinforcing', 'test_exports')

    case.create_switch_layer('switch')
    case.export('switch', 'test_exports')

    assert case.name == 'test_all_features_poker'
    assert case.formats == ['dxf']
    assert case.kerf == 0.1
    assert case.width == 247.65
    assert case.height == 95.25
    #assert case.inside_width == 247.45 # FIXME: Why doesn't this work?
    assert case.inside_height == 95.05

    for layer in ('reinforcing', 'switch'):
        assert layer in case.layers
        assert filecmp.cmp('test_exports/switch_%s.dxf' % case.name, 'test_exports/switch_%s.dxf.knowngood' % case.name) == True

    return True
Example #4
0
def test_all_shapes():
    layout = load_layout_file('test_all_shapes.kle')
    layout[0]['corner_type'] = 'bevel'
    layout[0]['corner_radius'] = 4
    layout[0]['name'] = 'test_bevel'
    case = KeyboardCase(layout, ['dxf'])
    case.create_switch_layer('switch')
    case.export('switch', 'test_exports')

    # Basic checks
    assert case.name == 'test_bevel'
    assert case.formats == ['dxf']
    assert case.kerf == 0
    assert case.layers == {'switch': {}}
    assert case.width == 247.65
    assert case.height == 95.25
    assert case.inside_width == 247.65
    assert case.inside_height == 95.25

    # Make sure the DXF matches the reference DXF
    assert filecmp.cmp('test_exports/switch_%s.dxf' % case.name, 'test_exports/switch_%s.dxf.knowngood' % case.name) == True

    return True
def test_all_features_sandwich():
    layout = load_layout_file("test_all_features_sandwich.kle")
    case = KeyboardCase(layout, ["dxf"])

    case.create_bottom_layer("bottom")
    case.export("bottom", "test_exports")

    case.create_middle_layer("closed")
    case.export("closed", "test_exports")

    case.create_middle_layer("open")
    case.export("open", "test_exports")

    case.create_switch_layer("reinforcing")
    case.export("reinforcing", "test_exports")

    case.create_switch_layer("switch")
    case.export("switch", "test_exports")

    case.create_switch_layer("top")
    case.export("top", "test_exports")

    assert case.name == "test_all_features_sandwich"
    assert case.formats == ["dxf"]
    assert case.kerf == 0.1
    assert case.width == 259.65
    assert case.height == 107.25
    assert case.inside_width == 251.45
    assert case.inside_height == 99.05

    for layer in ("bottom", "closed", "open", "reinforcing", "switch", "top"):
        assert layer in case.layers
        assert (
            filecmp.cmp("test_exports/switch_%s.dxf" % case.name, "test_exports/switch_%s.dxf.knowngood" % case.name)
            == True
        )

    return True