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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored the loop in the tests by parameterizing #736

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

Conversation

Sherwin-14
Copy link
Contributor

@Sherwin-14 Sherwin-14 commented Jun 30, 2024

I refactored the loop in here. I could only find this one to be refactored. What more could be done here?


馃摎 Documentation preview 馃摎: https://earthaccess--736.org.readthedocs.build/en/736/

@Sherwin-14 Sherwin-14 changed the title Refactored the loop in the tests by parameterzing the test Refactored the loop in the tests by parameterzing Jun 30, 2024
@Sherwin-14 Sherwin-14 changed the title Refactored the loop in the tests by parameterzing Refactored the loop in the tests by parameterizing Jun 30, 2024
for daac in earthaccess.daac.DAACS:
if len(daac["s3-credentials"]) > 0:
try:
logger.info(f"Testing S3 credentials for {daac['short-name']}")
Copy link
Member

Choose a reason for hiding this comment

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

Since the value of daac will be a string, subscript access will throw an error.

Currently integration tests are silently failing, even though they give a green check. It looks like this has been happening for a while. I'm investigating. #737

Once that's fixed, then we can continue to debug this test :)

Copy link
Contributor Author

@Sherwin-14 Sherwin-14 Jun 30, 2024

Choose a reason for hiding this comment

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

Maybe we should wait till then?

Copy link
Member

Choose a reason for hiding this comment

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

#738 resolves the issue, hopefully we can merge the change soon, but even after that there are errors blocking this test from executing. If you are interested, I think some tests need to be refactored to use fixtures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah but which one's need refactoring. If you could provide some info then maybe I can proceed :)

Copy link
Member

Choose a reason for hiding this comment

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

There are a couple refactors we need:

  • Tests which import assertions and call for example assertions.assertTrue(x) should be updated to builtin assertions, for example assert x is True.
  • Tests which do setup at the module level should be updated to use fixtures

I think these should probably be done separately if you want to take them on; the first one would probably be the best place to start IMO because it will give us better error messages.

This test module demonstrates both things I think we're looking to change: https://github.com/nsidc/earthaccess/blob/main/tests/integration/test_onprem_open.py

Perhaps the best place to start though is to see if we already have issues open for this, and if not, create one. If you can help out with that, it would be awesome :)

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 might create an issue but my descriptions are going to pretty vague( I am not good at explaining at all).

Copy link
Member

Choose a reason for hiding this comment

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

The team will be happy to help out :) Thanks @Sherwin-14 !

("ASDC", "LARC_CLOUD"),
),
)
def test_auth_can_fetch_s3_credentials(daac, provider):
Copy link
Member

Choose a reason for hiding this comment

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

We don't need provider here. We can also re-use the pre-existing earthaccess.daac.DAACS constant variable for the data structure instead!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting to use earthaccess.daac.DAACS as the variable from which we can access daac and providers, hence it cuts down the need of having a huge list of parameters ( the ones that I listed above)?

Copy link
Member

Choose a reason for hiding this comment

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

Correct, and also, the test never uses the provider variable, so it can be removed from the arguments and from the parameters in the decorator :)

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

2 participants