-
Notifications
You must be signed in to change notification settings - Fork 14
Merge has line #113
Merge has line #113
Conversation
(cherry picked from commit b75d6bd)
We have lots of fixes and improvements on #112, so I'd say let's wait for that other one to be ready and merged, before we go on with this one. I'm not sure how your newer commits in this pull request will play with the other ones after you fix the things I asked you to. |
There are big regressions in this, because of
in |
Merge remote-tracking branch 'remotes/upstream/master' into merge_has_line Conflicts: tests/unit/core/test_roles.py
OK, time to review this pull request now that the previous one merged. I see some problems with it, which I'd like you to fix and improve:
|
As for placing script in additional temp file I didn't think of it, and it is a great idea. As for template inside method I did that at first, but then I had to register_template_loader in I have no ide what to do with these errors:
|
I think I may be able to help you with this. Take a look here: We have a ChoiceLoader, which already has a FileSystemLoader, being setup when provy is run from the command line. So what you need to do is have this loader registered as part of the test, and have that script inside "provy/files/". Just point the loader from your test to "provy/files/" as well, and it will work fine. Let me know if this helps you. |
It makes sense. I'll see to it sometime during next couple of days.
jb:) |
@@ -67,9 +67,15 @@ def __init__(self, prov, context): | |||
context['used_roles'] = {} | |||
if 'roles_in_context' not in context: | |||
context['roles_in_context'] = {} | |||
if not "registered_loaders" in context: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gathered that it would be better to just add needed keys to context, in this case Role wold be ready to work even if started with empty context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get why you're changing these context items here. There's no need to do so, as provy/core/runner.py already does that when it's run from the command line.
If you need to change the context for tests, then change it for tests only, by providing an appropriate context to the role instance in the tests, instead of letting it leak to the production code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bacisally without this lines you coiuldn't write:
role = Role(whatever, {})
because you'll end up with KeyError
raised from register_template_package
. It would totally break Object Oriented Padagrim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, the main loader directory is defined at runtime. This is guaranteed by the application, and even has automated test coverage.
So you can just assume that at runtime it will provide a filesystem loader, with the correct directory, and provide one yourself on your tests. I don't see how it violates any OOP principle. If you want to see this from an OOP point of view, just think of Inversion of Control. ;-)
There is one thing that needs to be discussed: what does |
@@ -0,0 +1 @@ | |||
__author__ = 'jb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
Superseeded by next merge that is way better. |
Here is proposed implementation of
ensure_has_line
that is coircumvents shell escapes problem, but has own limitations (that is: it disallows """ in line).It relies on
execute_python_script
from latter commit, but I posted it as separate pull request.It is tested in the sense that I checked that it works, but I just fixed provy tests that failed because of
register_loader
incore.Role
, and wrote no new tests.It works like that:
What do you think about it?