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

Update API tests to deal with pagination and new options #146

Merged
merged 1 commit into from
Feb 19, 2018
Merged

Conversation

kdelee
Copy link
Contributor

@kdelee kdelee commented Feb 15, 2018

Updates tests to allow the results of listing all credentials or sources to be
paginated. Also updates the equivlancy tests to set proper default values for
ssl_cert_verify and satellite version.

Closes #142

@kdelee kdelee requested a review from elyezer February 15, 2018 19:00
sat_ver = self.options.get('satellite_version', '6.2')
else:
sat_ver = '6.2'
if other.get(key).get('satellite_version') != sat_ver:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is awkward and I'm interested to know if you have suggestion for some other flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any good suggestion right now. The only thing I see is that if other does not have key then it will return None and then will raise AttributeError since None object does not have the get method. I would recommend calling other.get(key, {}).get('satellite_version').

for server_source in server_srcs:
for created_source in created_srcs:
if server_source['id'] == created_source.fields()['id']:
assert_matches_server(created_source)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now will fail on the guilty source

Copy link
Contributor

Choose a reason for hiding this comment

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

This is good but it will only catch the first "invalid" occurrence. What if multiple sources are "invalid"?

I am leaving this as something to think about. I mean we can go with this as the improvement for now, but as a future though I think we should start trying to provide all the problematic instances in the future.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 69.565% when pulling 7d951b3 on issues/142 into 833fea3 on master.

@coveralls
Copy link

coveralls commented Feb 15, 2018

Coverage Status

Coverage remained the same at 69.565% when pulling 7991171 on issues/142 into 833fea3 on master.

Copy link
Contributor

@elyezer elyezer left a comment

Choose a reason for hiding this comment

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

LGTM, left some comments that you may want to handle.

sat_ver = self.options.get('satellite_version', '6.2')
else:
sat_ver = '6.2'
if other.get(key).get('satellite_version') != sat_ver:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have any good suggestion right now. The only thing I see is that if other does not have key then it will return None and then will raise AttributeError since None object does not have the get method. I would recommend calling other.get(key, {}).get('satellite_version').

created_srcs.remove(cp)
server_srcs = Source().list().json()['results']
num_srcs = len(created_srcs)
for server_source in server_srcs:
Copy link
Contributor

Choose a reason for hiding this comment

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

I like having more descriptive names.

for server_source in server_srcs:
for created_source in created_srcs:
if server_source['id'] == created_source.fields()['id']:
assert_matches_server(created_source)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good but it will only catch the first "invalid" occurrence. What if multiple sources are "invalid"?

I am leaving this as something to think about. I mean we can go with this as the improvement for now, but as a future though I think we should start trying to provide all the problematic instances in the future.

@@ -210,6 +210,8 @@ def prep_all_source_scan(cleanup, client, scan_type='inspect'):
hosts=s['hosts'],
credential_ids=[creds[s['credentials'][0]]],
)
if s.get('options', False):
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if src.options will be defined by the constructor above? Even if assigned to None?

Because if it is set to None then this can become a one liner src.options = s.get('options'[, default]) (define default if the default value is different from None

'scan_type': 'connect',
'sources': [153],
'status': 'created'
'id': 21,
Copy link
Contributor

Choose a reason for hiding this comment

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

Four spaces 👍

Updates tests to allow the results of listing all credentials or sources to be
paginated. Also updates the equivlancy tests to set proper default values for
ssl_cert_verify and satellite version.

Closes #142
else:
ssl_verify = True
if other.get(key, {}).get('ssl_cert_verify') != ssl_verify:
return False
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated this RE: your comment

@kdelee
Copy link
Contributor Author

kdelee commented Feb 19, 2018

thanks!

@kdelee kdelee merged commit 990f281 into master Feb 19, 2018
@kdelee kdelee deleted the issues/142 branch February 19, 2018 20:21
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.

3 participants