def test_bad_set_weight(self):
        base = {
            'replicas': 3, 'part_power': 8, 'random_seed': 123, 'overload': 0}

        # no dev
        busted = dict(base, rounds=[[['set_weight']]])
        self.assertRaises(ValueError, parse_scenario, json.dumps(busted))

        # no weight
        busted = dict(base, rounds=[[['set_weight', 0]]])
        self.assertRaises(ValueError, parse_scenario, json.dumps(busted))

        # bad dev id
        busted = dict(base, rounds=[[['set_weight', 'not an int', 90]]])
        expected = "Invalid device ID in set_weight (round 0, command 0): " \
            "invalid literal for int() with base 10: 'not an int'"
        try:
            parse_scenario(json.dumps(busted))
        except __HOLE__ as e:
            self.assertEqual(str(e), expected)

        # negative weight
        busted = dict(base, rounds=[[['set_weight', 1, -1]]])
        self.assertRaises(ValueError, parse_scenario, json.dumps(busted))

        # bogus weight
        busted = dict(base, rounds=[[['set_weight', 1, 'bogus']]])
        self.assertRaises(ValueError, parse_scenario, json.dumps(busted))
dataset/ETHPy150Open openstack/swift/test/unit/cli/test_ring_builder_analyzer.py/TestParseScenario.test_bad_set_weight