Skip to content

Commit

Permalink
refactor(cli): rename module name to gdk (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
saranyailla authored Nov 18, 2021
1 parent a154eec commit 5f06744
Show file tree
Hide file tree
Showing 63 changed files with 373 additions and 455 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Testing CLI (Runs both unit and integration tests)
run: |
coverage run --source=greengrassTools -m pytest -v -s . && coverage report --show-missing --fail-under=70
coverage run --source=gdk -m pytest -v -s . && coverage report --show-missing --fail-under=70
build-on-non-windows:
runs-on: ${{ matrix.config.os }}
strategy:
Expand Down Expand Up @@ -67,4 +67,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Testing CLI (Runs both unit and integration tests)
run: |
coverage run --source=greengrassTools -m pytest -v -s . && coverage report --show-missing --fail-under=70
coverage run --source=gdk -m pytest -v -s . && coverage report --show-missing --fail-under=70
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include greengrassTools/static/*
include gdk/static/*
12 changes: 6 additions & 6 deletions greengrassTools/CLIParser.py → gdk/CLIParser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import argparse
import logging

import greengrassTools.common.consts as consts
import greengrassTools.common.model_actions as model_actions
import greengrassTools.common.parse_args_actions as parse_args_actions
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.model_actions as model_actions
import gdk.common.parse_args_actions as parse_args_actions
import gdk.common.utils as utils

from . import _version

Expand Down Expand Up @@ -96,7 +96,7 @@ def _add_arg_to_group_or_parser(self, argument, group):
Parameters
----------
argument(dict): A dictonary object which argument parameters.
Full list: greengrassTools.common.consts.arg_parameters
Full list: gdk.common.consts.arg_parameters
group(Argument group obect): Argument group object created for each group of arguments that go together.
Returns
Expand Down Expand Up @@ -143,7 +143,7 @@ def _get_arg_from_model(self, argument):
Parameters
----------
argument(dict): A dictonary object which argument parameters.
Full list: greengrassTools.common.consts.arg_parameters
Full list: gdk.common.consts.arg_parameters
Returns
-------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import subprocess as sp
from pathlib import Path

import greengrassTools.commands.component.project_utils as project_utils
import greengrassTools.common.consts as consts
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.utils as utils
import gdk.commands.component.project_utils as project_utils
import gdk.common.consts as consts
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.utils as utils
import yaml


Expand Down
22 changes: 22 additions & 0 deletions gdk/commands/component/component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def init(d_args):
import gdk.commands.component.init as init

init.run(d_args)


def build(d_args):
import gdk.commands.component.build as build

build.run(d_args)


def publish(d_args):
import gdk.commands.component.publish as publish

publish.run(d_args)


def list(d_args):
import gdk.commands.component.list as list

list.run(d_args)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import os
import shutil

import greengrassTools.commands.component.list as list
import greengrassTools.common.consts as consts
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.parse_args_actions as parse_args_actions
import greengrassTools.common.utils as utils
import gdk.commands.component.list as list
import gdk.common.consts as consts
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.parse_args_actions as parse_args_actions
import gdk.common.utils as utils
import requests


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

import greengrassTools.common.consts as consts
import greengrassTools.common.exceptions.error_messages as error_messages
import gdk.common.consts as consts
import gdk.common.exceptions.error_messages as error_messages
import requests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from pathlib import Path

import boto3
import greengrassTools.common.configuration as config_actions
import greengrassTools.common.consts as consts
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.utils as utils
import gdk.common.configuration as config_actions
import gdk.common.consts as consts
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.utils as utils
import yaml


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import logging
from pathlib import Path

import greengrassTools.commands.component.project_utils as project_utils
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.utils as utils
import gdk.commands.component.project_utils as project_utils
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.utils as utils
import yaml
from botocore.exceptions import ClientError

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from greengrassTools.commands.component import component
from gdk.commands.component import component


def _gdk_component_init(d_args):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import logging
from pathlib import Path

import greengrassTools.common.consts as consts
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.utils as utils
import jsonschema


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

import greengrassTools.common.consts as consts
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.utils as utils


def is_valid_model(cli_model, command):
Expand Down Expand Up @@ -48,7 +48,7 @@ def is_valid_argument_model(argument):
Parameters
----------
argument(dict): A dictonary object which argument parameters.
Full list: greengrassTools.common.consts.arg_parameters
Full list: gdk.common.consts.arg_parameters
Returns
-------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

import greengrassTools.CLIParser
import greengrassTools.commands.methods as command_methods
import greengrassTools.common.consts as consts
import gdk.CLIParser
import gdk.commands.methods as command_methods
import gdk.common.consts as consts


def run_command(args_namespace):
Expand Down Expand Up @@ -89,7 +89,7 @@ def conflicting_arg_groups(command_args, command):
-------
(bool) Returns True if the command arguments conflict. Else False.
"""
cli_model = greengrassTools.CLIParser.cli_tool.cli_model
cli_model = gdk.CLIParser.cli_tool.cli_model
conf_args_dict = _dic_of_conflicting_args(cli_model, command)
logging.debug("Checking if arguments in the command conflict.")
return check_command_args_with_conflicting_args(command_args, conf_args_dict)
Expand Down
6 changes: 3 additions & 3 deletions greengrassTools/common/utils.py → gdk/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
from pathlib import Path

import greengrassTools
import gdk


def get_static_file_path(file_name):
Expand All @@ -17,8 +17,8 @@ def get_static_file_path(file_name):
-------
file_path(Path): Returns absolute path of the file if it exists. Else None
"""
greengrassTools_module_dir = Path(greengrassTools.__file__).resolve().parent
file_path = greengrassTools_module_dir.joinpath("static").joinpath(file_name).resolve()
gdk_module_dir = Path(gdk.__file__).resolve().parent
file_path = gdk_module_dir.joinpath("static").joinpath(file_name).resolve()

if file_exists(file_path):
return file_path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions greengrassTools/commands/component/component.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

import greengrassTools.common.consts as consts
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.utils as utils
import jsonschema


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import greengrassTools.common.consts as consts
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.utils as utils


def test_get_static_file_path_cli_schema():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import greengrassTools.common.consts as consts
import greengrassTools.common.model_actions as model_actions
import greengrassTools.common.utils as utils
import gdk.common.consts as consts
import gdk.common.model_actions as model_actions
import gdk.common.utils as utils


def test_is_valid_model():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import argparse
import logging

import greengrassTools.commands.methods as methods
import greengrassTools.common.parse_args_actions as actions
import gdk.commands.methods as methods
import gdk.common.parse_args_actions as actions
import pytest


Expand All @@ -13,7 +13,7 @@ def test_run_command_with_valid_namespace_without_debug(mocker):
spy_call_action_by_name = mocker.spy(actions, "call_action_by_name")
spy_get_method_from_command = mocker.spy(actions, "get_method_from_command")
spy_logger = mocker.spy(logging, "basicConfig")
mock_component_init = mocker.patch("greengrassTools.commands.methods._gdk_component_init", return_value=None)
mock_component_init = mocker.patch("gdk.commands.methods._gdk_component_init", return_value=None)
actions.run_command(args_namespace)
assert mock_component_init.call_count == 1
assert spy_component_build.call_count == 0
Expand All @@ -30,7 +30,7 @@ def test_run_command_with_valid_debug_enabled(mocker):
spy_component_build = mocker.spy(methods, "_gdk_component_build")
spy_call_action_by_name = mocker.spy(actions, "call_action_by_name")
spy_get_method_from_command = mocker.spy(actions, "get_method_from_command")
mock_component_init = mocker.patch("greengrassTools.commands.methods._gdk_component_init", return_value=None)
mock_component_init = mocker.patch("gdk.commands.methods._gdk_component_init", return_value=None)

spy_logging_ = mocker.spy(logging.getLogger(), "setLevel")
actions.run_command(args_namespace)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import greengrassTools.CLIParser as CLIParser
import greengrassTools.common.exceptions.error_messages as error_messages
import greengrassTools.common.parse_args_actions as parse_args_actions
import gdk.CLIParser as CLIParser
import gdk.common.exceptions.error_messages as error_messages
import gdk.common.parse_args_actions as parse_args_actions
import pytest


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import greengrassTools.commands.component.project_utils as project_utils
import greengrassTools.common.consts as consts
import greengrassTools.common.utils as utils
import gdk.commands.component.project_utils as project_utils
import gdk.common.consts as consts
import gdk.common.utils as utils


def test_get_static_file_path_supported_builds():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import greengrassTools.CLIParser as CLIParser
import greengrassTools.common.parse_args_actions as parse_args_actions
import gdk.CLIParser as CLIParser
import gdk.common.parse_args_actions as parse_args_actions


def test_main_parse_args_init(mocker):
mock_component_init = mocker.patch("greengrassTools.commands.component.component.init", return_value=None)
mock_component_init = mocker.patch("gdk.commands.component.component.init", return_value=None)
parse_args_actions.run_command(CLIParser.cli_parser.parse_args(["component", "init", "-d"]))
assert mock_component_init.called


def test_main_parse_args_case_insenstive_language(mocker):
mocker.patch("greengrassTools.commands.component.component.init", return_value=None)
mocker.patch("gdk.commands.component.component.init", return_value=None)
x = CLIParser.cli_parser.parse_args(["component", "init", "-l", "PYTHON", "-d"])
assert x.language == "python"


def test_main_parse_args_build(mocker):
mock_component_build = mocker.patch("greengrassTools.commands.component.component.build", return_value=None)
mock_component_build = mocker.patch("gdk.commands.component.component.build", return_value=None)
parse_args_actions.run_command(CLIParser.cli_parser.parse_args(["component", "build", "-d"]))
assert mock_component_build.called


def test_main_parse_args_publish(mocker):
mock_component_publish = mocker.patch("greengrassTools.commands.component.component.publish", return_value=None)
mock_component_publish = mocker.patch("gdk.commands.component.component.publish", return_value=None)
parse_args_actions.run_command(CLIParser.cli_parser.parse_args(["component", "publish", "-d"]))
assert mock_component_publish.called


def test_main_parse_args_list(mocker):
mock_component_list = mocker.patch("greengrassTools.commands.component.component.list", return_value=None)
mock_component_list = mocker.patch("gdk.commands.component.component.list", return_value=None)
args = CLIParser.cli_parser.parse_args(["component", "list", "--template", "-d"])
parse_args_actions.run_command(args)
assert mock_component_list.called
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
url = "https://aws.amazon.com/greengrass/"
short_description = "Greengrass tools CLI for developing greengrass components."
long_description = "Greengrass CLI Tool for creating Greengrass components."
version_file = "greengrassTools/_version.py"
version_file = "gdk/_version.py"
cli_name = "gdk"
key_words = "aws iot greengrass cli component"
license = "Apache-2.0"
Expand All @@ -21,7 +21,7 @@
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
]
entry_points = {"console_scripts": ["gdk = greengrassTools.CLIParser:main"]}
entry_points = {"console_scripts": ["gdk = gdk.CLIParser:main"]}


def get_requirements():
Expand Down
Loading

0 comments on commit 5f06744

Please sign in to comment.