示例#1
0
    def test_is_connected_multi_level(self):
        
        # No connections:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        assert p.is_connected(0, 1) == False
        assert p.is_connected(1, 0) == False

        # Connected in one direction:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        p['/aaa[0]', '/bbb[2]'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == False

        # Connected in both directions:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        p['/aaa[0]', '/bbb[2]'] = 1
        p['/bbb[0]', '/aaa[1]'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == True
示例#2
0
    def test_is_connected_single_level(self):

        # No connections:
        p = Pattern('/[aaa,bbb]', '/[ccc,ddd]')
        assert p.is_connected(0, 1) == False
        assert p.is_connected(1, 0) == False
        
        # Connected in one direction:
        p = Pattern('/[aaa,bbb]', '/[ccc,ddd]')
        p['/aaa', '/ccc'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == False

        # Connected in both directions:
        p = Pattern('/[aaa,bbb,ccc]', '/[ddd,eee,fff]')
        p['/aaa', '/ddd'] = 1
        p['/eee', '/bbb'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == True
示例#3
0
    def test_is_connected_multi_level(self):

        # No connections:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        assert p.is_connected(0, 1) == False
        assert p.is_connected(1, 0) == False

        # Connected in one direction:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        p['/aaa[0]', '/bbb[2]'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == False

        # Connected in both directions:
        p = Pattern('/aaa[0:3]', '/bbb[0:3]')
        p['/aaa[0]', '/bbb[2]'] = 1
        p['/bbb[0]', '/aaa[1]'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == True
示例#4
0
    def test_is_connected_single_level(self):

        # No connections:
        p = Pattern('/[aaa,bbb]', '/[ccc,ddd]')
        assert p.is_connected(0, 1) == False
        assert p.is_connected(1, 0) == False

        # Connected in one direction:
        p = Pattern('/[aaa,bbb]', '/[ccc,ddd]')
        p['/aaa', '/ccc'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == False

        # Connected in both directions:
        p = Pattern('/[aaa,bbb,ccc]', '/[ddd,eee,fff]')
        p['/aaa', '/ddd'] = 1
        p['/eee', '/bbb'] = 1
        assert p.is_connected(0, 1) == True
        assert p.is_connected(1, 0) == True
示例#5
0
 def test_is_connected_multi_level(self):
     p = Pattern('/aaa[0:3]', '/bbb[0:3]')
     p['/aaa[0]', '/bbb[2]'] = 1
     assert p.is_connected(0, 1) == True
     assert p.is_connected(1, 0) == False
示例#6
0
 def test_is_connected_single_level(self):
     p = Pattern('/[aaa,bbb]', '/[ccc,ddd]')
     p['/aaa', '/ccc'] = 1
     assert p.is_connected(0, 1) == True
     assert p.is_connected(1, 0) == False