Commit 9cf5b885 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Start of unit test maintenance

- Fix temp dirs
- Fix test_frontier for model4
- Use future print_function
- Add doc when possible
parent 31ccc1b8
......@@ -392,7 +392,8 @@ class FrontierSolution(object):
@param other: a DimacsFrontierSol
@return bool
"""
return set(self.frontier_values) == set(other.frontier_values)
# return set(self.frontier_values) == set(other.frontier_values)
raise NotImplementedError
def save(self, outfile):
"""
......
......@@ -148,6 +148,12 @@ def model4():
node_i = root.add_input_node('in1', 0, 0)
tri = root.add_transition(node_i, node_1)
tri.set_condition("n5")
# Frontier test: Add a start node on n3 or do not attempt any frontier
# place because there is a SCC composed of n3, n4, n5.
#node_s = root.add_start_node('s1', 0, 0)
#root.add_transition(node_s, node_3)
return model
def create_unfolder(model):
......@@ -247,8 +253,8 @@ class TestCLUnfolder(unittest.TestCase):
model = model4()
unfolder = create_unfolder(model)
cfr = unfolder.get_frontier()
res = len(cfr) == 1
res = res and unfolder.get_var_name(cfr[0]) == 'n3'
res = len(cfr) == 0
# res = res and unfolder.get_var_name(cfr[0]) == 'n3'
self.assert_(res,'Error in frontier: model4')
......
......@@ -41,7 +41,7 @@
"""
Unitary Tests for the MCLAnalyser
"""
from __future__ import print_function
import unittest
import sys, os
......@@ -50,6 +50,7 @@ from cadbiom.models.guard_transitions.simulator.chart_simul import ChartSimulato
from cadbiom.models.guard_transitions.chart_model import ChartModel
from cadbiom.models.clause_constraints.mcl.MCLQuery import MCLSimpleQuery
from cadbiom.models.clause_constraints.mcl.MCLSolutions import FrontierSolution
from cadbiom.commons import DIR_LOGS
TRACE_FILE = sys.stdout
#TRACE_FILE = open("/tmp/testMCLAnalyzer.txt",'w')
......@@ -99,13 +100,13 @@ class ErrorRep(object):
just printing
"""
self.error = True
print '\n>> '+self.context+" "+mess
print('\n>> '+self.context+" "+mess)
def display_info(self, mess):
"""
just printing
"""
print '\n-- '+mess
print('\n-- '+mess)
def set_context(self, cont):
"""
......@@ -146,6 +147,7 @@ class TestMCLAnaLyzer(unittest.TestCase):
res = lit_sol_equal(sol1, sol2)
self.assert_(not res, 'Error in lit_sol inequality: number case')
@unittest.skip("Test files not provided")
def test_load1(self):
"""
Load from a bcx file
......@@ -167,6 +169,7 @@ class TestMCLAnaLyzer(unittest.TestCase):
res = rep.error
self.assert_(not res, 'Error in load2')
@unittest.skip("Test files not provided")
def test_load3(self):
"""
Load from a PID file
......@@ -332,6 +335,7 @@ class TestMCLAnaLyzer(unittest.TestCase):
self.assert_(res, 'Error unflatten')
@unittest.skip("Test files not provided")
def test_dimacs_frontier(self):
"""
frontier solution in DIMACS form
......@@ -363,6 +367,7 @@ class TestMCLAnaLyzer(unittest.TestCase):
res = res and (sol.get_solution()[i] == sol2.get_solution()[i])
self.assert_(not res, 'Error dimacs_frontier: solutions not different')
@unittest.skip("Test files not provided")
def test_prune(self):
"""
pruning a solution
......@@ -554,23 +559,26 @@ class TestMCLAnaLyzer(unittest.TestCase):
query = MCLSimpleQuery(None, None, f_prop)
macwic = mcla.mac_search(query, 10)
f_out = file("x_file", 'w')
f_out = file(DIR_LOGS + "x_file", 'w')
# print macwic[0].activated_frontier
# print macwic[0].ic_sequence
# print '---------------'
macwic[0].save(f_out)
r_front = FrontierSolution.from_file("x_file")
r_front = FrontierSolution.from_file(DIR_LOGS + "x_file")
# print r_front.activated_frontier
# print r_front.ic_sequence
res = r_front.has_same_frontier(macwic[0])
res = set(macwic[0].activated_frontier) == set(r_front.activated_frontier)
res = res and set( macwic[0].ic_sequence) == set(r_front.ic_sequence)
# res = r_front.has_same_frontier(macwic[0]) # Not implemented
self.assert_(res, "Frontier solutions differ after read")
os.remove("x_file")
os.remove(DIR_LOGS + "x_file")
def test_mac_inhibitor(self):
"""
test
[A1, B1,C1] not strong activator, D is a strong inhibitor
"""
rep = ErrorRep()
mcla = MCLAnalyser(rep)
......
......@@ -769,6 +769,7 @@ class TestFull(unittest.TestCase):
TRACE_FILE.write( 'place_clocks'+ cl_ds.place_clocks.__str__()+'\n')
TRACE_FILE.write( 'inputs'+ cl_ds.inputs.__str__()+'\n')
@unittest.skip("Test files not provided")
def test_tgf_no_clock(self):
"""
optimisation gain comparison
......
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