Skip to content

Commit 3f5b33e

Browse files
committed
Move run_standalone to VCRIntegrationTest
Signed-off-by: Yves Bastide <yves@botify.com>
1 parent 1bb8b85 commit 3f5b33e

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

tests/integration/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
import os
33

44
import boto.swf
5+
from click.testing import CliRunner
6+
from sure import expect
57
from vcr import VCR
68

79
import simpleflow.command # NOQA
810
from tests.utils import IntegrationTestCase
911

12+
from simpleflow.utils import json_dumps
13+
14+
if False:
15+
from typing import List, Union
16+
from click.testing import Result
17+
18+
1019
# Default SWF parameters
1120
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
1221
os.environ["SWF_DOMAIN"] = "TestDomain"
@@ -70,3 +79,37 @@ def get_events(self, run_id):
7079
events.extend(response['events'])
7180
next_page = response.get('nextPageToken')
7281
return events
82+
83+
def invoke(self, command, arguments):
84+
# type: (str, Union(str, List[str])) -> Result
85+
if not hasattr(self, "runner"):
86+
self.runner = CliRunner()
87+
if isinstance(arguments, str):
88+
arguments = arguments.split(" ")
89+
print('simpleflow {} {}'.format(command, ' '.join(arguments)))
90+
return self.runner.invoke(command, arguments, catch_exceptions=False)
91+
92+
def run_standalone(self, workflow_name, *args, **kwargs):
93+
input = json_dumps(dict(args=args, kwargs=kwargs))
94+
result = self.invoke(
95+
simpleflow.command.cli,
96+
[
97+
"standalone",
98+
"--workflow-id",
99+
str(self.workflow_id),
100+
"--input",
101+
input,
102+
"--nb-deciders",
103+
"2",
104+
"--nb-workers",
105+
"2",
106+
workflow_name,
107+
],
108+
)
109+
expect(result.exit_code).to.equal(0)
110+
lines = result.output.split("\n")
111+
start_line = [line for line in lines if line.startswith(self.workflow_id)][0]
112+
_, run_id = start_line.split(" ", 1)
113+
114+
events = self.get_events(run_id)
115+
return events

tests/integration/test_markers.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,9 @@
1-
import simpleflow.command
2-
from click.testing import CliRunner
31
from sure import expect
42

5-
from simpleflow.utils import json_dumps
63
from tests.integration import VCRIntegrationTest, vcr
74

8-
if False:
9-
from typing import List, Union
10-
from click.testing import Result
11-
125

136
class TestMarkers(VCRIntegrationTest):
14-
def invoke(self, command, arguments):
15-
# type: (str, Union(str, List[str])) -> Result
16-
if not hasattr(self, "runner"):
17-
self.runner = CliRunner()
18-
if isinstance(arguments, str):
19-
arguments = arguments.split(" ")
20-
print('simpleflow {} {}'.format(command, ' '.join(arguments)))
21-
return self.runner.invoke(command, arguments, catch_exceptions=False)
22-
23-
def run_standalone(self, workflow_name, *args, **kwargs):
24-
input = json_dumps(dict(args=args, kwargs=kwargs))
25-
result = self.invoke(
26-
simpleflow.command.cli,
27-
[
28-
"standalone",
29-
"--workflow-id",
30-
str(self.workflow_id),
31-
"--input",
32-
input,
33-
"--nb-deciders",
34-
"2",
35-
"--nb-workers",
36-
"2",
37-
workflow_name,
38-
],
39-
)
40-
expect(result.exit_code).to.equal(0)
41-
lines = result.output.split("\n")
42-
start_line = [line for line in lines if line.startswith(self.workflow_id)][0]
43-
_, run_id = start_line.split(" ", 1)
44-
45-
events = self.get_events(run_id)
46-
return events
47-
487
@vcr.use_cassette
498
def test_without_replays(self):
509
events = self.run_standalone('tests.integration.workflow.MarkerWorkflow', False)

0 commit comments

Comments
 (0)