BOARD saving test

This commit is contained in:
Miguel Angel Ajo 2014-02-09 00:21:47 +01:00
parent 9263a4e798
commit bbcd2c61d6
3 changed files with 23 additions and 30 deletions

View File

@ -1,29 +0,0 @@
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()

View File

@ -1,7 +1,10 @@
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())

View File

@ -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>