summaryrefslogtreecommitdiff
path: root/gerber/tests/test_am_statements.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-02 20:03:26 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-02 20:03:26 -0500
commitf98b918634f23cf822b0d054ac4b6a0b790bb760 (patch)
tree3b5d4e7f1c8f174a2a3d6d0cd707d1b41cd77e63 /gerber/tests/test_am_statements.py
parent1cc20b351c10b1fa19817f29edd8c54a27aeee4b (diff)
downloadgerbonara-f98b918634f23cf822b0d054ac4b6a0b790bb760.tar.gz
gerbonara-f98b918634f23cf822b0d054ac4b6a0b790bb760.tar.bz2
gerbonara-f98b918634f23cf822b0d054ac4b6a0b790bb760.zip
Added some Aperture Macro Primitives. Moved AM primitives to seperate file
Diffstat (limited to 'gerber/tests/test_am_statements.py')
-rw-r--r--gerber/tests/test_am_statements.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/gerber/tests/test_am_statements.py b/gerber/tests/test_am_statements.py
new file mode 100644
index 0000000..2ba7733
--- /dev/null
+++ b/gerber/tests/test_am_statements.py
@@ -0,0 +1,77 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+
+from .tests import *
+from ..am_statements import *
+
+def test_AMPrimitive_ctor():
+ for exposure in ('on', 'off', 'ON', 'OFF'):
+ for code in (0, 1, 2, 4, 5, 6, 7, 20, 21, 22):
+ p = AMPrimitive(code, exposure)
+ assert_equal(p.code, code)
+ assert_equal(p.exposure, exposure.lower())
+
+
+def test_AMPrimitive_validation():
+ assert_raises(TypeError, AMPrimitive, '1', 'off')
+ assert_raises(ValueError, AMPrimitive, 0, 'exposed')
+ assert_raises(ValueError, AMPrimitive, 3, 'off')
+
+
+def test_AMCommentPrimitive_ctor():
+ c = AMCommentPrimitive(0, ' This is a comment *')
+ assert_equal(c.code, 0)
+ assert_equal(c.comment, 'This is a comment')
+
+
+def test_AMCommentPrimitive_validation():
+ assert_raises(ValueError, AMCommentPrimitive, 1, 'This is a comment')
+
+
+def test_AMCommentPrimitive_factory():
+ c = AMCommentPrimitive.from_gerber('0 Rectangle with rounded corners. *')
+ assert_equal(c.code, 0)
+ assert_equal(c.comment, 'Rectangle with rounded corners.')
+
+
+def test_AMCommentPrimitive_dump():
+ c = AMCommentPrimitive(0, 'Rectangle with rounded corners.')
+ assert_equal(c.to_gerber(), '0 Rectangle with rounded corners. *')
+
+
+def test_AMCirclePrimitive_ctor():
+ test_cases = ((1, 'on', 0, (0, 0)),
+ (1, 'off', 1, (0, 1)),
+ (1, 'on', 2.5, (0, 2)),
+ (1, 'off', 5.0, (3, 3)))
+ for code, exposure, diameter, position in test_cases:
+ c = AMCirclePrimitive(code, exposure, diameter, position)
+ assert_equal(c.code, code)
+ assert_equal(c.exposure, exposure)
+ assert_equal(c.diameter, diameter)
+ assert_equal(c.position, position)
+
+
+def test_AMCirclePrimitive_validation():
+ assert_raises(ValueError, AMCirclePrimitive, 2, 'on', 0, (0, 0))
+
+
+def test_AMCirclePrimitive_factory():
+ c = AMCirclePrimitive.from_gerber('1,0,5,0,0*')
+ assert_equal(c.code, 1)
+ assert_equal(c.exposure, 'off')
+ assert_equal(c.diameter, 5)
+ assert_equal(c.position, (0,0))
+
+
+def test_AMCirclePrimitive_dump():
+ c = AMCirclePrimitive(1, 'off', 5, (0, 0))
+ assert_equal(c.to_gerber(), '1,0,5,0,0*')
+ c = AMCirclePrimitive(1, 'on', 5, (0, 0))
+ assert_equal(c.to_gerber(), '1,1,5,0,0*')
+
+
+
+ \ No newline at end of file