def test_handle_parsing_graph_component(self):
        component_text = '''\
inputs:
- {name: graph in 1}
- {name: graph in 2}
outputs:
- {name: graph out 1}
- {name: graph out 2}
implementation:
  graph:
    tasks:
      task 1:
        componentRef: {name: Comp 1}
        arguments:
            in1 1: 11
      task 2:
        componentRef: {name: Comp 2}
        arguments:
            in2 1: 21
            in2 2: {taskOutput: {taskId: task 1, outputName: out1 1}}
      task 3:
        componentRef: {name: Comp 3}
        arguments:
            in3 1: {taskOutput: {taskId: task 2, outputName: out2 1}}
            in3 2: {graphInput: graph in 1}
    outputValues:
      graph out 1: {taskOutput: {taskId: task 3, outputName: out3 1}}
      graph out 2: {taskOutput: {taskId: task 1, outputName: out1 2}}
'''
        struct = load_yaml(component_text)
        ComponentSpec.from_struct(struct)
    def test_handle_parsing_predicates(self):
        component_text = '''\
implementation:
  graph:
    tasks:
      task 1:
        componentRef: {name: Comp 1}
      task 2:
        componentRef: {name: Comp 2}
        arguments:
            in2 1: 21
            in2 2: {taskOutput: {taskId: task 1, outputName: out1 1}}
        isEnabled:
            not:
                and:
                    op1:
                        '>':
                            op1: {taskOutput: {taskId: task 1, outputName: out1 1}}
                            op2: 0
                    op2:
                        '==':
                            op1: {taskOutput: {taskId: task 1, outputName: out1 2}}
                            op2: 'head'
'''
        struct = load_yaml(component_text)
        ComponentSpec.from_struct(struct)
    def test_fail_on_cyclic_references(self):
        component_text = '''\
implementation:
  graph:
    tasks:
      task 1:
        componentRef: {name: Comp 1}
        arguments:
            in1 1: {taskOutput: {taskId: task 2, outputName: out2 1}}
      task 2:
        componentRef: {name: Comp 2}
        arguments:
            in2 1: {taskOutput: {taskId: task 1, outputName: out1 1}}
'''
        struct = load_yaml(component_text)
        ComponentSpec.from_struct(struct)
    def test_handle_parsing_task_container_spec_options(self):
        component_text = '''\
implementation:
  graph:
    tasks:
      task 1:
        componentRef: {name: Comp 1}
        k8sContainerOptions:
          resources:
            requests:
              memory: 1024Mi
              cpu: 200m

'''
        struct = load_yaml(component_text)
        component_spec = ComponentSpec.from_struct(struct)
        self.assertEqual(
            component_spec.implementation.graph.tasks['task 1'].
            k8s_container_options.resources.requests['memory'], '1024Mi')
    def test_handle_parsing_task_volumes_and_mounts(self):
        component_text = '''\
implementation:
  graph:
    tasks:
      task 1:
        componentRef: {name: Comp 1}
        k8sContainerOptions:
          volumeMounts:
          - name: workdir
            mountPath: /mnt/vol
        k8sPodOptions:
          spec:
            volumes:
            - name: workdir
              emptyDir: {}
'''
        struct = load_yaml(component_text)
        component_spec = ComponentSpec.from_struct(struct)
        self.assertEqual(
            component_spec.implementation.graph.tasks['task 1'].
            k8s_pod_options.spec.volumes[0].name, 'workdir')
        self.assertTrue(component_spec.implementation.graph.tasks['task 1'].
                        k8s_pod_options.spec.volumes[0].empty_dir is not None)