Commit bbcd2c61 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

BOARD saving test

parent 9263a4e7
from pcbnew import *
import unittest
class TestLoadSave(unittest.TestCase):
def setUp(self):
self.TITLE="Test Board"
self.COMMENT1="For load/save test"
self.FILENAME="/tmp/test.brd"
def test_00_save(self):
pcb = BOARD()
pcb.GetTitleBlock().SetTitle(self.TITLE)
pcb.GetTitleBlock().SetComment1(self.COMMENT1)
result = SaveBoard(self.FILENAME,pcb)
self.assertTrue(result)
def test_01_load(self):
pcb2 = LoadBoard(self.FILENAME)
self.assertIsNotNone(pcb2)
def test_02_titleblock_ok(self):
pcb2 = LoadBoard(self.FILENAME)
tb = pcb2.GetTitleBlock()
self.assertEqual(tb.GetTitle(),self.TITLE)
self.assertEqual(tb.GetComment1(),self.COMMENT1)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
import code
import unittest
import os
import pcbnew
import pdb
import tempfile
from pcbnew import *
......@@ -9,6 +12,9 @@ class TestBoardClass(unittest.TestCase):
def setUp(self):
self.pcb = LoadBoard("data/complex_hierarchy.kicad_pcb")
self.TITLE="Test Board"
self.COMMENT1="For load/save test"
self.FILENAME=tempfile.mktemp()+".kicad_pcb"
def test_pcb_find_module(self):
module = self.pcb.FindModule('P1')
......@@ -74,6 +80,22 @@ class TestBoardClass(unittest.TestCase):
self.assertEqual(pad.this, p2.this)
self.assertEqual(pad.this, p3.this)
def test_pcb_save_and_load(self):
pcb = BOARD()
pcb.GetTitleBlock().SetTitle(self.TITLE)
pcb.GetTitleBlock().SetComment1(self.COMMENT1)
result = SaveBoard(self.FILENAME,pcb)
self.assertTrue(result)
pcb2 = LoadBoard(self.FILENAME)
self.assertIsNotNone(pcb2)
tb = pcb2.GetTitleBlock()
self.assertEqual(tb.GetTitle(),self.TITLE)
self.assertEqual(tb.GetComment1(),self.COMMENT1)
os.remove(self.FILENAME)
#def test_interactive(self):
# code.interact(local=locals())
......
......@@ -66,7 +66,7 @@
#include <class_title_block.h>
#include <class_colors_design_settings.h>
#include <class_marker_base.h>
#include <eda_text.h>
#include <eda_text.h>
#include <convert_from_iu.h>
#include <convert_to_biu.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment