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

Move search() into the base class ORapi #90

Merged
merged 1 commit into from
Nov 14, 2020
Merged

Conversation

jofegan
Copy link
Contributor

@jofegan jofegan commented Nov 13, 2020

Many classes have their own "search" functions but most of them are
identical so it makes sense to move into the base class and override
the minority that need to behave differently.

Change the unit tests to accommodate that, but also refactor some of
them to avoid reusing the requests_mock object because that can hide
issues where a test is succeeding only because a previous one has
primed the mock for it.

@jofegan
Copy link
Contributor Author

jofegan commented Nov 14, 2020

On reflection I think the basic idea is sound but it's architecturally incorrect to put OpsRamp-specific code into the ApiWrapper class. That and ApiObject form a base layer that is applicable to any REST api and it would be wrong to break that.

Instead, I will look at introducing an intermediate base class called something like ORapi derived from ApiWrapper, move search into that class, and make the others subclasses of ORapi instead of directly from ApiWrapper.

Many classes have their own "search" functions but most of them are
identical so it makes sense to move into the base class and override
the minority that need to behave differently.

Change the unit tests to accommodate that, but also refactor some of
them to avoid reusing the requests_mock object because that can hide
issues where a test is succeeding only because a previous one has
primed the mock for it.
@jofegan jofegan changed the title Move search() into the base class ApiWrapper Move search() into the base class ORapi Nov 14, 2020
@jofegan jofegan merged commit 9b20ba3 into master Nov 14, 2020
@jofegan jofegan deleted the refactor-search-functions branch November 14, 2020 17:51
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

1 participant