Ejemplo n.º 1
0
    def test_tc_without_filter(self):
        expected_output = """tc qdisc add dev eth0 root handle 1: htb default 1;
tc class add dev eth0 parent 1: classid 1:1 htb rate 1000mbit;
tc qdisc add dev eth0 parent 1:1 handle 2: netem delay 1500ms;"""

        tc_obj = Tc()
        output = tc_obj.delay(1500).command()

        self.assertEqual(expected_output, output)
Ejemplo n.º 2
0
    def test_tc_reorder_without_delay(self):
        """
        There is a validation in the command() method that makes sure
        that if the reorder command is given that the delay is supplied as well.
        This test makes sure that this works as designed.
        """
        tc_obj = Tc()
        with self.assertRaises(Exception) as context:
            tc_obj.reorder(15).command()

        self.assertEqual(
            "The delay function must be specified when using reorder",
            str(context.exception))

        tc_obj = Tc()
        tc_obj.delay(1500).reorder(15).command()

        tc_obj = Tc()
        tc_obj.delay(1500).command()

        tc_obj = Tc()
        tc_obj.limit(1000).command()