Skip to content

Commit

Permalink
SK-1749: Fix shared tests yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
saileshwar-skyflow committed Nov 26, 2024
1 parent 9656eac commit bbcd32c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/shared-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,13 @@ jobs:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Process and Update Test Constants
run: |
CREDS="${{ secrets.VALID_SKYFLOW_CREDS_TEST }}"
CREDS=$(echo "$CREDS" | sed 's/\\n/\n/g')
echo "$CREDS" > ./tests/service_account/valid_credentials.json
STRING_FORMAT=$(echo "$CREDS" | jq -c .)
DICT_FORMAT=$(echo "$CREDS" | jq .)
sed -i "s|VALID_CREDENTIALS_STRING = .*|VALID_CREDENTIALS_STRING = '$STRING_FORMAT'|" ./tests/constants/test_constants.py
sed -i "s|VALID_SERVICE_ACCOUNT_CREDS = .*|VALID_SERVICE_ACCOUNT_CREDS = $DICT_FORMAT|" ./tests/constants/test_constants.py
shell: bash
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.VALID_SKYFLOW_CREDS_TEST }}


- name: 'Run Tests'
run: |
pip install -r requirements.txt
Expand Down
10 changes: 8 additions & 2 deletions tests/constants/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from skyflow import LogLevel
from skyflow import Env
import os
import json

creds_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "credentials.json")
with open(creds_path, 'r') as file:
credentials = json.load(file)

#client initialization constants

Expand Down Expand Up @@ -37,9 +43,9 @@

# service account constants

VALID_CREDENTIALS_STRING = ''
VALID_CREDENTIALS_STRING = json.dumps(credentials)

VALID_SERVICE_ACCOUNT_CREDS = {}
VALID_SERVICE_ACCOUNT_CREDS = credentials

CREDENTIALS_WITHOUT_CLIENT_ID = {
'privateKey': 'private_key'
Expand Down
10 changes: 2 additions & 8 deletions tests/service_account/test__utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_generate_bearer_token_invalid_json(self, mock_json_load):

@patch("skyflow.service_account._utils.get_service_account_token")
def test_generate_bearer_token_valid_file_path(self, mock_generate_bearer_token):
creds_path = os.path.join(os.path.dirname(__file__), "valid_credentials.json")
creds_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "credentials.json")
generate_bearer_token(creds_path)
mock_generate_bearer_token.assert_called_once()

Expand Down Expand Up @@ -105,7 +105,7 @@ def test_get_signed_data_token_response_object(self):
self.assertEqual(response[1], signed_token)

def test_generate_signed_data_tokens_from_file_path(self):
creds_path = os.path.join(os.path.dirname(__file__), "valid_credentials.json")
creds_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "credentials.json")
options = {"data_tokens": ["token1", "token2"], "ctx": 'ctx'}
result = generate_signed_data_tokens(creds_path, options)
self.assertEqual(len(result), 2)
Expand All @@ -116,12 +116,6 @@ def test_generate_signed_data_tokens_from_invalid_file_path(self):
result = generate_signed_data_tokens('credentials1.json', options)
self.assertEqual(context.exception.message, SkyflowMessages.Error.INVALID_CREDENTIAL_FILE_PATH.value)

# def test_generate_signed_data_tokens_from_valid_file_path_with_invalid_credentials(self):
# options = {"data_tokens": ["token1", "token2"]}
# with self.assertRaises(SkyflowError) as context:
# result = generate_signed_data_tokens("invalid_creds.json", options)
# self.assertEqual(context.exception.message, SkyflowMessages.Error.FILE_INVALID_JSON.value.format("invalid_creds.json"))

def test_generate_signed_data_tokens_from_creds(self):
options = {"data_tokens": ["token1", "token2"]}
result = generate_signed_data_tokens_from_creds(VALID_CREDENTIALS_STRING, options)
Expand Down
1 change: 0 additions & 1 deletion tests/service_account/valid_credentials.json

This file was deleted.

0 comments on commit bbcd32c

Please sign in to comment.