From 3d849fd87c87dffb0a6770e5b7a97b3a16a2574f Mon Sep 17 00:00:00 2001 From: Miguel Angel Ajo Date: Tue, 4 Feb 2014 22:16:32 +0100 Subject: [PATCH] Adding a first BOARD class tester, very basic --- qa/testcases/test_001_pcb_load.py | 1 + qa/testcases/test_002_board_class.py | 35 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 qa/testcases/test_002_board_class.py diff --git a/qa/testcases/test_001_pcb_load.py b/qa/testcases/test_001_pcb_load.py index 724acdd37f..8e9aea9457 100644 --- a/qa/testcases/test_001_pcb_load.py +++ b/qa/testcases/test_001_pcb_load.py @@ -1,6 +1,7 @@ import code import unittest import pcbnew +import pdb class TestPCBLoad(unittest.TestCase): diff --git a/qa/testcases/test_002_board_class.py b/qa/testcases/test_002_board_class.py new file mode 100644 index 0000000000..230214ea6f --- /dev/null +++ b/qa/testcases/test_002_board_class.py @@ -0,0 +1,35 @@ +import code +import unittest +import pcbnew +import pdb + +from pcbnew import ToMM + +class TestBoardClass(unittest.TestCase): + + def setUp(self): + self.pcb = pcbnew.LoadBoard("data/complex_hierarchy.kicad_pcb") + + def test_pcb_find_module(self): + module = self.pcb.FindModule('P1') + self.assertEqual(module.GetReference(),'P1') + + def test_pcb_bounding_box(self): + bounding_box = self.pcb.ComputeBoundingBox() + + height = ToMM( bounding_box.GetHeight() ) + width = ToMM( bounding_box.GetWidth() ) + + # probably it's a cleaner test to generate a board with + # a couple of things, that we can know the exact size, + # and then compute the bounding box, + + self.assertAlmostEqual(height, 89.52, 2) + self.assertAlmostEqual(width, 108.44, 2) + + #def test_interactive(self): + # code.interact(local=locals()) + +if __name__ == '__main__': + unittest.main() + \ No newline at end of file