def test_HTTPSDistributor_getBridges_with_some_blocked_bridges(self):
    dist = distributor.HTTPSDistributor(1, self.key)
    bridges = self.bridges[:]
    blockedCN = []
    blockedIR = []
    for bridge in bridges:
        if self.coinFlip():
            bridge.setBlockedIn('cn')
            blockedCN.append(bridge.fingerprint)
        if self.coinFlip():
            bridge.setBlockedIn('ir')
            blockedIR.append(bridge.fingerprint)
    [dist.insert(bridge) for bridge in bridges]
    for _ in range(5):
        clientRequest1 = self.randomClientRequestForNotBlockedIn('cn')
        bridges = dist.getBridges(clientRequest1, 1)
        for b in bridges:
            self.assertFalse(b.isBlockedIn('cn'))
            self.assertNotIn(b.fingerprint, blockedCN)
        self.assertGreater(len(bridges), 0)
        clientRequest2 = self.randomClientRequestForNotBlockedIn('ir')
        bridges = dist.getBridges(clientRequest2, 1)
        for b in bridges:
            self.assertFalse(b.isBlockedIn('ir'))
            self.assertNotIn(b.fingerprint, blockedIR)
        self.assertGreater(len(bridges), 0)
def test_HTTPSDistributor_getBridges_with_some_blocked_bridges(self):
    dist = distributor.HTTPSDistributor(1, self.key)
    bridges = self.bridges[:]
    blockedCN = []
    blockedIR = []
    for bridge in bridges:
        if self.coinFlip():
            bridge.setBlockedIn('cn')
            blockedCN.append(bridge.fingerprint)
        if self.coinFlip():
            bridge.setBlockedIn('ir')
            blockedIR.append(bridge.fingerprint)
    [dist.insert(bridge) for bridge in bridges]
    for _ in range(5):
        clientRequest1 = self.randomClientRequestForNotBlockedIn('cn')
        bridges = dist.getBridges(clientRequest1, 1)
        for b in bridges:
            self.assertFalse(b.isBlockedIn('cn'))
            self.assertNotIn(b.fingerprint, blockedCN)
        self.assertGreater(len(bridges), 0)
        clientRequest2 = self.randomClientRequestForNotBlockedIn('ir')
        bridges = dist.getBridges(clientRequest2, 1)
        for b in bridges:
            self.assertFalse(b.isBlockedIn('ir'))
            self.assertNotIn(b.fingerprint, blockedIR)
        self.assertGreater(len(bridges), 0)