Skip to content

Commit

Permalink
mock aws credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
hynky1999 committed Oct 24, 2023
1 parent 0116fbd commit a095d2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MYSQL_HOST=localhost:3306
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DB_NAME=test_cc
MYSQL_TABLE_NAME=ccindex
4 changes: 3 additions & 1 deletion tests/athena_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest.mock import patch

import boto3
from tests.utils import MySQLRecordsDB
from tests.utils import MySQLRecordsDB, set_up_aws_credentials_testing
import aioboto3

from cmoncrawl.aggregator.athena_query import (
Expand Down Expand Up @@ -120,6 +120,7 @@ async def asyncSetUp(self) -> None:
"https://index.commoncrawl.org/CC-MAIN-2021-09-index",
"https://index.commoncrawl.org/CC-MAIN-2020-50-index",
]
set_up_aws_credentials_testing()

def test_prepare_athena_sql_query_multiple_urls(self):
query = prepare_athena_sql_query(
Expand Down Expand Up @@ -242,6 +243,7 @@ def setUp(self) -> None:
self.mock_s3.start()
self.mock_athena = mock_athena()
self.mock_athena.start()
set_up_aws_credentials_testing()

def tearDown(self) -> None:
self.mock_s3.stop()
Expand Down
10 changes: 10 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,13 @@ def setUp(self):
def tearDown(self):
self.remove_db()
self.db.close()


def set_up_aws_credentials_testing():
import os

os.environ["AWS_ACCESS_KEY_ID"] = "testing"
os.environ["AWS_SECRET_ACCESS_KEY"] = "testing"
os.environ["AWS_SECURITY_TOKEN"] = "testing"
os.environ["AWS_SESSION_TOKEN"] = "testing"
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"

0 comments on commit a095d2d

Please sign in to comment.