New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests : User Tracker creation of user with minimal values #181
Conversation
| @@ -76,6 +76,7 @@ def __init__(self, default_version=None): | |||
| self.api = api | |||
| self.default_version = default_version or API_VERSION | |||
| self._dn = None | |||
| self.attrs = {} | |||
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 do not create conflict with PR #148
ba7fce8
to
27d87c9
Compare
27d87c9
to
e568990
Compare
|
The same minimal values apply for stageuser-add command, can you please modify the stageuser tracker as well? Also adding testcases for these changes would be nice. |
|
Yes, It's a valid point to add testcases for these changes . Will do. Thank you. |
e568990
to
66376aa
Compare
|
Having "None" default values for obligatory arguments does not seem to be a good idea. If the method was called with default values, it would fail. It would be best if obligatory arguments ("givenname" and "sn") were provided as positional arguments and voluntary "name" as keyword argument. Please note that such a change will cause failure of existing tests that use this tracker, therefore it's necessary to fix them as well - include this in separate commit of this PR. Also please don't forget to add testcases for which this PR was created originally - creating user without the "name" argument (both positive and negative testcases). |
|
I think in this case we can go with keyword arguments only. Most of the uses of the tracker in the tests do it already. What I will need in the case of keyword arguments is an explicit check for some non-empty unicode string for the required attributes in the init method. All of this applies to |
66376aa
to
6560828
Compare
| in the init method """ | ||
|
|
||
| if not isinstance(givenname, (str, unicode)) and len(givenname) > 0: | ||
| raise ValueError("No name provided: %s" % givenname) |
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 condition does not fit the description, it should contain some more parentheses:
if not (isinstance(givenname, (str, unicode)) and len(givenname) > 0):
Also you can use 'basestring' instead of '(str, unicode)'.
Please change the error message so that it would unambiguously tell which value is incorrect (e.g. "No or invalid first name provided").
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.
basestringdoesn't work with Py3, please usesix.string_types- I agree with @mirielka the if statement looks suspicious
- please use
and givennameinstead ofand len(givenname) > 0, empty string is automaticallyFalse - please use
%rin error message to get more information about object
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.
Thank you for review, will check it and do required changes.
| if not isinstance(givenname, (str, unicode)) and len(givenname) > 0: | ||
| raise ValueError("No name provided: %s" % givenname) | ||
| if not isinstance(sn, (str, unicode)) and len(sn) > 0: | ||
| raise ValueError("No name provided: %s" % sn) |
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.
same as above
|
Please check inline comments. Also suggestion for more test cases:
|
79a9b65
to
b0d51d7
Compare
|
Bump for review. |
|
PR needs rebase |
|
Then, @stlaz must give final ACK |
|
The changes introduce different behavior than in the previous change where repr() of the given strings would have been printed. To have repr() of the given string, use '{!r}' instead of '{}' in string format if that is what's desired. CondACK if it's not but please tell :) Same for #210 |
|
Yes, the intention was to have repr() of the given string , so I'll use ''{!r} instead of '{}', and apply that change to #210 also. Thank you. |
|
Thank you for the changes! |
|
Thank you for review! |
|
This PR still needs rebase, it is not possible to apply patch without 3way merge, please pull the latest master and do rebase, we merge only patches that can be merged without 3-way merge |
Fix provide possibility to create user-add test with minimal values, where uid is not specified, to provide better coverage. Also provide check for non-empty unicode string for attributes required in init method https://fedorahosted.org/freeipa/ticket/6126
Test to create user with minimal values, where uid is not specified https://fedorahosted.org/freeipa/ticket/6126
|
@mbasti-rh done. hope now it's fine |
|
@gkaihorodova you haven't pushed the changes to github repo |
7205d9f
to
43ee2ff
Compare
Fix provide possibility to create user-add test with minimal values,
where uid is not specified, to provide better coverage
https://fedorahosted.org/freeipa/ticket/6126