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

feature/dq_unit #379

Merged
merged 54 commits into from
Jul 11, 2022
Merged

feature/dq_unit #379

merged 54 commits into from
Jul 11, 2022

Conversation

Ksteeds
Copy link
Contributor

@Ksteeds Ksteeds commented Jun 7, 2022

Commencing Unit Test.

@Ksteeds Ksteeds self-assigned this Jun 7, 2022
@Ksteeds Ksteeds linked an issue Jun 7, 2022 that may be closed by this pull request
@Ksteeds Ksteeds requested a review from lsimonsen June 9, 2022 12:54
@Ksteeds
Copy link
Contributor Author

Ksteeds commented Jun 16, 2022

Constructor removed - mock test still requires updating.

@lsimonsen
Copy link
Member

Need to merge in PR381 or run python -m black on the files for automatic code formatting.

Copy link
Member

@lsimonsen lsimonsen left a comment

Choose a reason for hiding this comment

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

Still a few outstanding items.

macrosynergy/dataquery/api.py Outdated Show resolved Hide resolved
Comment on lines 287 to 297
@classmethod
def jpmaqs_indicators(cls, metrics, tickers):
"""
Functionality used to convert tickers into formal JPMaQS expressions.
"""

dq_tix = []
for metric in metrics:
dq_tix += ["DB(JPMAQS," + tick + f",{metric})" for tick in tickers]

return dq_tix
Copy link
Member

Choose a reason for hiding this comment

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

I believe this one should be a staticmethod and not a classmethod. Class methods returns an instance of the class itself (Interface), using return cls() with some arguments, which instantiates the class .

Copy link
Member

Choose a reason for hiding this comment

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

@Ksteeds still need to convert to a static method or it needs to return an instance of the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted to @staticmethod.

macrosynergy/dataquery/api.py Outdated Show resolved Hide resolved
macrosynergy/dataquery/api.py Outdated Show resolved Hide resolved
macrosynergy/dataquery/api.py Show resolved Hide resolved
macrosynergy/dataquery/api.py Outdated Show resolved Hide resolved
macrosynergy/dataquery/auth.py Outdated Show resolved Hide resolved
tests/unit/dataquery/test_api.py Outdated Show resolved Hide resolved
@Ksteeds Ksteeds requested a review from lsimonsen July 11, 2022 07:33

def test_authentication_error(self):
with Interface(
oauth=True,
client_id="WRONG_CLIENT_ID",
client_secret="NOT_A_SECRET"
) as dq:
with self.assertRaises(RuntimeError, msg="Authentication error - unable to access DataQuery:"):
Copy link
Member

Choose a reason for hiding this comment

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

Re-add msg check, as it looks like it got removed by accident.

@@ -6,23 +6,24 @@


class TestDataQueryOAuth(unittest.TestCase):
def test_connection(self):
Copy link
Member

Choose a reason for hiding this comment

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

Add back in, as it shouldn't be removed

Comment on lines 76 to 78
results: dict = js["errors"][0]
print(f"The corresponding code is: {results['code']}.")
raise ConnectionError(results["description"])
Copy link
Member

Choose a reason for hiding this comment

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

To make it more robust lets change it do:

try:
    results: dict = js["info"]
except KeyError:
    raise ConnectionError(f"DataQuery error response: {js}")

return int(results["code"]) == 200, results

that way we are independent of the structure of js (the response).

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 76 to 78
results: dict = js["errors"][0]
print(f"The corresponding code is: {results['code']}.")
raise ConnectionError(results["description"])
Copy link
Member

Choose a reason for hiding this comment

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

dq_error = f"DataQuery error response: {js}"
raise ConnectionError(dq_error)

@Ksteeds Ksteeds merged commit 93a9d30 into develop Jul 11, 2022
@lsimonsen lsimonsen deleted the feature/dq_unit branch October 10, 2022 09:26
@lsimonsen lsimonsen restored the feature/dq_unit branch October 10, 2022 09:26
@lsimonsen lsimonsen deleted the feature/dq_unit branch October 10, 2022 09:26
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.

DataQuery interface
2 participants