-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add tests for cleanse #5499
Add tests for cleanse #5499
Conversation
One idea:
Note that even a simple fake image has two files: the .fake and the import log. Could test each. |
self.args += [data_dir] | ||
self.cli.invoke(self.args, strict=True) | ||
out, err = capsys.readouterr() | ||
output_string = "Removing empty directories from...\n " + data_dir + "ManagedRepository\n" |
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.
See what the actual cleanse
method does with client.getManagedRepository(description=True)
flake8 issues
|
Following on from conversation, some useful tips may include,
However,
query_service = client.sf.getQueryService()
update_service = client.sf.getUpdateService()
|
@mtbc : I am afraid that the test as suggested by you in #5499 (comment) is not passing. If the cleanse would really remove the file from the ManagedRepository, then this line 4d69e5d#diff-1d5c6c10d23d75593370d2d5806c17bcR112 would be failing. But it passes. Verified also manually - simply re-run the cleanse after the test finished, whilst checking that the name in the OrigiinalFile table is still showing "nonsensical" and then looking for the file on the filesystem -> the file is still there. |
My apologies, I am probably wrong about what "cleanse" actually does, I am usually not very sure; @joshmoore may wish to weigh in. Too many of my attempts to help you with Python tests are but guesswork. |
And the test passed on CI as well, indicating that the cleanse is not doing what we think it is doing https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-merge-integration-python/lastCompletedBuild/testReport/OmeroPy.test.integration.clitest.test_cleanse/TestCleanseRoot/ |
@mtbc : no need to apologize, this is the part of the testing (getting the feature described correctly) :) |
Manual testing:
the filesetentry and the corresponding originalfile deleted from the DB successfully.
|
@mtbc @joshmoore : this is what I intended to do here on the cleanse test according to the brief. Are more tests desirable ? |
As mentioned in chat, happy for this to go in as is or see the addition of light admin tests before merging. |
@pwalczysko do you think you will be able to add the test for lightadmin tomorrow? |
Should be doable, did some prep yesterday evening. |
ca00eaa
to
9f79786
Compare
@jburel @joshmoore : test for Restricted Admins added |
Ready for review. |
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.
Few minor comments added. Happy for any/all to be addressed later.
As an aside, I did spend some time trying to figure out why this is the current behavior, but I haven't yet gotten to the bottom of it. That being said, happy to have a passing test to describe what needs figuring out.
# default value None makes the new user to Full Admin | ||
# For Restricted Admin with no privileges, set the value to [] | ||
# Can be overriden by test instances | ||
DEFAULT_PRIVILEGES = None |
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.
This is a very well-done test feature. Thank you!
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.
One point though: it is better to use ()
(which is immutable) rather than []
so that subclasses cannot modify the value and cause confusion.
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.
You can blame me for that one, I know little more Python than @pwalczysko. 😃
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.
@joshmoore : Not sure I understand now, in your second comment here you suggested to use round brackets instead of square brackets. Which I implemented. Your commit now seem to revert on this chenge ? Or is there some granularity (doc vs non-doc) which I am missing ?
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.
Apologies, I was trying to correct another line while preparing for a call and inadvertently changed this one. Give me just a bit to try to correct my mistake.
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.
Force pushed the correction. Please let me know what you think.
assert err.endswith("SecurityViolation: Admins only!\n") | ||
|
||
|
||
class TestCleanseRoot(RootCLITest): |
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.
For comparison, this might could/should be TestCleanFullAdmin
and use DEFAULT_PRIVILEGES = None
self.args += ["admin", "cleanse"] | ||
self.group_ctx = {'omero.group': str(self.group.id.val)} | ||
config_service = self.root.sf.getConfigService() | ||
self.mrepo_dir = config_service.getConfigValue("omero.managed.dir") |
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.
A next step here (5.4.1+) should be to check if the test is running locally to this directory and xfail
or skip_if
. This could be done in a base class and made available to all tests: self.is_local_to_server()
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.
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.
Added this point to https://trello.com/c/3gBK3okF/51-integration-test-for-bin-omero-admin-cleanse (last unchecked point on the checklist)
This should address the comments of @joshmoore except #5499 (comment) which was carded #5499 (comment). Ready for re-review. |
599e1bc
to
a0dfa53
Compare
@@ -538,7 +538,7 @@ def new_user(cls, group=None, perms=None, | |||
:system: If user is to be a system group member | |||
:privileges: If system group member is to have privileges | |||
privileges=None gives all privileges (full admin) | |||
privileges=[] gives no privileges | |||
privileges=() gives no privileges |
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.
Yes, that is how it should be, consistent. I forgot about this one, thank you @joshmoore
👍 Happy to follow-up the local issues. Many thanks, @pwalczysko |
I missed the details of this test PR and especially the Seconding #5499 (comment) and following a discussion @pwalczysko last week, an immediate implication is that we might be able to simplify the current complexity of the CLI test classes hierarchy as follows:
|
What this PR does
Adds tests for
bin/omero admin cleanse
command on CLI.Atm,4 tests are added, "admin-only" when the executor of the command is not an admin, and a successful execution of the command for root with expected ending of the output checked.
Also, a more detailed test of functionality (checking that a file and directory were really removed, and Restricted Admin test as well were added.
See https://trello.com/c/3gBK3okF/752-integration-test-for-bin-omero-admin-cleanse
and https://trello.com/c/vsLBC6Aq/35-define-additional-markers-for-local-tests
As discussed, we can attempt to merge this PR, so putting for review for tomorrow.
@joshmoore @mtbc @sbesson
Ready for review