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 unit and functional tests of the SAL client #70

Merged
merged 22 commits into from
Mar 17, 2021
Merged

Conversation

TOFarmer
Copy link
Contributor

@TOFarmer TOFarmer commented Feb 22, 2021

Description of work

Add unit and functional tests of the SAL client using pytest.

All tests are documented using GIVEN-WHEN-THEN, and I would recommend this approach is used for all future tests.

All tests which are marked as expected fails have corresponding issues:

Fixes

Fixes #65

To test

  • Run tests to confirm that they pass or are expected failures.

Reviewer checklist

  • The author suggested tests are successful.
  • Relevant documentation (user and developer) has been added, and is clear and complete.
  • Suitable unit tests have been added. If unit tests are not included in this MR, please comment as to why and create an issue to address this.

@TOFarmer TOFarmer added Priority: 3 IMPORTANT: The typical top priority, describes what should be worked on next in most cases. Testing Related to additional tests required labels Feb 22, 2021
@TOFarmer TOFarmer changed the title Tests client Add unit and functional tests of the SAL client Feb 22, 2021
WHEN
A client performs a get operation
THEN
The client returns either a Branch or a DataObject
Copy link
Contributor

Choose a reason for hiding this comment

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

question: The actual test client only returns a Branch, and only a Branch is ever checked for. Is this specification overbroad, or is the test not fully implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I must have forgotten to add the parametrization for testing a DataObject. I've done so using a Scalar and I've also added the same type of parametrization for list and put, as these both really should apply to both the contents of branches and leaves, and there are minor differences in how the SALClient handles this.

WHEN
The client performs a copy operation from a source to a target
THEN
A POST request
Copy link
Contributor

Choose a reason for hiding this comment

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

question: What does the POST request do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, I think this one had been left incomplete. I've updated it.

Comment on lines 75 to 85
'host': 'https://sal.testing/',
'api': {'version': 2,
'requires_auth': True,
'resources': ['data', 'auth'],
'classes': {'core': ['dictionary',
'scalar',
'string',
'array']}},
'service': {'name': 'Simple Access Layer (SAL) Server',
'version': '1.2.2'},
'request': {'url': 'https://sal.testing/'}}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: https://sal.testing is hard-coded twice in this fixture, would it be possible to use the host fixture 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.

Thanks, changed.

Comment on lines 147 to 148
cred_file = {'https://sal.testing': {'user': UN,
'password': PW}}
Copy link
Contributor

@thomassclayton thomassclayton Mar 17, 2021

Choose a reason for hiding this comment

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

suggestion: As in conftest.py, the host address is hard coded; the fixture could be used instead.

This situation occurs twice more in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, changed all three.

The client raises a ConnectionError
"""

server_root_response.json.return_value['api']['version'] = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

suggeston: Instead of hard coding the future API version, would it be possible to get the current version and just add one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I've implemented this.

Copy link
Contributor

@thomassclayton thomassclayton 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, I just have a few minor questions and suggestions before merging.

@TOFarmer TOFarmer merged commit b6b3b32 into master Mar 17, 2021
@TOFarmer TOFarmer deleted the tests_client branch March 17, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 3 IMPORTANT: The typical top priority, describes what should be worked on next in most cases. Testing Related to additional tests required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests of SAL client
2 participants