summaryrefslogtreecommitdiff
path: root/gerber/tests
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2014-09-30 23:42:02 -0400
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2014-09-30 23:42:02 -0400
commitf8449ad2b60b8a715d0867325e257a8297193b49 (patch)
treec7cf4bed6de5c6200f9aaf937167ee71d1c9ce58 /gerber/tests
parent88fb7f23110d2270c5c7f8a7b90cae32295da78e (diff)
downloadgerbonara-f8449ad2b60b8a715d0867325e257a8297193b49.tar.gz
gerbonara-f8449ad2b60b8a715d0867325e257a8297193b49.tar.bz2
gerbonara-f8449ad2b60b8a715d0867325e257a8297193b49.zip
tests update
Diffstat (limited to 'gerber/tests')
-rw-r--r--gerber/tests/test_cnc.py50
-rw-r--r--gerber/tests/test_statements.py87
-rw-r--r--gerber/tests/tests.py18
3 files changed, 155 insertions, 0 deletions
diff --git a/gerber/tests/test_cnc.py b/gerber/tests/test_cnc.py
new file mode 100644
index 0000000..ace047e
--- /dev/null
+++ b/gerber/tests/test_cnc.py
@@ -0,0 +1,50 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+
+from ..cnc import CncFile, FileSettings
+from tests import *
+
+
+def test_smoke_filesettings():
+ """ Smoke test FileSettings class
+ """
+ fs = FileSettings()
+
+
+def test_filesettings_defaults():
+ """ Test FileSettings default values
+ """
+ fs = FileSettings()
+ assert_equal(fs.format, (2, 5))
+ assert_equal(fs.notation, 'absolute')
+ assert_equal(fs.zero_suppression, 'trailing')
+ assert_equal(fs.units, 'inch')
+
+
+def test_filesettings_dict():
+ """ Test FileSettings Dict
+ """
+ fs = FileSettings()
+ assert_equal(fs['format'], (2, 5))
+ assert_equal(fs['notation'], 'absolute')
+ assert_equal(fs['zero_suppression'], 'trailing')
+ assert_equal(fs['units'], 'inch')
+
+
+def test_filesettings_assign():
+ """ Test FileSettings attribute assignment
+ """
+ fs = FileSettings()
+ fs.units = 'test'
+ fs.notation = 'test'
+ fs.zero_suppression = 'test'
+ fs.format = 'test'
+ assert_equal(fs.units, 'test')
+ assert_equal(fs.notation, 'test')
+ assert_equal(fs.zero_suppression, 'test')
+ assert_equal(fs.format, 'test')
+
+ def test_smoke_cncfile():
+ pass
diff --git a/gerber/tests/test_statements.py b/gerber/tests/test_statements.py
new file mode 100644
index 0000000..47fbb48
--- /dev/null
+++ b/gerber/tests/test_statements.py
@@ -0,0 +1,87 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+
+from .tests import *
+from ..statements import *
+
+
+def test_FSParamStmt_factory():
+ """ Test FSParamStruct factory correctly handles parameters
+ """
+ stmt = {'param': 'FS', 'zero': 'L', 'notation': 'A', 'x': '27'}
+ fs = FSParamStmt.from_dict(stmt)
+ assert_equal(fs.param, 'FS')
+ assert_equal(fs.zero_suppression, 'leading')
+ assert_equal(fs.notation, 'absolute')
+ assert_equal(fs.format, (2, 7))
+
+ stmt = {'param': 'FS', 'zero': 'T', 'notation': 'I', 'x': '27'}
+ fs = FSParamStmt.from_dict(stmt)
+ assert_equal(fs.param, 'FS')
+ assert_equal(fs.zero_suppression, 'trailing')
+ assert_equal(fs.notation, 'incremental')
+ assert_equal(fs.format, (2, 7))
+
+
+def test_FSParamStmt_dump():
+ """ Test FSParamStmt to_gerber()
+ """
+ stmt = {'param': 'FS', 'zero': 'L', 'notation': 'A', 'x': '27'}
+ fs = FSParamStmt.from_dict(stmt)
+ assert_equal(fs.to_gerber(), '%FSLAX27Y27*%')
+
+ stmt = {'param': 'FS', 'zero': 'T', 'notation': 'I', 'x': '25'}
+ fs = FSParamStmt.from_dict(stmt)
+ assert_equal(fs.to_gerber(), '%FSTIX25Y25*%')
+
+
+def test_MOParamStmt_factory():
+ """ Test MOParamStruct factory correctly handles parameters
+ """
+ stmt = {'param': 'MO', 'mo': 'IN'}
+ mo = MOParamStmt.from_dict(stmt)
+ assert_equal(mo.param, 'MO')
+ assert_equal(mo.mode, 'inch')
+
+ stmt = {'param': 'MO', 'mo': 'MM'}
+ mo = MOParamStmt.from_dict(stmt)
+ assert_equal(mo.param, 'MO')
+ assert_equal(mo.mode, 'metric')
+
+
+def test_MOParamStmt_dump():
+ """ Test MOParamStmt to_gerber()
+ """
+ stmt = {'param': 'MO', 'mo': 'IN'}
+ mo = MOParamStmt.from_dict(stmt)
+ assert_equal(mo.to_gerber(), '%MOIN*%')
+
+ stmt = {'param': 'MO', 'mo': 'MM'}
+ mo = MOParamStmt.from_dict(stmt)
+ assert_equal(mo.to_gerber(), '%MOMM*%')
+
+
+def test_IPParamStmt_factory():
+ """ Test IPParamStruct factory correctly handles parameters
+ """
+ stmt = {'param': 'IP', 'ip': 'POS'}
+ ip = IPParamStmt.from_dict(stmt)
+ assert_equal(ip.ip, 'positive')
+
+ stmt = {'param': 'IP', 'ip': 'NEG'}
+ ip = IPParamStmt.from_dict(stmt)
+ assert_equal(ip.ip, 'negative')
+
+
+def test_IPParamStmt_dump():
+ """ Test IPParamStmt to_gerber()
+ """
+ stmt = {'param': 'IP', 'ip': 'POS'}
+ ip = IPParamStmt.from_dict(stmt)
+ assert_equal(ip.to_gerber(), '%IPPOS*%')
+
+ stmt = {'param': 'IP', 'ip': 'NEG'}
+ ip = IPParamStmt.from_dict(stmt)
+ assert_equal(ip.to_gerber(), '%IPNEG*%')
diff --git a/gerber/tests/tests.py b/gerber/tests/tests.py
new file mode 100644
index 0000000..29b7899
--- /dev/null
+++ b/gerber/tests/tests.py
@@ -0,0 +1,18 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Author: Hamilton Kibbe <ham@hamiltonkib.be>
+
+from nose.tools import assert_in
+from nose.tools import assert_not_in
+from nose.tools import assert_equal
+from nose.tools import assert_not_equal
+from nose.tools import assert_true
+from nose.tools import assert_false
+from nose.tools import assert_raises
+from nose.tools import raises
+from nose import with_setup
+
+__all__ = ['assert_in', 'assert_not_in', 'assert_equal', 'assert_not_equal',
+ 'assert_true', 'assert_false', 'assert_raises', 'raises',
+ 'with_setup' ]