summaryrefslogtreecommitdiff
path: root/gerber/tests/test_layers.py
diff options
context:
space:
mode:
authorGarret Fick <garret@fickworkshop.com>2016-11-11 15:54:42 +0800
committerGitHub <noreply@github.com>2016-11-11 15:54:42 +0800
commit1e868763a1c4030bedd51553468cbe25f272bef9 (patch)
tree59cef68f1449a5be8d2a9a8ed352e3d9974a3edb /gerber/tests/test_layers.py
parent5af19af190c1fb0f0c5be029d46d63e657dde4d9 (diff)
parent60d08dc8ad72f5bb0a14d4821451d7dce20b9639 (diff)
downloadgerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.tar.gz
gerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.tar.bz2
gerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.zip
Merge pull request #5 from hamiltonkibbe/merge-curtacircuitos
Merge curtacircuitos
Diffstat (limited to 'gerber/tests/test_layers.py')
-rw-r--r--gerber/tests/test_layers.py75
1 files changed, 72 insertions, 3 deletions
diff --git a/gerber/tests/test_layers.py b/gerber/tests/test_layers.py
index 3f2bcfc..7e36dc2 100644
--- a/gerber/tests/test_layers.py
+++ b/gerber/tests/test_layers.py
@@ -1,11 +1,33 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+# copyright 2016 Hamilton Kibbe <ham@hamiltonkib.be>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import os
from .tests import *
-from ..layers import guess_layer_class, hints
+from ..layers import *
+from ..common import read
+NCDRILL_FILE = os.path.join(os.path.dirname(__file__),
+ 'resources/ncdrill.DRD')
+NETLIST_FILE = os.path.join(os.path.dirname(__file__),
+ 'resources/ipc-d-356.ipc')
+COPPER_FILE = os.path.join(os.path.dirname(__file__),
+ 'resources/top_copper.GTL')
def test_guess_layer_class():
""" Test layer type inferred correctly from filename
@@ -30,4 +52,51 @@ def test_guess_layer_class():
def test_sort_layers():
""" Test layer ordering
"""
- pass
+ layers = [
+ PCBLayer(layer_class='drawing'),
+ PCBLayer(layer_class='drill'),
+ PCBLayer(layer_class='bottompaste'),
+ PCBLayer(layer_class='bottomsilk'),
+ PCBLayer(layer_class='bottommask'),
+ PCBLayer(layer_class='bottom'),
+ PCBLayer(layer_class='internal'),
+ PCBLayer(layer_class='top'),
+ PCBLayer(layer_class='topmask'),
+ PCBLayer(layer_class='topsilk'),
+ PCBLayer(layer_class='toppaste'),
+ PCBLayer(layer_class='outline'),
+ ]
+
+ layer_order = ['outline', 'toppaste', 'topsilk', 'topmask', 'top',
+ 'internal', 'bottom', 'bottommask', 'bottomsilk',
+ 'bottompaste', 'drill', 'drawing']
+ bottom_order = list(reversed(layer_order[:10])) + layer_order[10:]
+ assert_equal([l.layer_class for l in sort_layers(layers)], layer_order)
+ assert_equal([l.layer_class for l in sort_layers(layers, from_top=False)],
+ bottom_order)
+
+
+def test_PCBLayer_from_file():
+ layer = PCBLayer.from_cam(read(COPPER_FILE))
+ assert_true(isinstance(layer, PCBLayer))
+ layer = PCBLayer.from_cam(read(NCDRILL_FILE))
+ assert_true(isinstance(layer, DrillLayer))
+ layer = PCBLayer.from_cam(read(NETLIST_FILE))
+ assert_true(isinstance(layer, PCBLayer))
+ assert_equal(layer.layer_class, 'ipc_netlist')
+
+
+def test_PCBLayer_bounds():
+ source = read(COPPER_FILE)
+ layer = PCBLayer.from_cam(source)
+ assert_equal(source.bounds, layer.bounds)
+
+
+def test_DrillLayer_from_cam():
+ no_exceptions = True
+ try:
+ layer = DrillLayer.from_cam(read(NCDRILL_FILE))
+ assert_true(isinstance(layer, DrillLayer))
+ except:
+ no_exceptions = False
+ assert_true(no_exceptions)