Ejemplo n.º 1
0
    def test_weight_locusts(self):
        maxDiff = 2048

        class BaseUser(User):
            pass

        class L1(BaseUser):
            weight = 101

        class L2(BaseUser):
            weight = 99

        class L3(BaseUser):
            weight = 100

        runner = Environment(user_classes=[L1, L2, L3]).create_local_runner()
        self.assert_locust_class_distribution({
            L1: 10,
            L2: 9,
            L3: 10
        }, runner.weight_users(29))
        self.assert_locust_class_distribution({
            L1: 10,
            L2: 10,
            L3: 10
        }, runner.weight_users(30))
        self.assert_locust_class_distribution({
            L1: 11,
            L2: 10,
            L3: 10
        }, runner.weight_users(31))
Ejemplo n.º 2
0
    def test_weight_locusts_fewer_amount_than_user_classes(self):
        class BaseUser(User):
            pass
        class L1(BaseUser):
            weight = 101
        class L2(BaseUser):
            weight = 99
        class L3(BaseUser):
            weight = 100

        runner = Environment(user_classes=[L1, L2, L3]).create_local_runner()
        self.assertEqual(1, len(runner.weight_users(1)))
        self.assert_locust_class_distribution({L1:1}, runner.weight_users(1))