Skip to content
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 initial unit tests for gateway.py #253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gnuoy
Copy link
Contributor

@gnuoy gnuoy commented Feb 23, 2022

Add some intial unit tests to gateway.py

@gnuoy gnuoy changed the title Add initial unit tests for gateway Add initial unit tests for gateway.py Feb 23, 2022
return self.run_ceph_mock_return.pop()

@mock.patch.object(gateway.subprocess, 'check_output')
def test__run_ceph_cmd(self, check_output):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/test__run_ceph_cmd/test_run_ceph_cmd/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method being tested starts with an underscore _run_ceph_cmd . Hence the double underscore in the test name. I'm happy to change the test name though if you'd prefer test_run_ceph_cmd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, please.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the same time could update the README to give some explaination and a example for the test ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lxbsz, thank you for the review. I can't think what would be relevant to put in the README since this PR is just adding some unit tests or are you suggesting I add doc strings to the tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am how to run the test. You need to update the exact command and what should others do to run the test.

Such as the Curl Examples:.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the README was aimed at users who want to install, configure and use ceph-iscsi. The Curl Examples in the README is aimed at users who want to interact with the api via curl. Running unit tests seems to me to only be of interest to developers. Having said that I could add something like

diff --git a/README b/README
index fe32bd2..b0c7455 100644
--- a/README
+++ b/README
@@ -135,3 +135,9 @@ here:
 http://docs.ceph.com/docs/master/rbd/iscsi-target-cli/
 
 can be used to create a iscsi-gateway.cfg and create a target.
+
+## Running Unit Tests
+
+The unit tests for ceph-isci can be run with:
+
+```tox -e py3```

Is that the sort of thing you are looking for?

@gnuoy gnuoy force-pushed the add-gateway-unit-tests branch from 9d697e1 to de69fff Compare March 21, 2022 06:40
Add some intial unit tests to gateway.py
@gnuoy gnuoy force-pushed the add-gateway-unit-tests branch from de69fff to 9e89d4b Compare April 26, 2022 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants