def test_type_input_with_default_value(self):
     expected = {
         "label": "Label",
         "name": "name",
         "type": "STRING",
         "defaultValue": "test"
     }
     self.assertDictEqual(expected,
                          text_input("name", "Label", defaultValue="test"))
示例#2
0
    def test_adding_flow(self):

        def execute_first_step(data):
            pass

        def add_flow_callback(request):
            body = json.loads(request.body)
            self.assertDictEqual(
                body,
                {'instance': {'url': 'http://localhost:5000', 'name': 'testSlims'},
                 'flow':
                    {'id': 'myFlow',
                     'name': 'My flow in python',
                     'usage': 'CONTENT_MANAGEMENT',
                     'steps': [
                         {'hidden': False,
                          'name': 'first step',
                          'input': {'parameters': [{'type': 'STRING', 'name': 'text', 'label': 'Text'}]},
                          'process': {'route': 'myFlow/0', 'asynchronous': False},
                          'output': {'parameters': [{'type': 'FILE', 'name': 'file'}]}
                          }
                     ],
                     'pythonApiFlow': True
                     }
                 })

            return (200, {}, json.dumps({}))

        responses.add_callback(
            responses.POST,
            'http://localhost:9999/rest/external/',
            callback=add_flow_callback,
            content_type='application/json',
        )

        slims = Slims("testSlims", "http://localhost:9999", "admin", "admin")
        slims.add_flow(
            flow_id="myFlow",
            name="My flow in python",
            usage="CONTENT_MANAGEMENT",
            steps=[
                Step(
                    name="first step",
                    action=execute_first_step,
                    input=[
                        text_input("text", "Text")
                    ],
                    output=[
                        file_output()
                    ]
                )
            ],
            testing=True)
示例#3
0
    def test_fail(self):
        def execute_first_step(flow_run):
            raise Exception("went wrong")

        step = Step(name="first step",
                    action=execute_first_step,
                    input=[text_input("text", "Text")],
                    output=[file_output()])

        flow_run = FlowRun(None, None, None)
        flow_run._update_status = MagicMock()
        flow_run.log = MagicMock()

        self.assertRaises(StepExecutionException, step.execute, flow_run)

        flow_run._update_status.assert_called_with(Status.FAILED)
示例#4
0
    def test_success(self):
        def execute_first_step(flow_run):
            print("Do Nothing")

        step = Step(name="first step",
                    action=execute_first_step,
                    input=[text_input("text", "Text")],
                    output=[file_output()])

        flow_run = FlowRun(None, None, {})
        flow_run._update_status = MagicMock()
        flow_run.log = MagicMock()

        step.execute(flow_run)

        flow_run._update_status.assert_called_with(Status.DONE)
 def test_type_input(self):
     expected = {"label": "Label", "name": "name", "type": "STRING"}
     self.assertDictEqual(expected, text_input("name", "Label"))
    "slims",
    "http://127.0.0.1:9999",
    oauth=True,
    client_id="c5d4d038-c918-4fca-bfd4-121e415a433c",
    client_secret=
    "d83a61a9568940f337632873376cf5c47854617bcfdb3d49b9319ac6c82d65b1")
# Whenever SLIMS is not run on the same server as python, local_host="yourIp"
# parameter in Slims() method should be set.

slims.add_flow(
    flow_id="updateContentId",
    name="Update content id",
    usage="CONTENT_MANAGEMENT",
    steps=[
        Step(
            name="Select content to update",
            action=do_nothing,
            input=[
                single_choice_with_value_map_input(
                    "content_to_modify",
                    "Content to modify",
                    "Content",
                    # Persistent will make sure the parameter is also passed
                    # into all the next steps
                    persistent=True)
            ]),
        Step(name="Fill in id",
             action=execute,
             input=[text_input("id", "New ID")])
    ])
示例#7
0
              client_id="c5d4d038-c918-4fca-bfd4-121e415a433c",
              client_secret="d83a61a9568940f337632873376cf5c47854617bcfdb3d49b9319ac6c82d65b1")
# Whenever SLIMS is not run on the same server as python, local_host="yourIp"
# parameter in Slims() method should be set.

slims.add_flow(
    flow_id="updateContentId",
    name="Update content id",
    usage="CONTENT_MANAGEMENT",
    steps=[
        Step(
            name="Select content to update",
            action=do_nothing,
            input=[
                single_choice_with_value_map_input(
                    "content_to_modify",
                    "Content to modify",
                    "Content",
                    # Persistent will make sure the parameter is also passed
                    # into all the next steps
                    persistent=True)
            ]
        ),
        Step(
            name="Fill in id",
            action=execute,
            input=[
                text_input("id", "New ID")
            ]
        )
    ])