Example #1
0
    def test_selectExitNode_one_exit(self, mock_fe, mock_swn, mock_gwn, mock_gpw):
        bw_weights = 'bw_weights'
        bwweightscale = 'bwweightscale'
        cons_rel_stats = 'cons_rel_stats'
        descriptors = 'descriptors'
        fast = 'fast'
        stable = 'stable'
        internal = 'internal'
        port = 'port'

        ret = path.selectExitNode(
            bw_weights,
            bwweightscale,
            cons_rel_stats,
            descriptors,
            fast,
            stable,
            internal,
            port)

        self.assertEqual(ret, 'exit1')

        mock_fe.assert_called_once_with(
            cons_rel_stats,
            descriptors,
            fast,
            stable,
            internal,
            port)

        self.assertEqual(mock_gpw.call_count, 0)
        self.assertEqual(mock_gwn.call_count, 0)
        self.assertEqual(mock_swn.call_count, 0)
Example #2
0
    def test_selectExitNode_internal(self, mock_fe, mock_swn, mock_gwn, mock_gpw):
        bw_weights = 'bw_weights'
        bwweightscale = 'bwweightscale'
        cons_rel_stats = 'cons_rel_stats'
        descriptors = 'descriptors'
        fast = 'fast'
        stable = 'stable'
        internal = True
        port = 'port'

        _ = path.selectExitNode(
            bw_weights,
            bwweightscale,
            cons_rel_stats,
            descriptors,
            fast,
            stable,
            internal,
            port)

        mock_fe.assert_called_once_with(
            cons_rel_stats,
            descriptors,
            fast,
            stable,
            internal,
            port)

        mock_gpw.assert_called_once_with(
            ['exit1', 'exit2'],
            cons_rel_stats,
            'm',
            bw_weights,
            bwweightscale)
Example #3
0
    def test_selectExitNode_internal(self, mock_fe, mock_swn, mock_gwn,
                                     mock_gpw):
        bw_weights = 'bw_weights'
        bwweightscale = 'bwweightscale'
        cons_rel_stats = 'cons_rel_stats'
        descriptors = 'descriptors'
        fast = 'fast'
        stable = 'stable'
        internal = True
        port = 'port'

        _ = path.selectExitNode(bw_weights, bwweightscale, cons_rel_stats,
                                descriptors, fast, stable, internal, port)

        mock_fe.assert_called_once_with(cons_rel_stats, descriptors, fast,
                                        stable, internal, port)

        mock_gpw.assert_called_once_with(['exit1', 'exit2'], cons_rel_stats,
                                         'm', bw_weights, bwweightscale)
Example #4
0
    def test_selectExitNode_one_exit(self, mock_fe, mock_swn, mock_gwn,
                                     mock_gpw):
        bw_weights = 'bw_weights'
        bwweightscale = 'bwweightscale'
        cons_rel_stats = 'cons_rel_stats'
        descriptors = 'descriptors'
        fast = 'fast'
        stable = 'stable'
        internal = 'internal'
        port = 'port'

        ret = path.selectExitNode(bw_weights, bwweightscale, cons_rel_stats,
                                  descriptors, fast, stable, internal, port)

        self.assertEqual(ret, 'exit1')

        mock_fe.assert_called_once_with(cons_rel_stats, descriptors, fast,
                                        stable, internal, port)

        self.assertEqual(mock_gpw.call_count, 0)
        self.assertEqual(mock_gwn.call_count, 0)
        self.assertEqual(mock_swn.call_count, 0)