tests.py
Go to the documentation of this file.
00001 import unittest
00002 import types
00003 
00004 
00005 
00006 
00007 class Test_BlockNeighbors(unittest.TestCase):
00008     def test(self):
00009         import topology
00010         t = topology.Topology()
00011         v0 = topology.Vertex(t)
00012         v1 = topology.Vertex(t)
00013         v2 = topology.Vertex(t)
00014         v3 = topology.Vertex(t)
00015 
00016         assert(v0.block.index is None)
00017         assert(v1.block.index is None)
00018         assert(v2.block.index is None)
00019         assert(v3.block.index is None)
00020 
00021         v1.block.index = 1
00022         assert(v1.block.leftBlock is None)
00023         assert(v1.block.rightBlock is None)
00024 
00025         v3.block.index = 3
00026         assert(v1.block.leftBlock is None)
00027         assert(v1.block.rightBlock == v3.block)
00028         assert(v3.block.leftBlock == v1.block)
00029         assert(v3.block.rightBlock is None)
00030 
00031         v2.block.index = 0
00032         assert(v1.block.leftBlock == v2.block)
00033         assert(v1.block.rightBlock == v3.block)
00034         assert(v2.block.leftBlock is None)
00035         assert(v2.block.rightBlock == v1.block)
00036         assert(v3.block.leftBlock == v1.block)
00037         assert(v3.block.rightBlock is None)
00038 
00039         v2.block.index = 2
00040         assert(v1.block.leftBlock is None)
00041         assert(v1.block.rightBlock == v2.block)
00042         assert(v2.block.leftBlock == v1.block)
00043         assert(v2.block.rightBlock == v3.block)
00044         assert(v3.block.leftBlock == v2.block)
00045         assert(v3.block.rightBlock is None)
00046 
00047         v0.block.index = 0
00048         assert(v0.block.leftBlock is None)
00049         assert(v0.block.rightBlock == v1.block)
00050         assert(v1.block.leftBlock == v0.block)
00051         assert(v1.block.rightBlock == v2.block)
00052         assert(v2.block.leftBlock == v1.block)
00053         assert(v2.block.rightBlock == v3.block)
00054         assert(v3.block.leftBlock == v2.block)
00055         assert(v3.block.rightBlock is None)
00056 
00057 
00058 
00059 
00060 
00061 class Test_v5_a(unittest.TestCase):
00062     def setUp(self):
00063         import parser
00064         self.t = parser.parseFile('data/v5_a.xml')
00065  
00066     def test_band_emitters_collectors(self):
00067         t = self.t
00068 
00069         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [0])
00070         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [1])
00071         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [2])
00072         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [1])
00073 
00074     def test_block(self):
00075         t = self.t
00076         # Make sure the matching is correct
00077         for index in t.blocks:
00078             assert(t.blocks[index].index == index)
00079 
00080         # Count the number of emitters and collectors of each block
00081         # {blockIndex: (#collectors,#emitters), ...}
00082         vals = { 0: (0,1),  1: (1,0),  2: (0,1)}
00083         for index in t.blocks:
00084             assert(len(t.blocks[index].collector) == vals[index][0])
00085             assert(len(t.blocks[index].emitter) == vals[index][1])
00086 
00087     def test_snaps_to_bands_connectivity(self):
00088         """ Test to make sure that snaps are connected to the correct bands """
00089         t = self.t
00090         assert(t.blocks[0].emitter[0].posBandLink.altitude == 1)
00091         assert(t.blocks[0].emitter[0].negBandLink is None)
00092         assert(t.blocks[1].collector[0].posBandLink.altitude == 1)
00093         assert(t.blocks[1].collector[0].negBandLink.altitude == -1)
00094         assert(t.blocks[2].emitter[0].posBandLink is None)
00095         assert(t.blocks[2].emitter[0].negBandLink.altitude == -1)
00096 
00097 
00098 
00099 class Test_v5_b(unittest.TestCase):
00100     def setUp(self):
00101         import parser
00102         self.t = parser.parseFile('data/v5_b.xml')
00103  
00104     def test_band_emitters_collectors(self):
00105         t = self.t
00106 
00107 
00108         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [1])
00109         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [2])
00110         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [1])
00111         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [0])
00112 
00113     def test_block(self):
00114         t = self.t
00115         # Make sure the matching is correct
00116         for index in t.blocks:
00117             assert(t.blocks[index].index == index)
00118 
00119         # Count the number of emitters and collectors of each block
00120         # {blockIndex: (#collectors,#emitters), ...}
00121         vals = { 0: (1,0),  1: (0,1),  2: (1,0)}
00122         for index in t.blocks:
00123             assert(len(t.blocks[index].collector) == vals[index][0])
00124             assert(len(t.blocks[index].emitter) == vals[index][1])
00125 
00126     def test_snaps_to_bands_connectivity(self):
00127         """ Test to make sure that snaps are connected to the correct bands """
00128         t = self.t
00129         assert(t.blocks[0].collector[0].posBandLink is None)
00130         assert(t.blocks[0].collector[0].negBandLink.altitude == -1)
00131         assert(t.blocks[1].emitter[0].posBandLink.altitude == 1)
00132         assert(t.blocks[1].emitter[0].negBandLink.altitude == -1)
00133         assert(t.blocks[2].collector[0].posBandLink.altitude == 1)
00134         assert(t.blocks[2].collector[0].negBandLink is None)
00135 
00136 
00137 
00138 class Test_v5_c(unittest.TestCase):
00139     def setUp(self):
00140         import parser
00141         self.t = parser.parseFile('data/v5_c.xml')
00142  
00143     def test_band_emitters_collectors(self):
00144         t = self.t
00145 
00146         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [0])
00147         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [1,2])
00148         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [])
00149         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [])
00150 
00151     def test_block(self):
00152         t = self.t
00153         # Make sure the matching is correct
00154         for index in t.blocks:
00155             assert(t.blocks[index].index == index)
00156 
00157         # Count the number of emitters and collectors of each block
00158         # {blockIndex: (#collectors,#emitters), ...}
00159         vals = { 0: (0,1),  1: (1,0),  2: (1,0)}
00160         for index in t.blocks:
00161             assert(len(t.blocks[index].collector) == vals[index][0])
00162             assert(len(t.blocks[index].emitter) == vals[index][1])
00163 
00164     def test_snaps_to_bands_connectivity(self):
00165         """ Test to make sure that snaps are connected to the correct bands """
00166         t = self.t
00167         assert(t.blocks[0].emitter[0].posBandLink.altitude == 1)
00168         assert(t.blocks[0].emitter[0].negBandLink is None)
00169         assert(t.blocks[1].collector[0].posBandLink.altitude == 1)
00170         assert(t.blocks[1].collector[0].negBandLink is None)
00171         assert(t.blocks[2].collector[0].posBandLink.altitude == 1)
00172         assert(t.blocks[2].collector[0].negBandLink is None)
00173 
00174 class Test_v5_d(unittest.TestCase):
00175     def setUp(self):
00176         import parser
00177         self.t = parser.parseFile('data/v5_d.xml')
00178  
00179     def test_band_emitters_collectors(self):
00180         t = self.t
00181         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [])
00182         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [])
00183         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [1,2])
00184         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [0])
00185 
00186     def test_block_index(self):
00187         """ checks that topology block indexing follows block index values """
00188         t = self.t
00189         # Make sure the matching is correct
00190         for index in t.blocks:
00191             assert(t.blocks[index].index == index)
00192 
00193     def test_emitter_collector_count(self):
00194         """ Counts the number of emitters and collectors in each block """
00195         # {blockIndex: (#collectors,#emitters), ...}
00196         vals = { 0: (1,0),  1: (0,1),  2: (0,1)}
00197         t = self.t
00198         for index in t.blocks:
00199             assert(len(t.blocks[index].collector) == vals[index][0])
00200             assert(len(t.blocks[index].emitter) == vals[index][1])
00201 
00202     def test_snaps_connectivity(self):
00203         """ Test to make sure that snaps are connected to the correct bands """
00204         t = self.t
00205         assert(t.blocks[0].collector[0].posBandLink is None)
00206         assert(t.blocks[0].collector[0].negBandLink.altitude == -1)
00207         assert(t.blocks[1].emitter[0].posBandLink is None)
00208         assert(t.blocks[1].emitter[0].negBandLink.altitude == -1)
00209         assert(t.blocks[2].emitter[0].posBandLink is None)
00210         assert(t.blocks[2].emitter[0].negBandLink.altitude == -1)
00211 
00212 class Test_v5_e(unittest.TestCase):
00213     def setUp(self):
00214         import parser
00215         self.t = parser.parseFile('data/v5_e.xml')
00216  
00217     def test_band_emitters_collectors(self):
00218         t = self.t
00219         # Check locations
00220         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [0,2])
00221         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [1,3])
00222         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [2])
00223         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [1])
00224 
00225     def test_block_index(self):
00226         """ checks that topology block indexing follows block index values """
00227         t = self.t
00228         # Make sure the matching is correct
00229         for index in t.blocks:
00230             assert(t.blocks[index].index == index)
00231 
00232     def test_emitter_collector_count(self):
00233         """ Counts the number of emitters and collectors in each block """
00234         # {blockIndex: (#collectors,#emitters), ...}
00235         vals = { 0: (0,1),  1: (1,0),  2: (0,1), 3: (1,0)}
00236         t = self.t
00237         for index in t.blocks:
00238             assert(len(t.blocks[index].collector) == vals[index][0])
00239             assert(len(t.blocks[index].emitter) == vals[index][1])
00240 
00241     def test_snaps_connectivity(self):
00242         """ Test to make sure that snaps are connected to the correct bands """
00243         t = self.t
00244         assert(t.blocks[0].emitter[0].posBandLink.altitude == 1)
00245         assert(t.blocks[0].emitter[0].negBandLink is None)
00246         assert(t.blocks[1].collector[0].posBandLink.altitude == 1)
00247         assert(t.blocks[1].collector[0].negBandLink.altitude == -1)
00248         assert(t.blocks[2].emitter[0].posBandLink.altitude == 1)
00249         assert(t.blocks[2].emitter[0].negBandLink.altitude == -1)
00250         assert(t.blocks[3].collector[0].posBandLink.altitude == 1)
00251         assert(t.blocks[3].collector[0].negBandLink is None)
00252 
00253 
00254 class Test_v5_f(unittest.TestCase):
00255     def setUp(self):
00256         import parser
00257         self.t = parser.parseFile('data/v5_f.xml')
00258  
00259     def test_band_emitters_collectors(self):
00260         t = self.t
00261        
00262         # Check locations
00263         assert([snap.block.index for snap in t.edges[0].posBand.emitters] == [1])
00264         assert([snap.block.index for snap in t.edges[0].posBand.collectors] == [2])
00265         assert([snap.block.index for snap in t.edges[0].negBand.emitters] == [1,3])
00266         assert([snap.block.index for snap in t.edges[0].negBand.collectors] == [0,2])
00267 
00268     def test_block_index(self):
00269         """ checks that topology block indexing follows block index values """
00270         t = self.t
00271         # Make sure the matching is correct
00272         for index in t.blocks:
00273             assert(t.blocks[index].index == index)
00274 
00275     def test_emitter_collector_count(self):
00276         """ Counts the number of emitters and collectors in each block """
00277         # {blockIndex: (#collectors,#emitters), ...}
00278         vals = { 0: (1,0),  1: (0,1),  2: (1,0), 3: (0,1)}
00279         t = self.t
00280         for index in t.blocks:
00281             assert(len(t.blocks[index].collector) == vals[index][0])
00282             assert(len(t.blocks[index].emitter) == vals[index][1])
00283 
00284     def test_snaps_connectivity(self):
00285         """ Test to make sure that snaps are connected to the correct bands """
00286         t = self.t
00287         assert(t.blocks[0].collector[0].negBandLink.altitude == -1)
00288         assert(t.blocks[0].collector[0].posBandLink is None)
00289         assert(t.blocks[1].emitter[0].negBandLink.altitude == -1)
00290         assert(t.blocks[1].emitter[0].posBandLink.altitude == 1)
00291         assert(t.blocks[2].collector[0].negBandLink.altitude == -1)
00292         assert(t.blocks[2].collector[0].posBandLink.altitude == 1)
00293         assert(t.blocks[3].emitter[0].negBandLink.altitude == -1)
00294         assert(t.blocks[3].emitter[0].posBandLink is None)
00295 
00296 
00297 
00298 
00299 if __name__ == "__main__":
00300     unittest.main()
00301 
00302 
00303 
00304 


rqt_graphprofiler
Author(s): Dan Brooks
autogenerated on Thu Jun 6 2019 20:29:31