turq icon indicating copy to clipboard operation
turq copied to clipboard

multi-rule files in start turq

Open XiaoboHe opened this issue 8 years ago • 9 comments

Hi vfaronov,

I just wonder how to start turq with multi-rule files? Thanks!

I start turq with command in the following, may be it is not supported.

# data is dir, and some rule files in it
# start turq with rule dir
turq --no-editor --rules /data/

# start truq with fuzzy style
turq --no-editor --rules /data/*.py

XiaoboHe avatar May 24 '17 09:05 XiaoboHe

Hi! This is currently not supported. You need to put all initial rules into one file.

Is there any specific reason why you need multiple files in your situation?

vfaronov avatar May 24 '17 13:05 vfaronov

in case, if there is a large number of mock interfaces which are provided different applications, how to manage the single config file with large size?

In my opinion, mock can be configured in diff files by diff dimensions.

XiaoboHe avatar May 25 '17 12:05 XiaoboHe

You can work around this with your shell. For example, this works in Bash:

turq --no-editor --rules <( cat /data/*.py )

But maybe you’re right and Turq should be able to handle this by itself. I will think about this for the next version.

vfaronov avatar May 25 '17 19:05 vfaronov

Hello vfaronov,

What about making imports in the rules file? Assuming the rules / file.py file The instruction: import rules.file

Thank you.

wlyssespereira avatar May 02 '18 15:05 wlyssespereira

@wlyssespereira This will not work, because Turq rules are executed in a special Python scope (all the magic names like route and GET), which is unavailable to the module being imported.

vfaronov avatar May 02 '18 17:05 vfaronov

Hello again vfaronov,

I made a little technical adjustment to solve this problem. Follow the code:

wlyssespereira avatar May 02 '18 18:05 wlyssespereira

@wlyssespereira Thank you for your suggestion. But I don’t think messing with imports is a good idea for Turq. Above I showed how to load multiple Python files into Turq. If you need something more complex or strange, such as different modules, it’s likely that Turq just isn’t for you.

vfaronov avatar May 02 '18 19:05 vfaronov

@vfaronov, I fully agree, thank you very much for the attention and congratulations for the project.

wlyssespereira avatar May 02 '18 19:05 wlyssespereira