diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2016-11-05 21:11:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-05 21:11:09 -0400 |
commit | d2fe4441662435e55f2dc481bf94a2729b9d6a48 (patch) | |
tree | dd60a0b21e1d1ca7258b9f978ce973354d96062c /gerber/tests/test_cam.py | |
parent | 318a81382e074a5897489299a58e029815d23492 (diff) | |
parent | 5af19af190c1fb0f0c5be029d46d63e657dde4d9 (diff) | |
download | gerbonara-d2fe4441662435e55f2dc481bf94a2729b9d6a48.tar.gz gerbonara-d2fe4441662435e55f2dc481bf94a2729b9d6a48.tar.bz2 gerbonara-d2fe4441662435e55f2dc481bf94a2729b9d6a48.zip |
Merge pull request #3 from garretfick/merge-curtacircuitos
Merge curtacircuitos
Diffstat (limited to 'gerber/tests/test_cam.py')
-rw-r--r-- | gerber/tests/test_cam.py | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/gerber/tests/test_cam.py b/gerber/tests/test_cam.py index ce4ec44..a557e8c 100644 --- a/gerber/tests/test_cam.py +++ b/gerber/tests/test_cam.py @@ -4,7 +4,7 @@ # Author: Hamilton Kibbe <ham@hamiltonkib.be> from ..cam import CamFile, FileSettings -from tests import * +from .tests import * def test_filesettings_defaults(): @@ -54,15 +54,107 @@ def test_filesettings_dict_assign(): assert_equal(fs.zero_suppression, 'leading') assert_equal(fs.format, (1, 2)) + def test_camfile_init(): """ Smoke test CamFile test """ cf = CamFile() + def test_camfile_settings(): """ Test CamFile Default Settings """ cf = CamFile() assert_equal(cf.settings, FileSettings()) + + +def test_bounds_override_smoketest(): + cf = CamFile() + cf.bounds + + +def test_zeros(): + """ Test zero/zero_suppression interaction + """ + fs = FileSettings() + assert_equal(fs.zero_suppression, 'trailing') + assert_equal(fs.zeros, 'leading') + + fs['zero_suppression'] = 'leading' + assert_equal(fs.zero_suppression, 'leading') + assert_equal(fs.zeros, 'trailing') + + fs.zero_suppression = 'trailing' + assert_equal(fs.zero_suppression, 'trailing') + assert_equal(fs.zeros, 'leading') + + fs['zeros'] = 'trailing' + assert_equal(fs.zeros, 'trailing') + assert_equal(fs.zero_suppression, 'leading') + + fs.zeros = 'leading' + assert_equal(fs.zeros, 'leading') + assert_equal(fs.zero_suppression, 'trailing') + + fs = FileSettings(zeros='leading') + assert_equal(fs.zeros, 'leading') + assert_equal(fs.zero_suppression, 'trailing') + + fs = FileSettings(zero_suppression='leading') + assert_equal(fs.zeros, 'trailing') + assert_equal(fs.zero_suppression, 'leading') + + fs = FileSettings(zeros='leading', zero_suppression='trailing') + assert_equal(fs.zeros, 'leading') + assert_equal(fs.zero_suppression, 'trailing') + + fs = FileSettings(zeros='trailing', zero_suppression='leading') + assert_equal(fs.zeros, 'trailing') + assert_equal(fs.zero_suppression, 'leading') + + +def test_filesettings_validation(): + """ Test FileSettings constructor argument validation + """ +<<<<<<< HEAD + # absolute-ish is not a valid notation + assert_raises(ValueError, FileSettings, 'absolute-ish', + 'inch', None, (2, 5), None) + + # degrees kelvin isn't a valid unit for a CAM file + assert_raises(ValueError, FileSettings, 'absolute', + 'degrees kelvin', None, (2, 5), None) + + assert_raises(ValueError, FileSettings, 'absolute', + 'inch', 'leading', (2, 5), 'leading') -
\ No newline at end of file + # Technnically this should be an error, but Eangle files often do this incorrectly so we + # allow it + #assert_raises(ValueError, FileSettings, 'absolute', + # 'inch', 'following', (2, 5), None) + +======= + assert_raises(ValueError, FileSettings, 'absolute-ish', + 'inch', None, (2, 5), None) + assert_raises(ValueError, FileSettings, 'absolute', + 'degrees kelvin', None, (2, 5), None) + assert_raises(ValueError, FileSettings, 'absolute', + 'inch', 'leading', (2, 5), 'leading') + assert_raises(ValueError, FileSettings, 'absolute', + 'inch', 'following', (2, 5), None) +>>>>>>> 5476da8... Fix a bunch of rendering bugs. + assert_raises(ValueError, FileSettings, 'absolute', + 'inch', None, (2, 5), 'following') + assert_raises(ValueError, FileSettings, 'absolute', + 'inch', None, (2, 5, 6), None) + + +def test_key_validation(): + fs = FileSettings() + assert_raises(KeyError, fs.__getitem__, 'octopus') + assert_raises(KeyError, fs.__setitem__, 'octopus', 'do not care') + assert_raises(ValueError, fs.__setitem__, 'notation', 'absolute-ish') + assert_raises(ValueError, fs.__setitem__, 'units', 'degrees kelvin') + assert_raises(ValueError, fs.__setitem__, 'zero_suppression', 'following') + assert_raises(ValueError, fs.__setitem__, 'zeros', 'following') + assert_raises(ValueError, fs.__setitem__, 'format', (2, 5, 6)) |