{"action":"created","comment":{"url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/comments/254242199","pull_request_review_id":200539072,"id":254242199,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1NDI0MjE5OQ==","diff_hunk":"@@ -0,0 +1,212 @@\n+import unittest\n+import requests\n+import json\n+import uuid\n+import os\n+from datetime import datetime\n+import pytz\n+import lusid\n+import lusid.models as models\n+from unittest import TestCase\n+from collections import namedtuple\n+from msrest.authentication import BasicTokenAuthentication\n+from time import sleep\n+from TestDataUtilities import TestDataUtilities\n+from InstrumentLoader import InstrumentLoader\n+\n+try:\n+    # Python 3.x\n+    from urllib.request import pathname2url\n+except ImportError:\n+    # Python 2.7\n+    from urllib import pathname2url\n+\n+\n+class TestFinbourneApi(TestCase):\n+    client = None\n+    effective_date = datetime(2018, 1, 1, tzinfo=pytz.utc)\n+\n+    @classmethod\n+    def setUpClass(cls):\n+\n+        cls.ISIN_PROPERTY_KEY = \"Instrument/default/Isin\"\n+        cls.SEDOL_PROPERTY_KEY = \"Instrument/default/Sedol\"\n+        cls.FIGI_SCHEME = \"Figi\"\n+        cls.CUSTOM_INTERNAL_SCHEME = \"ClientInternal\"\n+        cls.GROUPBY_KEY = \"Instrument/default/Name\"\n+        cls.AGGREGATION_KEY = \"Holding/default/PV\"\n+        cls.sorted_instrument_ids = []\n+\n+        # Load our configuration details from the environment variables\n+        token_url = os.getenv(\"FBN_TOKEN_URL\", None)\n+        cls.api_url = os.getenv(\"FBN_LUSID_API_URL\", None)\n+        username = os.getenv(\"FBN_USERNAME\", None)\n+        password_raw = os.getenv(\"FBN_PASSWORD\", None)\n+        client_id_raw = os.getenv(\"FBN_CLIENT_ID\", None)\n+        client_secret_raw = os.getenv(\"FBN_CLIENT_SECRET\", None)\n+\n+        # If any of the environmental variables are missing use a local secrets file\n+        if token_url is None or username is None or password_raw is None or client_id_raw is None \\\n+                or client_secret_raw is None or cls.api_url is None:\n+\n+            dir_path = os.path.dirname(os.path.realpath(__file__))\n+            with open(os.path.join(dir_path, \"secrets.json\"), \"r\") as secrets:\n+                config = json.load(secrets)\n+\n+            token_url = os.getenv(\"FBN_TOKEN_URL\", config[\"api\"][\"tokenUrl\"])\n+            username = os.getenv(\"FBN_USERNAME\", config[\"api\"][\"username\"])\n+            password = pathname2url(os.getenv(\"FBN_PASSWORD\", config[\"api\"][\"password\"]))\n+            client_id = pathname2url(os.getenv(\"FBN_CLIENT_ID\", config[\"api\"][\"clientId\"]))\n+            client_secret = pathname2url(os.getenv(\"FBN_CLIENT_SECRET\", config[\"api\"][\"clientSecret\"]))\n+            cls.api_url = os.getenv(\"FBN_LUSID_API_URL\", config[\"api\"][\"apiUrl\"])\n+\n+        else:\n+            password = pathname2url(password_raw)\n+            client_id = pathname2url(client_id_raw)\n+            client_secret = pathname2url(client_secret_raw)\n+\n+        # Prepare our authentication request\n+        token_request_body = (\"grant_type=password&username={0}\".format(username) +\n+                              \"&password={0}&scope=openid client groups\".format(password) +\n+                              \"&client_id={0}&client_secret={1}\".format(client_id, client_secret))\n+        headers = {\"Accept\": \"application/json\", \"Content-Type\": \"application/x-www-form-urlencoded\"}\n+\n+        # Make our authentication request\n+        okta_response = requests.post(token_url, data=token_request_body, headers=headers)\n+\n+        # Ensure that we have a 200 response code\n+        assert okta_response.status_code == 200\n+\n+        # Retrieve our api token from the authentication response\n+        cls.api_token = {\"access_token\": okta_response.json()[\"access_token\"]}\n+\n+        # Initialise our API client using our token so that we can include it in all future requests\n+        credentials = BasicTokenAuthentication(cls.api_token)\n+        cls.client = lusid.LUSIDAPI(credentials, cls.api_url)\n+\n+        # Create and load in instruments\n+        cls.inst_loader = InstrumentLoader()\n+        cls.instrument_ids = cls.inst_loader.load_instruments(cls.client)\n+        # sort the instruments by name to match the aggregation ordering later. create LUID/name pairs dict\n+        luids_to_sort = {}\n+        for instrument in cls.instrument_ids.values:\n+            luids_to_sort[cls.instrument_ids.values[instrument].lusid_instrument_id] = cls.instrument_ids.values[instrument].name","path":"lusid-sdk-python/tests/test_aggregation.py","position":93,"original_position":93,"commit_id":"231eb1b2e0833e7b46f25af9e180265739a6b917","original_commit_id":"231eb1b2e0833e7b46f25af9e180265739a6b917","user":{"login":"gsekhon1","id":35544293,"node_id":"MDQ6VXNlcjM1NTQ0Mjkz","avatar_url":"https://avatars1.githubusercontent.com/u/35544293?v=4","gravatar_id":"","url":"https://api.github.com/users/gsekhon1","html_url":"https://github.com/gsekhon1","followers_url":"https://api.github.com/users/gsekhon1/followers","following_url":"https://api.github.com/users/gsekhon1/following{/other_user}","gists_url":"https://api.github.com/users/gsekhon1/gists{/gist_id}","starred_url":"https://api.github.com/users/gsekhon1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsekhon1/subscriptions","organizations_url":"https://api.github.com/users/gsekhon1/orgs","repos_url":"https://api.github.com/users/gsekhon1/repos","events_url":"https://api.github.com/users/gsekhon1/events{/privacy}","received_events_url":"https://api.github.com/users/gsekhon1/received_events","type":"User","site_admin":false},"body":"prettied","created_at":"2019-02-06T11:57:57Z","updated_at":"2019-02-06T11:57:57Z","html_url":"https://github.com/finbourne/lusid-sdk-python/pull/17#discussion_r254242199","pull_request_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/comments/254242199"},"html":{"href":"https://github.com/finbourne/lusid-sdk-python/pull/17#discussion_r254242199"},"pull_request":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17"}},"in_reply_to_id":253483016},"pull_request":{"url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17","id":248526178,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQ4NTI2MTc4","html_url":"https://github.com/finbourne/lusid-sdk-python/pull/17","diff_url":"https://github.com/finbourne/lusid-sdk-python/pull/17.diff","patch_url":"https://github.com/finbourne/lusid-sdk-python/pull/17.patch","issue_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/17","number":17,"state":"open","locked":false,"title":"Integration tests","user":{"login":"gsekhon1","id":35544293,"node_id":"MDQ6VXNlcjM1NTQ0Mjkz","avatar_url":"https://avatars1.githubusercontent.com/u/35544293?v=4","gravatar_id":"","url":"https://api.github.com/users/gsekhon1","html_url":"https://github.com/gsekhon1","followers_url":"https://api.github.com/users/gsekhon1/followers","following_url":"https://api.github.com/users/gsekhon1/following{/other_user}","gists_url":"https://api.github.com/users/gsekhon1/gists{/gist_id}","starred_url":"https://api.github.com/users/gsekhon1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsekhon1/subscriptions","organizations_url":"https://api.github.com/users/gsekhon1/orgs","repos_url":"https://api.github.com/users/gsekhon1/repos","events_url":"https://api.github.com/users/gsekhon1/events{/privacy}","received_events_url":"https://api.github.com/users/gsekhon1/received_events","type":"User","site_admin":false},"body":"combined integration testing files","created_at":"2019-01-29T14:27:41Z","updated_at":"2019-02-06T11:57:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4bba7f061bf27bdab65646c20001c95536e0634","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17/commits","review_comments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17/comments","review_comment_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/17/comments","statuses_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/statuses/231eb1b2e0833e7b46f25af9e180265739a6b917","head":{"label":"finbourne:integration_tests","ref":"integration_tests","sha":"231eb1b2e0833e7b46f25af9e180265739a6b917","user":{"login":"finbourne","id":22306292,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzA2Mjky","avatar_url":"https://avatars3.githubusercontent.com/u/22306292?v=4","gravatar_id":"","url":"https://api.github.com/users/finbourne","html_url":"https://github.com/finbourne","followers_url":"https://api.github.com/users/finbourne/followers","following_url":"https://api.github.com/users/finbourne/following{/other_user}","gists_url":"https://api.github.com/users/finbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/finbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finbourne/subscriptions","organizations_url":"https://api.github.com/users/finbourne/orgs","repos_url":"https://api.github.com/users/finbourne/repos","events_url":"https://api.github.com/users/finbourne/events{/privacy}","received_events_url":"https://api.github.com/users/finbourne/received_events","type":"Organization","site_admin":false},"repo":{"id":125082278,"node_id":"MDEwOlJlcG9zaXRvcnkxMjUwODIyNzg=","name":"lusid-sdk-python","full_name":"finbourne/lusid-sdk-python","private":false,"owner":{"login":"finbourne","id":22306292,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzA2Mjky","avatar_url":"https://avatars3.githubusercontent.com/u/22306292?v=4","gravatar_id":"","url":"https://api.github.com/users/finbourne","html_url":"https://github.com/finbourne","followers_url":"https://api.github.com/users/finbourne/followers","following_url":"https://api.github.com/users/finbourne/following{/other_user}","gists_url":"https://api.github.com/users/finbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/finbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finbourne/subscriptions","organizations_url":"https://api.github.com/users/finbourne/orgs","repos_url":"https://api.github.com/users/finbourne/repos","events_url":"https://api.github.com/users/finbourne/events{/privacy}","received_events_url":"https://api.github.com/users/finbourne/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/finbourne/lusid-sdk-python","description":"LUSID Python SDK","fork":false,"url":"https://api.github.com/repos/finbourne/lusid-sdk-python","forks_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/forks","keys_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/teams","hooks_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/hooks","issue_events_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/events{/number}","events_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/events","assignees_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/assignees{/user}","branches_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/branches{/branch}","tags_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/tags","blobs_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/statuses/{sha}","languages_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/languages","stargazers_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/stargazers","contributors_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/contributors","subscribers_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/subscribers","subscription_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/subscription","commits_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/contents/{+path}","compare_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/merges","archive_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/downloads","issues_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues{/number}","pulls_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls{/number}","milestones_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/milestones{/number}","notifications_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/labels{/name}","releases_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/releases{/id}","deployments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/deployments","created_at":"2018-03-13T16:31:54Z","updated_at":"2019-02-04T15:49:50Z","pushed_at":"2019-02-04T17:37:13Z","git_url":"git://github.com/finbourne/lusid-sdk-python.git","ssh_url":"git@github.com:finbourne/lusid-sdk-python.git","clone_url":"https://github.com/finbourne/lusid-sdk-python.git","svn_url":"https://github.com/finbourne/lusid-sdk-python","homepage":null,"size":1117,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"finbourne:master","ref":"master","sha":"403a86c46d0ccb257188dc4e276a47647721023b","user":{"login":"finbourne","id":22306292,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzA2Mjky","avatar_url":"https://avatars3.githubusercontent.com/u/22306292?v=4","gravatar_id":"","url":"https://api.github.com/users/finbourne","html_url":"https://github.com/finbourne","followers_url":"https://api.github.com/users/finbourne/followers","following_url":"https://api.github.com/users/finbourne/following{/other_user}","gists_url":"https://api.github.com/users/finbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/finbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finbourne/subscriptions","organizations_url":"https://api.github.com/users/finbourne/orgs","repos_url":"https://api.github.com/users/finbourne/repos","events_url":"https://api.github.com/users/finbourne/events{/privacy}","received_events_url":"https://api.github.com/users/finbourne/received_events","type":"Organization","site_admin":false},"repo":{"id":125082278,"node_id":"MDEwOlJlcG9zaXRvcnkxMjUwODIyNzg=","name":"lusid-sdk-python","full_name":"finbourne/lusid-sdk-python","private":false,"owner":{"login":"finbourne","id":22306292,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMzA2Mjky","avatar_url":"https://avatars3.githubusercontent.com/u/22306292?v=4","gravatar_id":"","url":"https://api.github.com/users/finbourne","html_url":"https://github.com/finbourne","followers_url":"https://api.github.com/users/finbourne/followers","following_url":"https://api.github.com/users/finbourne/following{/other_user}","gists_url":"https://api.github.com/users/finbourne/gists{/gist_id}","starred_url":"https://api.github.com/users/finbourne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finbourne/subscriptions","organizations_url":"https://api.github.com/users/finbourne/orgs","repos_url":"https://api.github.com/users/finbourne/repos","events_url":"https://api.github.com/users/finbourne/events{/privacy}","received_events_url":"https://api.github.com/users/finbourne/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/finbourne/lusid-sdk-python","description":"LUSID Python SDK","fork":false,"url":"https://api.github.com/repos/finbourne/lusid-sdk-python","forks_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/forks","keys_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/teams","hooks_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/hooks","issue_events_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/events{/number}","events_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/events","assignees_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/assignees{/user}","branches_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/branches{/branch}","tags_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/tags","blobs_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/statuses/{sha}","languages_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/languages","stargazers_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/stargazers","contributors_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/contributors","subscribers_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/subscribers","subscription_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/subscription","commits_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/contents/{+path}","compare_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/merges","archive_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/downloads","issues_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues{/number}","pulls_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls{/number}","milestones_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/milestones{/number}","notifications_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/labels{/name}","releases_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/releases{/id}","deployments_url":"https://api.github.com/repos/finbourne/lusid-sdk-python/deployments","created_at":"2018-03-13T16:31:54Z","updated_at":"2019-02-04T15:49:50Z","pushed_at":"2019-02-04T17:37:13Z","git_url":"git://github.com/finbourne/lusid-sdk-python.git","ssh_url":"git@github.com:finbourne/lusid-sdk-python.git","clone_url":"https://github.com/finbourne/lusid-sdk-python.git","svn_url":"https://github.com/finbourne/lusid-sdk-python","homepage":null,"size":1117,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17"},"html":{"href":"https://github.com/finbourne/lusid-sdk-python/pull/17"},"issue":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/17"},"comments":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/finbourne/lusid-sdk-python/statuses/231eb1b2e0833e7b46f25af9e180265739a6b917"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"gsekhon1"}}