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

DM-35039: Add tests for CfhtIsrTask to obs_cfht #107

Merged
merged 2 commits into from Oct 14, 2022
Merged

Conversation

czwa
Copy link
Contributor

@czwa czwa commented Oct 10, 2022

Add unit test coverage for CfhtIsrTask.

testDataDirectory = lsst.utils.getPackageDir(testDataPackage)
except LookupError as e:
warnings.warn(e.args[0])
raise unittest.SkipTest("Skipping tests as testdata_cfht is not setup")
Copy link
Member

Choose a reason for hiding this comment

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

Normally we'd ask for the test data package in the preamble and use a unittest.skipIf decorator around the entire test class. This is more efficient than having every test run the same code that will always fail.

detector = self.camera[0]

# Get the override.
self.configPath = os.path.join(lsst.utils.getPackageDir("obs_lsst"), "config",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be depending on obs_lsst in this test.

Copy link
Member

@arunkannawadi arunkannawadi left a comment

Choose a reason for hiding this comment

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

Looks good overall, Chris! Just suggested some minor modifications.

@@ -0,0 +1,140 @@
#
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the blank line in the beginning is required.

self.assertEqual(md['RDNOISEA'], amplifiers[0].getReadNoise())
self.assertEqual(md['RDNOISEB'], amplifiers[1].getReadNoise())

def imageHandler(self, location, detector=None):
Copy link
Member

Choose a reason for hiding this comment

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

This should perhaps be a staticmethod, since none of self's attributes are used. Also, this could go either before or after setUp(Class) method, in case we want to add additional tests later.

class CfhtIsrTestCase(lsst.utils.tests.TestCase):
"""Test for the CFHT IsrTask wrapper."""

def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

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

Since there's only one test case, it doesn't make any difference now, but if you foresee other test cases making use of the exposure and camera attributes, make it a setUpClass method so that it doesn't have to read in the images for every test case.

@czwa czwa merged commit 3b3c578 into main Oct 14, 2022
@czwa czwa deleted the tickets/DM-35039 branch October 14, 2022 17:27
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.

None yet

3 participants