Beispiel #1
0
 def testParseYamlOrJsonCondition_Exception(self):
     file_content = 'expression: expr'
     with self.AssertRaisesExceptionRegexp(
             gcloud_exceptions.InvalidArgumentException,
             '.*condition-from-file must be a path to a YAML or JSON file containing'
             ' the condition.*'):
         iam_util.ParseYamlOrJsonCondition(file_content)
Beispiel #2
0
def ParseConditionFromFile(condition_from_file):
    """Read condition from YAML or JSON file."""

    condition = arg_parsers.BufferedFileInput()(condition_from_file)
    condition_dict = iam_util.ParseYamlOrJsonCondition(
        condition, _ConditionFileFormatException(condition_from_file))
    return condition_dict
Beispiel #3
0
 def testParseYamlOrJsonCondition(self, file_content, expected_condition):
     condition = iam_util.ParseYamlOrJsonCondition(file_content)
     self.assertEqual(condition, expected_condition)