Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thilp committed Jun 5, 2020
1 parent 5d73935 commit 2599b5f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
60 changes: 40 additions & 20 deletions tests/transformer/test_locust.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,35 @@ def test_it_renders_a_locustfile_template(self):
# File automatically generated by Transformer v{__version__}:
# https://github.com/zalando-incubator/Transformer
import re
import sys
from distutils.version import LooseVersion
from locust import __version__
if LooseVersion(__version__) >= LooseVersion('1.0.0'):
print(f'Sorry! You have locust=={{__version__}},', "but Transformer doesn't support locust>=0.99 yet.", 'Please try again with a less recent Locust version', '(e.g. "pip install \\'locustio==0.14.6\\'")', 'while we are working on a long-term solution. 😊', file=sys.stderr)
exit(1)
from locust import HttpLocust
from locust import TaskSequence
from locust import TaskSet
from locust import seq_task
from locust import task
LOCUST_MAJOR_VERSION = LooseVersion(__version__).version[0]
if LOCUST_MAJOR_VERSION >= 1:
from locust import HttpUser
from locust import SequentialTaskSet
from locust import TaskSet
from locust import task
HttpLocust = HttpUser
TaskSequence = SequentialTaskSet
def seq_task(_):
return task
else:
from locust import HttpLocust
from locust import TaskSequence
from locust import TaskSet
from locust import seq_task
from locust import task
class ScenarioGroup(TaskSet):
@task(1)
class SomeScenario(TaskSequence):
@seq_task(1)
def some_task(self):
response = self.client.get(url='some_url', name='some_url', timeout=$TIMEOUT, allow_redirects=False, headers={{'a': 'b'}})
class LocustForScenarioGroup(HttpLocust):
task_set = ScenarioGroup
if LOCUST_MAJOR_VERSION >= 1:
tasks = [ScenarioGroup]
else:
task_set = ScenarioGroup
weight = 2
min_wait = 0
max_wait = 10
Expand Down Expand Up @@ -92,25 +102,35 @@ def plugin_change_task_name(t: Task2) -> Task2:
# File automatically generated by Transformer v{__version__}:
# https://github.com/zalando-incubator/Transformer
import re
import sys
from distutils.version import LooseVersion
from locust import __version__
if LooseVersion(__version__) >= LooseVersion('1.0.0'):
print(f'Sorry! You have locust=={{__version__}},', "but Transformer doesn't support locust>=0.99 yet.", 'Please try again with a less recent Locust version', '(e.g. "pip install \\'locustio==0.14.6\\'")', 'while we are working on a long-term solution. 😊', file=sys.stderr)
exit(1)
from locust import HttpLocust
from locust import TaskSequence
from locust import TaskSet
from locust import seq_task
from locust import task
LOCUST_MAJOR_VERSION = LooseVersion(__version__).version[0]
if LOCUST_MAJOR_VERSION >= 1:
from locust import HttpUser
from locust import SequentialTaskSet
from locust import TaskSet
from locust import task
HttpLocust = HttpUser
TaskSequence = SequentialTaskSet
def seq_task(_):
return task
else:
from locust import HttpLocust
from locust import TaskSequence
from locust import TaskSet
from locust import seq_task
from locust import task
class ScenarioGroup(TaskSet):
@task(1)
class SomeScenario(TaskSequence):
@seq_task(1)
def some_task(self):
response = self.client.get(url='some_url', name='changed_name', timeout=$TIMEOUT, allow_redirects=False, headers={{'a': 'b'}})
class LocustForScenarioGroup(HttpLocust):
task_set = ScenarioGroup
if LOCUST_MAJOR_VERSION >= 1:
tasks = [ScenarioGroup]
else:
task_set = ScenarioGroup
weight = 2
min_wait = 0
max_wait = 10
Expand Down
2 changes: 1 addition & 1 deletion transformer/builders_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ascii_text(min_size: int = 0, max_size: Optional[int] = 5) -> SearchStrategy


def ascii_inline_text(
min_size: int = 0, max_size: Optional[int] = 5
min_size: int = 0, max_size: Optional[int] = 3
) -> SearchStrategy[str]:
"""Similar to ascii_text, but does not generate multiline strings."""
return text(_ascii_inline, min_size=min_size, max_size=max_size)
Expand Down

0 comments on commit 2599b5f

Please sign in to comment.