Esempio n. 1
0
 def test_parse_not_callable(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR TENANT:0123456789abcdef DO SET compression')
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     action_list = rule_parsed.action_list
     self.assertEqual(len(action_list), 1)
     action_info = action_list[0]
     self.assertEqual(action_info.callable, '')
Esempio n. 2
0
 def test_parse_target_object_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR OBJECT:0123456789abcdef/container1/object.txt DO SET compression')
     self.assertIsNotNone(rule_parsed)
     targets = rule_parsed.target
     self.assertEqual(len(targets), 1)
     target = targets[0]
     self.assertEqual(target.type, 'OBJECT')
     self.assertEqual(target[1], '0123456789abcdef/container1/object.txt')
Esempio n. 3
0
 def test_parse_target_container_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR CONTAINER:0123456789abcdef/container1 DO SET compression')
     self.assertIsNotNone(rule_parsed)
     targets = rule_parsed.target
     self.assertEqual(len(targets), 1)
     target = targets[0]
     self.assertEqual(target.type, 'CONTAINER')
     self.assertEqual(target[1], '0123456789abcdef/container1')
Esempio n. 4
0
 def test_parse_group_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR G:1 DO SET compression')
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     targets = rule_parsed.target
     action_list = rule_parsed.action_list
     self.assertEqual(len(targets), 2)
     self.assertEqual(len(action_list), 1)
     self.assertEqual(targets[0], 'abcdef0123456789')
     self.assertEqual(targets[1], '0123456789abcdef')
Esempio n. 5
0
 def test_parse_target_tenant_to_object_type_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR TENANT:0123456789abcdef DO SET compression TO OBJECT_TYPE=DOCS')
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     object_list = rule_parsed.object_list
     self.assertIsNotNone(object_list)
     object_type = object_list.object_type
     self.assertIsNotNone(object_type)
     self.assertIsNotNone(object_type.object_value)
     self.assertEqual(object_type.object_value, 'DOCS')
Esempio n. 6
0
 def test_parse_target_tenant_with_parameters_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR TENANT:0123456789abcdef DO SET compression WITH cparam1=11, cparam2=12, cparam3=13')
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     targets = rule_parsed.target
     action_list = rule_parsed.action_list
     self.assertEqual(len(targets), 1)
     self.assertEqual(len(action_list), 1)
     action_info = action_list[0]
     self.assertEqual(action_info.action, 'SET')
     self.assertEqual(action_info.filter, 'compression')
     self.assertEqual(action_info.execution_server, '')
     self.assertEqual(len(action_info.params), 6)  # ???
Esempio n. 7
0
 def test_parse_target_tenant_ok(self):
     self.setup_dsl_parser_data()
     has_condition_list, rule_parsed = parse('FOR TENANT:0123456789abcdef DO SET compression')
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     targets = rule_parsed.target
     action_list = rule_parsed.action_list
     self.assertEqual(len(targets), 1)
     self.assertEqual(len(action_list), 1)
     target = targets[0]
     self.assertEqual(target.type, 'TENANT')
     self.assertEqual(target[1], '0123456789abcdef')
     action_info = action_list[0]
     self.assertEqual(action_info.action, 'SET')
     self.assertEqual(action_info.filter, 'compression')
     self.assertEqual(action_info.execution_server, '')
     self.assertEqual(action_info.params, '')
Esempio n. 8
0
 def test_parse_target_tenant_to_object_type_tag_size_ok(self):
     self.setup_dsl_parser_data()
     rule_str = 'FOR TENANT:0123456789abcdef DO SET compression TO OBJECT_TAG=tagtag, OBJECT_SIZE>10, OBJECT_TYPE=DOCS'
     has_condition_list, rule_parsed = parse(rule_str)
     self.assertFalse(has_condition_list)
     self.assertIsNotNone(rule_parsed)
     object_list = rule_parsed.object_list
     self.assertIsNotNone(object_list)
     object_type = object_list.object_type
     self.assertIsNotNone(object_type)
     self.assertIsNotNone(object_type.object_value)
     self.assertEqual(object_type.object_value, 'DOCS')
     object_tag = object_list.object_tag
     self.assertIsNotNone(object_tag)
     self.assertIsNotNone(object_tag.object_value)
     self.assertEqual(object_tag.object_value, 'tagtag')
     object_size = object_list.object_size
     self.assertIsNotNone(object_size)
     self.assertIsNotNone(object_size.object_value)
     self.assertEqual(object_size.object_value, '10')
     self.assertEqual(object_size.operand, '>')
Esempio n. 9
0
 def test_parse_rule_with_invalid_target(self):
     self.setup_dsl_parser_data()
     with self.assertRaises(ParseException):
         parse('FOR xxxxxxx DO SET compression')
Esempio n. 10
0
 def test_parse_rule_not_starting_with_for(self):
     self.setup_dsl_parser_data()
     with self.assertRaises(ParseException):
         parse('TENANT:1234 DO SET compression')