Skip to content

Commit

Permalink
Merge pull request #2 from Jmateusribeiro/github-action-pylint
Browse files Browse the repository at this point in the history
Update pylint.yml
  • Loading branch information
Jmateusribeiro committed Jun 1, 2024
2 parents 89ec08c + 9e623bc commit 41941a4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
- name: Analyzing the code with pylint
run: |
pylint $(git ls-files '*.py')
pylint **/*.py
10 changes: 5 additions & 5 deletions tests/step_defs/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from utilities.classes.sqs_client import SQSClient
from utilities.classes.log import CustomLogger
from utilities.settings import queue_name, sqs_bucket, report_dir
from utilities.settings import QUEUE_NAME, SQS_BUCKET, REPORT_DIR
from utilities import os_funcs as cmd
from moto import mock_aws

Expand Down Expand Up @@ -41,7 +41,7 @@ def log() -> CustomLogger:
Returns:
CustomLogger: A CustomLogger instance.
"""
return CustomLogger(report_dir)
return CustomLogger(REPORT_DIR)

@pytest.fixture(autouse=True, scope='module')
def setup(request: 'pytest.FixtureRequest', mock_aws_flag: bool, log: CustomLogger) -> None:
Expand Down Expand Up @@ -89,8 +89,8 @@ def sqs_cli(mock_aws_flag: bool, log: CustomLogger) -> SQSClient:
Returns:
SQSClient: An SQSClient instance.
"""
sqs_cli = SQSClient(log=log, bucket=sqs_bucket, mock_aws_flag=mock_aws_flag)
sqs_cli.create_queue(queue_name)
sqs_cli.get_queue_url(queue_name)
sqs_cli = SQSClient(log=log, bucket=SQS_BUCKET, mock_aws_flag=mock_aws_flag)
sqs_cli.create_queue(QUEUE_NAME)
sqs_cli.get_queue_url(QUEUE_NAME)

return sqs_cli
4 changes: 2 additions & 2 deletions tests/step_defs/test_messages_steps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pytest_bdd import scenarios, given, when, then
import json
from utilities.settings import project_dir
from utilities.settings import PROJECT_DIR

# Load feature files for pytest-bdd
scenarios('../features/cars_stream_processing.feature')
Expand All @@ -19,7 +19,7 @@ def added_cars(sqs_cli: 'SQSClient', log: 'CustomLogger') -> list:
list: List of cars added to the queue.
"""
log.info("######## Start Step: 'Given a list of cars are added to car queue' ########")
f = open(project_dir + "\\test-data\\cars.json", "r")
f = open(PROJECT_DIR + "\\test-data\\cars.json", "r")
cars = json.loads(f.read())

for car in cars:
Expand Down
8 changes: 4 additions & 4 deletions utilities/classes/sqs_client.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import boto3
from botocore.exceptions import ClientError
import json
from utilities.settings import localhost, region_name
from utilities.settings import LOCALHOST, REGION_NAME

class SQSClient:
def __init__(self, log: 'CustomLogger', bucket: str, mock_aws_flag: bool, host: str = localhost, region_name: str = region_name):
def __init__(self, log: 'CustomLogger', bucket: str, mock_aws_flag: bool, host: str = LOCALHOST, region_name: str = REGION_NAME):
"""
Initialize SQSClient.
Args:
log (CustomLogger): Logger object.
bucket (str): Name of the AWS bucket.
mock_aws_flag (bool): Flag indicating whether to mock AWS or not.
host (str, optional): Host URL. Defaults to localhost.
region_name (str, optional): AWS region name. Defaults to region_name.
host (str, optional): Host URL. Defaults to LOCALHOST.
region_name (str, optional): AWS region name. Defaults to REGION_NAME.
"""
self.log = log
self.bucket_name = bucket
Expand Down
5 changes: 4 additions & 1 deletion utilities/os_funcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
LocalStack Commandline Functions Module
"""
import os

def start_localstack() -> None:
Expand All @@ -11,4 +14,4 @@ def stop_localstack() -> None:
"""
Stop local stack on command line.
"""
os.system('localstack stop')
os.system('localstack stop')
15 changes: 9 additions & 6 deletions utilities/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""
Project Settings
"""
import os

project_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
report_dir = project_dir + "//reports"
queue_name = "cars"
localhost = "http://localhost:4566"
sqs_bucket = "sqs"
region_name = "eu-west-2"
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
REPORT_DIR = PROJECT_DIR + "//reports"
QUEUE_NAME = "cars"
LOCALHOST = "http://localhost:4566"
SQS_BUCKET = "sqs"
REGION_NAME = "eu-west-2"

0 comments on commit 41941a4

Please sign in to comment.