From 551f793a5b2e2d23d46250214c8870258ff3f27c Mon Sep 17 00:00:00 2001 From: Srinivas Gorur-Shandilya Date: Mon, 18 Nov 2024 21:32:07 -0500 Subject: [PATCH] fix: all tests pass now --- src/data_hub/api.py | 9 +- src/utils/network.py | 3 +- .../fixtures/responses/convert_id_format.json | 30 +++ tests/fixtures/responses/create_database.json | 6 +- .../responses/create_file_download_url.json | 2 +- .../responses/create_file_upload.json | 45 ++++ .../fixtures/responses/create_workspace.json | 6 +- .../responses/describe_database_stats.json | 2 +- tests/fixtures/responses/ensure_rows.json | 8 +- .../responses/list_database_rows.json | 248 +++++------------- tests/fixtures/responses/list_files.json | 27 +- tests/fixtures/responses/list_rows.json | 36 +-- tests/test_cli_config.py | 62 +---- tests/test_data_hub.py | 16 +- 14 files changed, 202 insertions(+), 298 deletions(-) create mode 100644 tests/fixtures/responses/convert_id_format.json diff --git a/src/data_hub/api.py b/src/data_hub/api.py index 60f7652..8b86b89 100644 --- a/src/data_hub/api.py +++ b/src/data_hub/api.py @@ -3,7 +3,6 @@ import concurrent.futures import os -import tempfile from pathlib import Path from typing import Any, Optional, Union from urllib.parse import urlparse, urlunparse @@ -246,7 +245,7 @@ def list_rows( def download_file( file_id: str, *, - destination: str | Path | tempfile.TemporaryDirectory = os.getcwd(), + destination: str | Path = os.getcwd(), client=None, _stash: bool = False, ) -> None: @@ -261,9 +260,7 @@ def download_file( """ - if not isinstance(destination, tempfile.TemporaryDirectory) and not os.path.isdir( - destination - ): + if not os.path.isdir(destination): raise DeepOriginException( message=f"Destination `{destination}` should be a path for a folder." ) @@ -1102,7 +1099,7 @@ def get_dataframe( def download_files( files: Optional[list | dict] = None, *, - save_to_dir: Path | str | tempfile.TemporaryDirectory = Path("."), + save_to_dir: Path | str = Path("."), use_file_names: bool = True, client=None, _stash: bool = False, diff --git a/src/utils/network.py b/src/utils/network.py index 61a27a3..98082b6 100644 --- a/src/utils/network.py +++ b/src/utils/network.py @@ -2,7 +2,6 @@ import functools import json -import tempfile from pathlib import Path from urllib.parse import parse_qs, urljoin, urlparse @@ -33,7 +32,7 @@ def check_for_updates(): @beartype def download_sync( url: str, - save_path: str | Path | tempfile.TemporaryDirectory, + save_path: str | Path, ) -> None: """Concrete method to download a resource using GET and save to disk diff --git a/tests/fixtures/responses/convert_id_format.json b/tests/fixtures/responses/convert_id_format.json new file mode 100644 index 0000000..ef2b31b --- /dev/null +++ b/tests/fixtures/responses/convert_id_format.json @@ -0,0 +1,30 @@ +{ + "{\"conversions\": [{\"hid\": \"dfsd-306\"}, {\"hid\": \"exp-1\"}, {\"hid\": \"dna-8\"}]}": [ + { + "id": "_row:cbOepriiytSaPfpqetT4C", + "hid": "dfsd-306" + }, + { + "id": "_row:ku2ZdpZ0VkYgOj1Y37rSi", + "hid": "dna-8" + }, + { + "id": "_row:rakyaiwKrKsS4JT9IJsXn", + "hid": "exp-1" + } + ], + "{\"conversions\": [{\"id\": \"_row:cbOepriiytSaPfpqetT4C\"}, {\"id\": \"_row:ku2ZdpZ0VkYgOj1Y37rSi\"}, {\"id\": \"_row:rakyaiwKrKsS4JT9IJsXn\"}]}": [ + { + "id": "_row:cbOepriiytSaPfpqetT4C", + "hid": "dfsd-306" + }, + { + "id": "_row:rakyaiwKrKsS4JT9IJsXn", + "hid": "exp-1" + }, + { + "id": "_row:ku2ZdpZ0VkYgOj1Y37rSi", + "hid": "dna-8" + } + ] +} \ No newline at end of file diff --git a/tests/fixtures/responses/create_database.json b/tests/fixtures/responses/create_database.json index e39dd36..4d3996b 100644 --- a/tests/fixtures/responses/create_database.json +++ b/tests/fixtures/responses/create_database.json @@ -319,12 +319,12 @@ } }, "{\"database\": {\"hid\": \"tc-4Qzkrn57rM-db\", \"hidPrefix\": \"tc-4Qzkrn57rM-db\", \"name\": \"tc-4Qzkrn57rM-db\", \"parentId\": \"registry\"}}": { - "id": "_database:WrOAWYHIuIqqvy0nbGb5u", + "id": "_database:6yDqaiwVaJF3RNodOWW19", "type": "database", "hid": "tc-4Qzkrn57rM-db", "name": "tc-4Qzkrn57rM-db", - "dateCreated": "2024-11-18 20:26:20.145809", - "dateUpdated": "2024-11-18 20:26:20.145809", + "dateCreated": "2024-11-19 02:31:40.413344", + "dateUpdated": "2024-11-19 02:31:40.413344", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", "parentId": "_workspace:IYTHdIjtuSvnOekwQjUlN", "hidPrefix": "tc-4Qzkrn57rM-db", diff --git a/tests/fixtures/responses/create_file_download_url.json b/tests/fixtures/responses/create_file_download_url.json index b0ba905..c17ed81 100644 --- a/tests/fixtures/responses/create_file_download_url.json +++ b/tests/fixtures/responses/create_file_download_url.json @@ -1,5 +1,5 @@ { "{\"file_id\": \"_file:09fwpdPqHtVdt4jj43ywC\"}": { - "downloadUrl": "https://s3.us-west-2.amazonaws.com/data.deeporigin-com.ijvjf/files/_file%3A09fwpdPqHtVdt4jj43ywC?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIAYOHGBN6A6ZRHWFX7%2F20241118%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241118T202620Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEM3%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQD6U%2Fd%2F1D%2B005aO5p7yRu6w95WUrNGpxopfNtEkSOx4YwIgI%2FmGG9O7zM2RKecUGA2P%2BczzugfJYAecAbvVDwJ3ZHAqlwUIZhABGgw1ODAzMDMwMjQwMDEiDNZ9bdkDqyE%2FlJq1SSr0BNFtckcaKZv6D%2FJwCozdo9tVu%2FmhWZifNK13eMyuAjub2W3rZZxHQLOWR%2B3G6rkhonq2N0S6eWZgtZLXDvi7aeDX4nIz8X%2BgYtHhiO9MnNLd%2BeVv1zFk8DDqnBnhhObPyn5i9VoZeJloR1C7bXGI%2FW9x0641dcYfnhQNFicQ2uAgRP%2BxfcabkiN10vONpA47kNCF6XS9CrgzB2498Fk8SXQubhML6SuMKj56P3if4JtIU%2FV1bw72f7uYILPl6T7YVJgGrP4ZfwGVqkQppvHjgPAVX4BSWuW6zLWp77cWSmbsdlMtP7KRLhggvqJTscUcQHKJYAZCqnJpN9x5Hkp3jMTvgmTM%2FRF8ZFWNSSdtJv6Y9DTj8qyjC5YbGbj0lN3PK7ZEdT98jzS8BGNEcLUOdut%2BXj9md526MunsmPG6kufxsqWG6r0ysV2GDxLDmKE%2B8k3B53de5FDdV%2FD0xLIPxrzWvl8ZkGxfkq8QRg0WojkFuJzxtV1FgWHUbOzzDtZoiElyAWC7ofVxInyVz6GpAQg27C2Qjm9IJX8388X82BaCe3nLw%2FP6M%2BRA9qClBQZjyPfcD%2FwwDEfPZBDuH1ePv3UmLhPJzjO5RNvKbfKSa7AMbgGg0V1IOiB%2BO7sXD6fPQcHlsh98EoCRULQ09DCkAKE%2FifQ%2F2uKkL5PLImkpwc0MOFuoPgVoYQKLvTQ1DqvxQH6flKYQYY8IQuPvjkokEhnhvabeS56tjG5ukAmz31ho1CyJVHg3tONNx%2FPEkDlT9rgljWbaD8c7Pompsb5G843IbGxjTdNNyn17TwYCou%2BqiHetVZGPNKyfhIQ1%2B7ERzlt2jaYw7MXuuQY6mwET59CZAQh9D9F7InhTgdsRGeUbkg38y4nAFzv2kbmMozSeLw8MtdnYmCjYavVctiwnH86O59BD%2BaephTUozgRi6j9KJ17OamqG7I5zucrL9b6cHJkuv29Cx%2BDe%2Bd1dHB134t7L8BmtNHI1LNysKaXfuckcqgC69QjYeRh1ECgmcfHTp0LWRFaftX1JbseEeFAGuZVB9U5facnyGw%3D%3D&X-Amz-Signature=3cabd9bbed4f2de87fa3cb2f63041d47504fdc4875ea2626fe4b211bc9c497ae&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27science.ade2574_sm.pdf&x-id=GetObject" + "downloadUrl": "https://s3.us-west-2.amazonaws.com/data.deeporigin-com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ICyOuAHYHQUba3jzp6xnFQDH5NKxARvfdNdILEpK%2Fjjn0ksmGD%2FBMcefytl%2FrGXPBeKH89D8N5RoFJ4dzv6Z86eXUrRNRjqbleYpLdsttnlIL71xWX0Z3%2BmkRP84ZktQSTvJLU8cG78VO3uKbBOiEAcyhDZ8fAoMUrIM4QLaxd9y3%2BvKZofe4nZN1t5wPYreBJWsfbhZkgJnxmHLBBdyt8eXyEBy5j5lYZfp6MIzx77kGOpoBAocVoW9HLkIC5chuTrZL7nVhKE3cnLjHyPlxIJ7ePTCH3mqdINhGGqmhDToUD8tdPlBLNRnxvUVRrRujZbjwd5fxZyLf77A24UeO%2FIzZ9x3l61mj020OAXT9ZHkfsEr2RH%2BSBe0Z%2B%2BOIQeJjMdILep8vKD4SYDdjH05QeGe39Q71uRS9AxthTIcmpO0lVmiQf6bZgTfU2l8Y4w%3D%3D&X-Amz-Signature=bfcb539c5ed7be3f64d916a1a717f8ac89edff7815436f4e1210dcaa97afe56a&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27science.ade2574_sm.pdf&x-id=GetObject" } } \ No newline at end of file diff --git a/tests/fixtures/responses/create_file_upload.json b/tests/fixtures/responses/create_file_upload.json index 6b82ae5..5884c55 100644 --- a/tests/fixtures/responses/create_file_upload.json +++ b/tests/fixtures/responses/create_file_upload.json @@ -148,5 +148,50 @@ "dateUpdated": "2024-11-18T20:26:25.600Z", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" } + }, + "{\"checksum_sha256\": \"OOalC7zeyKhsbKYnafPElfRfNNhFbb9834QZKG0bScI=\", \"content_length\": \"10532\", \"content_type\": \"text/x-python\", \"name\": \"test_data_hub.py\"}": { + "uploadUrl": "https://s3.us-west-2.amazonaws.com/data.deeporigin-com.ijvjf/files/_file%3AcAntixwMAY0kdJof1TEBf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential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hiLKiesyHlqBlMKCkLmNXKo56%2FCsn7ZF%2BhsOuEp0lCdX8wvsc%2FLi%2FBjP0vPHC%2FvM8rSzDg9KopgIIf3v3mDbC4uBVMPHyhBYYp8yvPxnhbox%2F%2FQbszhnHVPSvwm%2FOZMuNe92BZPOzC2vO%2B5BjqcAZIKAbXyarlFcIEVesM969xNvBLz0qcRMNEmASZqTuspDa3y4Bh3ycihk3oXcBiKD4VjTlw%2BAl3K6NMvifsezP%2F0P9COu3kywpBO9jbkmAaJgPAcDYH4j5nkpIonhVWVfUEG%2BVoVAmOCRTKTujlmFAEC9O%2BegVi%2Bp8l9FUCSDSO%2FKGMKKLmtlb%2FP6dizOE159TxeecIGQImD%2BRyK8A%3D%3D&X-Amz-Signature=e67e98220003654c0e9f586247794fd918a7c8138c18e07993a9fd3e4be43c77&X-Amz-SignedHeaders=content-length%3Bhost%3Bx-amz-checksum-sha256&x-amz-sdk-checksum-algorithm=SHA256&x-id=PutObject", + "file": { + "name": "test_data_hub.py", + "contentType": "text/x-python", + "contentLength": 10532, + "checksumSha256": "OOalC7zeyKhsbKYnafPElfRfNNhFbb9834QZKG0bScI=", + "id": "_file:cAntixwMAY0kdJof1TEBf", + "status": "ready", + "uri": "s3://data.deeporigin-com.ijvjf/files/_file:cAntixwMAY0kdJof1TEBf", + "dateCreated": "2024-11-19T00:39:18.050Z", + "dateUpdated": "2024-11-19T00:39:18.050Z", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" + } + }, + "{\"checksum_sha256\": \"ow8eG4Wyyh7lFRVWXX+5/0GKgq/9fKxTTnx8ZXg/V/4=\", \"content_length\": \"10300\", \"content_type\": \"text/x-python\", \"name\": \"test_data_hub.py\"}": { + "uploadUrl": "https://s3.us-west-2.amazonaws.com/data.deeporigin-com.ijvjf/files/_file%3AHgf8ODhmDqrkHkSWKxWYS?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=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wQ9s5q2m%2FZQ7R5KuGbpxnBV3dt5OHhWOIkIG7znMf%2Bhczn5jfXpeHt4DWA3GKy8SljECNl8Omu5ZY9GvKdAuxkwaZ1hlwS3PvT9zGTbGJeflRvep5Pre1HcHxroMutxCPFxndkJ068yIIw4bzvuQY6mwFcXasbsCX81dL93%2BP7uQM%2Fkz%2FL%2FFhqNzrz5ZyIcHITSmCpBNCBNfbb85ok5drbmrZ2sGOkhzK%2BqXu5MRfT2eR7C7rmTHtmI9l1RPkRsBZPvs4ypjAGqHynxg0J%2B7a%2Fz0xjcdMSZlSJG3GaVjZxZOiSdY5vmj%2F%2FKMoJAO6Sr8VxTfq3EkUsSTUqiBR6K3IMuqE0x90Af1cfqe8Ovw%3D%3D&X-Amz-Signature=0e9c563abe72c55965d8298b9482157d4211720b01462e9da7fbfe4c54cc8ab9&X-Amz-SignedHeaders=content-length%3Bhost%3Bx-amz-checksum-sha256&x-amz-sdk-checksum-algorithm=SHA256&x-id=PutObject", + "file": { + "name": "test_data_hub.py", + "contentType": "text/x-python", + "contentLength": 10300, + "checksumSha256": "ow8eG4Wyyh7lFRVWXX+5/0GKgq/9fKxTTnx8ZXg/V/4=", + "id": "_file:Hgf8ODhmDqrkHkSWKxWYS", + "status": "ready", + "uri": "s3://data.deeporigin-com.ijvjf/files/_file:Hgf8ODhmDqrkHkSWKxWYS", + "dateCreated": "2024-11-19T00:40:01.413Z", + "dateUpdated": "2024-11-19T00:40:01.413Z", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" + } + }, + "{\"checksum_sha256\": \"HBtzo8llBxCz+VTKiadjW1i/tcLGq8kOafOJXPcW3+g=\", \"content_length\": \"10486\", \"content_type\": \"text/x-python\", \"name\": \"test_data_hub.py\"}": { + "uploadUrl": "https://s3.us-west-2.amazonaws.com/data.deeporigin-com.ijvjf/files/_file%3AmdLNOcypPygiSS2LiX9Zn?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED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3ajkzNDjOy90R%2FlrTAjAv%2BVEVQFeC4OgcSb6jOLvM4miw091dzX0rnRiyacU3qzk1EVwtu1pDOEhKngbNJozxPehNp7NPVY6Ak%2BhF9%2B%2Bl6OwPSlGg09bwBOc8RbrKYbyxGe1Ao4OrX9poOSKDNokwjfHvuQY6mwEK12iR26T%2BUkPPULpvMKYGK%2FqxQOtPFmj%2FRLCT6gvgpAzcMH96QlA1vT33qRq6zUoJK%2BUaLtoOnrtJTjJfEaf6d00bw2TvsJXAzrvIxHY8kuQprZgORWILVyjRCZJEyNIIKtpV7LtuQgJA6rvjWO2bNXl2IqUxs0okheykHsPa%2FclMOdfbCgct1ejkV6k2R%2B3alcqmuy%2B9peOeVw%3D%3D&X-Amz-Signature=0d8a52680bed3d7f972556413d728005e391dca145df9489da287bf46988f080&X-Amz-SignedHeaders=content-length%3Bhost%3Bx-amz-checksum-sha256&x-amz-sdk-checksum-algorithm=SHA256&x-id=PutObject", + "file": { + "name": "test_data_hub.py", + "contentType": "text/x-python", + "contentLength": 10486, + "checksumSha256": "HBtzo8llBxCz+VTKiadjW1i/tcLGq8kOafOJXPcW3+g=", + "id": "_file:mdLNOcypPygiSS2LiX9Zn", + "status": "ready", + "uri": "s3://data.deeporigin-com.ijvjf/files/_file:mdLNOcypPygiSS2LiX9Zn", + "dateCreated": "2024-11-19T02:31:41.749Z", + "dateUpdated": "2024-11-19T02:31:41.749Z", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" + } } } \ No newline at end of file diff --git a/tests/fixtures/responses/create_workspace.json b/tests/fixtures/responses/create_workspace.json index bb6e80d..af3df18 100644 --- a/tests/fixtures/responses/create_workspace.json +++ b/tests/fixtures/responses/create_workspace.json @@ -17,12 +17,12 @@ "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" }, "{\"workspace\": {\"hid\": \"tc-4Qzkrn57rM-ws\", \"name\": \"tc-4Qzkrn57rM-ws\", \"parentId\": null}}": { - "id": "_workspace:fuwIWJoLFy9rqMDorXebv", + "id": "_workspace:6Wja8RPJ1hTP0ZB4K1UZu", "type": "workspace", "hid": "tc-4Qzkrn57rM-ws", "name": "tc-4Qzkrn57rM-ws", - "dateCreated": "2024-11-18 20:26:20.358607", - "dateUpdated": "2024-11-18 20:26:20.358607", + "dateCreated": "2024-11-19 02:31:40.529314", + "dateUpdated": "2024-11-19 02:31:40.529314", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" }, "{\"workspace\": {\"hid\": \"tc-4Qzkrn57rM-d64c9f\", \"name\": \"tc-4Qzkrn57rM-d64c9f\", \"parentId\": null}}": { diff --git a/tests/fixtures/responses/describe_database_stats.json b/tests/fixtures/responses/describe_database_stats.json index a934947..606b560 100644 --- a/tests/fixtures/responses/describe_database_stats.json +++ b/tests/fixtures/responses/describe_database_stats.json @@ -3,6 +3,6 @@ "rowCount": 29 }, "{\"database_id\": \"kitchen-sink\"}": { - "rowCount": 120 + "rowCount": 125 } } \ No newline at end of file diff --git a/tests/fixtures/responses/ensure_rows.json b/tests/fixtures/responses/ensure_rows.json index 255dc67..2da216e 100644 --- a/tests/fixtures/responses/ensure_rows.json +++ b/tests/fixtures/responses/ensure_rows.json @@ -17,11 +17,11 @@ "rows": [ { "type": "row", - "id": "_row:21p3WTJ8i4OA5IKYRldms", - "hid": "ks-129", + "id": "_row:dEKQy0zs4KtvubW3kfOZq", + "hid": "ks-133", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-11-18 20:26:26.024273", - "dateUpdated": "2024-11-18 20:26:26.024273", + "dateCreated": "2024-11-19 02:31:40.246771", + "dateUpdated": "2024-11-19 02:31:40.246771", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", "validationStatus": "valid" } diff --git a/tests/fixtures/responses/list_database_rows.json b/tests/fixtures/responses/list_database_rows.json index 163a790..98929aa 100644 --- a/tests/fixtures/responses/list_database_rows.json +++ b/tests/fixtures/responses/list_database_rows.json @@ -2294,6 +2294,46 @@ } ], "{\"database_row_id\": \"_database:swAKhqQzxqTB7cm2FeVcW\"}": [ + { + "type": "row", + "id": "_row:Fnj4XNRufMJOPLyiPU7Dh", + "hid": "ks-130", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "dateCreated": "2024-11-19 00:39:19.55981", + "dateUpdated": "2024-11-19 00:39:19.55981", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", + "validationStatus": "valid" + }, + { + "type": "row", + "id": "_row:uG83XtADlvVqO3zSztT0x", + "hid": "ks-132", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "dateCreated": "2024-11-19 00:45:27.082065", + "dateUpdated": "2024-11-19 00:45:27.082065", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", + "validationStatus": "valid" + }, + { + "type": "row", + "id": "_row:xVNYduhIP2MUNLxWWq43c", + "hid": "ks-131", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "dateCreated": "2024-11-19 00:40:02.110502", + "dateUpdated": "2024-11-19 00:40:02.110502", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", + "validationStatus": "valid" + }, + { + "type": "row", + "id": "_row:dEKQy0zs4KtvubW3kfOZq", + "hid": "ks-133", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "dateCreated": "2024-11-19 02:31:40.246771", + "dateUpdated": "2024-11-19 02:31:40.246771", + "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", + "validationStatus": "valid" + }, { "type": "row", "id": "_row:3vYzh6x7cZVusfAtOG8Zz", @@ -2477,111 +2517,49 @@ "validationStatus": "valid" } ] - }, + } + ], + "{\"database_row_id\": \"kitchen-sink\"}": [ { "type": "row", - "id": "_row:Rm616vGofFhnKirBE3Dfm", - "hid": "ks-123", + "id": "_row:Fnj4XNRufMJOPLyiPU7Dh", + "hid": "ks-130", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-11-18 19:47:17.480021", - "dateUpdated": "2024-11-18 19:47:17.480021", + "dateCreated": "2024-11-19 00:39:19.55981", + "dateUpdated": "2024-11-19 00:39:19.55981", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", "validationStatus": "valid" }, { "type": "row", - "id": "_row:bWc2CHn4trPnGaDutc7zf", - "hid": "ks-124", + "id": "_row:uG83XtADlvVqO3zSztT0x", + "hid": "ks-132", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-11-18 20:02:28.368599", - "dateUpdated": "2024-11-18 20:02:28.368599", + "dateCreated": "2024-11-19 00:45:27.082065", + "dateUpdated": "2024-11-19 00:45:27.082065", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", "validationStatus": "valid" }, { "type": "row", - "id": "_row:vMkkZoVne2KiaJ2K5BdlY", - "hid": "ks-25", + "id": "_row:xVNYduhIP2MUNLxWWq43c", + "hid": "ks-131", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-10-18 13:30:47.103189", - "dateUpdated": "2024-11-16 00:11:51.802721", + "dateCreated": "2024-11-19 00:40:02.110502", + "dateUpdated": "2024-11-19 00:40:02.110502", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "editedByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid", - "fields": [ - { - "columnId": "_column:z6QzWODldQbQlEk7bKIP5", - "type": "boolean", - "value": false, - "version": 11, - "validationStatus": "valid" - }, - { - "columnId": "_column:MDfMnvJ5eIQG4eIXewMGF", - "type": "float", - "value": 9.249614179762611, - "version": 20, - "validationStatus": "valid" - }, - { - "columnId": "_column:i3NTGFiGmbbvpB8tCszJJ", - "type": "integer", - "value": 192, - "version": 43, - "validationStatus": "valid" - }, - { - "columnId": "_column:orvcMwBnadxNsaN3nsvh8", - "type": "text", - "value": "o1l81a", - "version": 4, - "validationStatus": "valid" - } - ] + "validationStatus": "valid" }, { "type": "row", - "id": "_row:4lSHzko50SqYu1fGeLfsT", - "hid": "ks-26", + "id": "_row:dEKQy0zs4KtvubW3kfOZq", + "hid": "ks-133", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-10-18 13:30:47.103189", - "dateUpdated": "2024-11-16 00:11:51.802721", + "dateCreated": "2024-11-19 02:31:40.246771", + "dateUpdated": "2024-11-19 02:31:40.246771", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "editedByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid", - "fields": [ - { - "columnId": "_column:z6QzWODldQbQlEk7bKIP5", - "type": "boolean", - "value": false, - "version": 11, - "validationStatus": "valid" - }, - { - "columnId": "_column:MDfMnvJ5eIQG4eIXewMGF", - "type": "float", - "value": 96.83094830563796, - "version": 20, - "validationStatus": "valid" - }, - { - "columnId": "_column:i3NTGFiGmbbvpB8tCszJJ", - "type": "integer", - "value": 830, - "version": 43, - "validationStatus": "valid" - }, - { - "columnId": "_column:orvcMwBnadxNsaN3nsvh8", - "type": "text", - "value": "famr0e", - "version": 4, - "validationStatus": "valid" - } - ] - } - ], - "{\"database_row_id\": \"kitchen-sink\"}": [ + "validationStatus": "valid" + }, { "type": "row", "id": "_row:3vYzh6x7cZVusfAtOG8Zz", @@ -2765,108 +2743,6 @@ "validationStatus": "valid" } ] - }, - { - "type": "row", - "id": "_row:Rm616vGofFhnKirBE3Dfm", - "hid": "ks-123", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-11-18 19:47:17.480021", - "dateUpdated": "2024-11-18 19:47:17.480021", - "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid" - }, - { - "type": "row", - "id": "_row:bWc2CHn4trPnGaDutc7zf", - "hid": "ks-124", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-11-18 20:02:28.368599", - "dateUpdated": "2024-11-18 20:02:28.368599", - "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid" - }, - { - "type": "row", - "id": "_row:vMkkZoVne2KiaJ2K5BdlY", - "hid": "ks-25", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-10-18 13:30:47.103189", - "dateUpdated": "2024-11-16 00:11:51.802721", - "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "editedByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid", - "fields": [ - { - "columnId": "_column:z6QzWODldQbQlEk7bKIP5", - "type": "boolean", - "value": false, - "version": 11, - "validationStatus": "valid" - }, - { - "columnId": "_column:MDfMnvJ5eIQG4eIXewMGF", - "type": "float", - "value": 9.249614179762611, - "version": 20, - "validationStatus": "valid" - }, - { - "columnId": "_column:i3NTGFiGmbbvpB8tCszJJ", - "type": "integer", - "value": 192, - "version": 43, - "validationStatus": "valid" - }, - { - "columnId": "_column:orvcMwBnadxNsaN3nsvh8", - "type": "text", - "value": "o1l81a", - "version": 4, - "validationStatus": "valid" - } - ] - }, - { - "type": "row", - "id": "_row:4lSHzko50SqYu1fGeLfsT", - "hid": "ks-26", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "dateCreated": "2024-10-18 13:30:47.103189", - "dateUpdated": "2024-11-16 00:11:51.802721", - "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "editedByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com", - "validationStatus": "valid", - "fields": [ - { - "columnId": "_column:z6QzWODldQbQlEk7bKIP5", - "type": "boolean", - "value": false, - "version": 11, - "validationStatus": "valid" - }, - { - "columnId": "_column:MDfMnvJ5eIQG4eIXewMGF", - "type": "float", - "value": 96.83094830563796, - "version": 20, - "validationStatus": "valid" - }, - { - "columnId": "_column:i3NTGFiGmbbvpB8tCszJJ", - "type": "integer", - "value": 830, - "version": 43, - "validationStatus": "valid" - }, - { - "columnId": "_column:orvcMwBnadxNsaN3nsvh8", - "type": "text", - "value": "famr0e", - "version": 4, - "validationStatus": "valid" - } - ] } ] } \ No newline at end of file diff --git a/tests/fixtures/responses/list_files.json b/tests/fixtures/responses/list_files.json index 8bf2fab..40eb2c1 100644 --- a/tests/fixtures/responses/list_files.json +++ b/tests/fixtures/responses/list_files.json @@ -376,27 +376,28 @@ }, { "file": { - "id": "_file:36ufKT2Sej22coSEOizpK", - "uri": "s3://data.deeporigin-com.ijvjf/files/_file:36ufKT2Sej22coSEOizpK", - "name": "purple.png", + "id": "_file:2ygPpAsbHxVSVBNiKpehU", + "uri": "s3://data.deeporigin-com.ijvjf/files/_file:2ygPpAsbHxVSVBNiKpehU", + "name": "test_data_hub.py", "status": "ready", - "contentLength": 554588, - "contentType": "image/png", - "dateCreated": "2024-06-18 14:48:33.501", - "dateUpdated": "2024-06-18 14:48:33.501", + "contentLength": 10743, + "contentType": "text/x-python", + "checksumSha256": "0mveZ1Nr7KTKAPhTng9w9rBvyk3YNLStUiebd43sjZI=", + "dateCreated": "2024-11-18 20:26:25.6", + "dateUpdated": "2024-11-18 20:26:25.6", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" } }, { "file": { - "id": "_file:39I8dsX0jLa1HjQtX6FQp", - "uri": "s3://data.deeporigin-com.ijvjf/files/_file:39I8dsX0jLa1HjQtX6FQp", - "name": "chonky-boi.png", + "id": "_file:36ufKT2Sej22coSEOizpK", + "uri": "s3://data.deeporigin-com.ijvjf/files/_file:36ufKT2Sej22coSEOizpK", + "name": "purple.png", "status": "ready", - "contentLength": 1006333, + "contentLength": 554588, "contentType": "image/png", - "dateCreated": "2024-10-08 13:20:42.423", - "dateUpdated": "2024-10-08 13:20:42.423", + "dateCreated": "2024-06-18 14:48:33.501", + "dateUpdated": "2024-06-18 14:48:33.501", "createdByUserDrn": "drn:identity::user:google-apps|srinivas@deeporigin.com" } } diff --git a/tests/fixtures/responses/list_rows.json b/tests/fixtures/responses/list_rows.json index 95a94f8..ae20ea8 100644 --- a/tests/fixtures/responses/list_rows.json +++ b/tests/fixtures/responses/list_rows.json @@ -222,6 +222,24 @@ } ], "{\"filters\": [{\"parent\": {\"id\": \"kitchen-sink\"}}]}": [ + { + "id": "_row:Fnj4XNRufMJOPLyiPU7Dh", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "hid": "ks-130", + "type": "row" + }, + { + "id": "_row:uG83XtADlvVqO3zSztT0x", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "hid": "ks-132", + "type": "row" + }, + { + "id": "_row:xVNYduhIP2MUNLxWWq43c", + "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", + "hid": "ks-131", + "type": "row" + }, { "id": "_row:3vYzh6x7cZVusfAtOG8Zz", "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", @@ -263,24 +281,6 @@ "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", "hid": "ks-123", "type": "row" - }, - { - "id": "_row:bWc2CHn4trPnGaDutc7zf", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "hid": "ks-124", - "type": "row" - }, - { - "id": "_row:vMkkZoVne2KiaJ2K5BdlY", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "hid": "ks-25", - "type": "row" - }, - { - "id": "_row:4lSHzko50SqYu1fGeLfsT", - "parentId": "_database:swAKhqQzxqTB7cm2FeVcW", - "hid": "ks-26", - "type": "row" } ], "{\"filters\": [{\"parent\": {\"id\": \"kitchen-sink\"}}, {\"row_type\": \"row\"}]}": [ diff --git a/tests/test_cli_config.py b/tests/test_cli_config.py index e1956e1..9fb8a30 100644 --- a/tests/test_cli_config.py +++ b/tests/test_cli_config.py @@ -1,60 +1,12 @@ -import pytest from deeporigin.config import get_value -from deeporigin.data_hub import api -from mock_client import MockClient -from tests.utils import _run_cli_command +from tests.utils import ( # noqa: F401 + _run_cli_command, + config, +) -STASH = True - -@pytest.fixture(scope="session", autouse=True) -def config(pytestconfig): - """this fixture performs some setup tasks - before all tests are run, and runs only once""" - - data = dict() - - # set up client - if pytestconfig.getoption("client") == "mock": - data["client"] = MockClient() - - # unpack mock data from client - data["folders"] = data["client"].folders - data["databases"] = data["client"].databases - data["rows"] = data["client"].rows - data["file"] = data["client"].file - else: - client = api._get_default_client() - data["client"] = client - - # if we're going to be making requests to a live - # instance, we need to make sensible requests - databases = api.list_rows( - row_type="database", - _stash=STASH, - ) - data["databases"] = [db.hid for db in databases] - rows = api.list_rows( - row_type="row", - _stash=STASH, - ) - data["rows"] = [row.id for row in rows] - - # get a list of all files - files = api.list_files( - _stash=STASH, - ) - if len(files) > 0: - data["file"] = files[0].file - - # tests run on yield - yield data - - # teardown tasks, if any - - -def test_set_config(config): +def test_set_config(config): # noqa: F811 org_id = "foo_1234" try: org_id = get_value()["organization_id"] @@ -64,7 +16,7 @@ def test_set_config(config): stdout = _run_cli_command( ["config", "set", "organization_id", "foo_3423"], - config["client"], + client=config["client"], ) assert "foo_3423" in stdout, "Failed to set organization_id" @@ -72,7 +24,7 @@ def test_set_config(config): # reset to what it was before stdout = _run_cli_command( ["config", "set", "organization_id", org_id], - config["client"], + client=config["client"], ) assert org_id in stdout, "Failed to set organization_id" diff --git a/tests/test_data_hub.py b/tests/test_data_hub.py index a1e333e..d8c22c1 100644 --- a/tests/test_data_hub.py +++ b/tests/test_data_hub.py @@ -1,7 +1,8 @@ """this tests functions used to interact with the data hub""" import os -import tempfile +import shutil +import uuid import pandas as pd import pytest @@ -248,10 +249,6 @@ def test_get_dataframe(config): # noqa: F811 assert isinstance(df, pd.DataFrame), "Expected return type to be a pandas Dataframe" - assert ( - set(df.attrs.keys()) == DATAFRAME_ATTRIBUTE_KEYS - ), f"Expected to find a dictionary in `df.attrs` with these keys: {DATAFRAME_ATTRIBUTE_KEYS}, instead found a dictionary with these keys: {df.attrs.keys()}" - assert ( "Validation Status" in df.columns ), f"Expected to find a column called `Validation Status` in the dataframe. Instead, the columns in this dataframe are: {df.columns}" @@ -332,13 +329,20 @@ def test_download_file(config): # noqa: F811 ) else: + destination = str(uuid.uuid4())[:5] + destination = os.path.join(os.getcwd(), destination) + os.makedirs(destination) + api.download_file( file_id=file_id, client=config["client"], _stash=config["stash"], - destination=tempfile.TemporaryDirectory(), + destination=destination, ) + # clean up + shutil.rmtree(destination) + def test_describe_file(config): # noqa: F811 file_id = config["file"].id