-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixing errors in config file integration testing
- Loading branch information
Showing
3 changed files
with
66 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,11 +247,17 @@ def test_cli_analyze_incorrect_arguments_correct_config(tmpdir): | |
|
||
def test_cli_analyze_url_config(cwd): | ||
"""Confirm that using the command-line interface correctly handles a valid URL configuration.""" | ||
# get current git branch to use | ||
git_directory = cwd / Path(".git") / Path("HEAD") | ||
branch = re.findall("(?:ref: refs/heads/).+", git_directory.read_text())[0] | ||
git_HEAD = cwd / Path(".git") / Path("HEAD") | ||
git_config = cwd / Path(".git") / Path("config") | ||
# get current git branch to use by reading local git data | ||
branch = re.match("(?:ref: refs/heads/)(\S+)", git_HEAD.read_text()).group(1) | ||
# get the git repo ("owner/repo") by reading local git data | ||
owner_slash_repo = re.search( | ||
'(?:\[remote "origin"\]\n\turl = ([email protected]:|https://github.com/))(\S+?)(?:\.git)', | ||
git_config.read_text(), | ||
).group(2) | ||
# use current git branch to fetch config files from raw text repo files | ||
config_url = f"https://raw.githubusercontent.com/AstuteSource/chasten/{branch}/.chasten/config_url_checks_file.yml" | ||
config_url = f"https://raw.githubusercontent.com/{owner_slash_repo}/{branch}/.chasten/config_url_checks_file.yml" | ||
project_name = "test" | ||
# call the analyze command | ||
result = runner.invoke( | ||
|
@@ -260,7 +266,7 @@ def test_cli_analyze_url_config(cwd): | |
"analyze", | ||
project_name, | ||
"--search-path", | ||
test_one, | ||
cwd, | ||
"--config", | ||
config_url, | ||
"--verbose", | ||
|
@@ -269,13 +275,19 @@ def test_cli_analyze_url_config(cwd): | |
assert result.exit_code == 0 | ||
|
||
|
||
def test_cli_analyze_url_config_with_local_checks_file(): | ||
def test_cli_analyze_url_config_with_local_checks_file(cwd): | ||
"""Confirm that using the command-line interface aborts execution when given a URL config that uses a local file path to specify checks files.""" | ||
# get current git branch to use | ||
git_directory = cwd / Path(".git") / Path("HEAD") | ||
branch = re.findall("(?:ref: refs/heads/).+", git_directory.read_text())[0] | ||
git_HEAD = cwd / Path(".git") / Path("HEAD") | ||
git_config = cwd / Path(".git") / Path("config") | ||
# get current git branch to use by reading local git data | ||
branch = re.match("(?:ref: refs/heads/)(\S+)", git_HEAD.read_text()).group(1) | ||
# get the git repo ("owner/repo") by reading local git data | ||
owner_slash_repo = re.search( | ||
'(?:\[remote "origin"\]\n\turl = ([email protected]:|https://github.com/))(\S+?)(?:\.git)', | ||
git_config.read_text(), | ||
).group(2) | ||
# use current git branch to fetch config files from raw text repo files | ||
config_url = f"https://raw.githubusercontent.com/AstuteSource/chasten/{branch}/.chasten/config.yml" | ||
config_url = f"https://raw.githubusercontent.com/{owner_slash_repo}/{branch}/.chasten/config.yml" | ||
project_name = "test" | ||
# call the analyze command | ||
result = runner.invoke( | ||
|
@@ -284,7 +296,7 @@ def test_cli_analyze_url_config_with_local_checks_file(): | |
"analyze", | ||
project_name, | ||
"--search-path", | ||
test_one, | ||
cwd, | ||
"--config", | ||
config_url, | ||
"--verbose", | ||
|
@@ -305,16 +317,16 @@ def test_cli_analyze_local_config_with_url_checks_file(cwd): | |
"analyze", | ||
project_name, | ||
"--search-path", | ||
test_one, | ||
cwd, | ||
"--config", | ||
config_url, | ||
configuration_file, | ||
"--verbose", | ||
], | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_cli_analyze_local_config_with_url_and_filesystem_checks_files(cwd): | ||
def test_cli_analyze_local_config_with_url_and_local_checks_files(cwd): | ||
"""Confirm that using the command-line interface correctly handles a local config that references a combination of URL endpoints and local files for each checks file.""" | ||
configuration_file = cwd / Path(".chasten") / Path("config_url_and_local_checks_files.yml") | ||
project_name = "test" | ||
|
@@ -325,22 +337,28 @@ def test_cli_analyze_local_config_with_url_and_filesystem_checks_files(cwd): | |
"analyze", | ||
project_name, | ||
"--search-path", | ||
test_one, | ||
cwd, | ||
"--config", | ||
config_url, | ||
configuration_file, | ||
"--verbose", | ||
], | ||
) | ||
assert result.exit_code == 0 | ||
|
||
|
||
def test_cli_analyze_url_config_with_url_and_filesystem_checks_files(): | ||
def test_cli_analyze_url_config_with_url_and_local_checks_files(cwd): | ||
"""Confirm that using the command-line interface aborts execution when given a URL config that references a combination of URL endpoints and local files for each checks file.""" | ||
# get current git branch to use | ||
git_directory = cwd / Path(".git") / Path("HEAD") | ||
branch = re.findall("(?:ref: refs/heads/).+", git_directory.read_text())[0] | ||
git_HEAD = cwd / Path(".git") / Path("HEAD") | ||
git_config = cwd / Path(".git") / Path("config") | ||
# get current git branch to use by reading local git data | ||
branch = re.match("(?:ref: refs/heads/)(\S+)", git_HEAD.read_text()).group(1) | ||
# get the git repo ("owner/repo") by reading local git data | ||
owner_slash_repo = re.search( | ||
'(?:\[remote "origin"\]\n\turl = ([email protected]:|https://github.com/))(\S+?)(?:\.git)', | ||
git_config.read_text(), | ||
).group(2) | ||
# use current git branch to fetch config files from raw text repo files | ||
config_url = f"https://raw.githubusercontent.com/AstuteSource/chasten/{branch}/.chasten/config_url_and_local_checks_files.yml" | ||
config_url = f"https://raw.githubusercontent.com/{owner_slash_repo}/{branch}/.chasten/config_url_and_local_checks_files.yml" | ||
project_name = "test" | ||
# call the analyze command | ||
result = runner.invoke( | ||
|
@@ -349,7 +367,7 @@ def test_cli_analyze_url_config_with_url_and_filesystem_checks_files(): | |
"analyze", | ||
project_name, | ||
"--search-path", | ||
test_one, | ||
cwd, | ||
"--config", | ||
config_url, | ||
"--verbose", | ||
|