mypy w/ burnettk cullerton
This commit is contained in:
parent
ade7a41e7b
commit
2081532f4a
2
.flake8
2
.flake8
|
@ -27,3 +27,5 @@ per-file-ignores =
|
|||
# this file overwrites methods from the logging library so we can't change them
|
||||
# and ignore long comment line
|
||||
src/spiffworkflow_backend/services/logging_service.py:N802,B950
|
||||
|
||||
tests/spiffworkflow_backend/integration/test_process_api.py:S607,S101,D103,S605
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""dev."""
|
||||
"""Dev."""
|
||||
from os import environ
|
||||
|
||||
GIT_MERGE_BRANCH = environ.get("GIT_MERGE_BRANCH", default="staging")
|
||||
GIT_USERNAME = environ.get("GIT_USERNAME", default="sartography-automated-committer")
|
||||
GIT_USER_EMAIL = environ.get("GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com")
|
||||
GIT_USER_EMAIL = environ.get(
|
||||
"GIT_USER_EMAIL", default="sartography-automated-committer@users.noreply.github.com"
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import os
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
from typing import Generator, List
|
||||
from typing import Optional
|
||||
|
||||
import pytz
|
||||
|
@ -25,9 +25,9 @@ class FileSystemService:
|
|||
PROCESS_MODEL_JSON_FILE = "process_model.json"
|
||||
|
||||
# https://stackoverflow.com/a/24176022/6090676
|
||||
@contextmanager
|
||||
@staticmethod
|
||||
def cd(newdir):
|
||||
@contextmanager
|
||||
def cd(newdir: str) -> Generator:
|
||||
"""Cd."""
|
||||
prevdir = os.getcwd()
|
||||
os.chdir(os.path.expanduser(newdir))
|
||||
|
|
|
@ -44,7 +44,7 @@ class GitService:
|
|||
return file_contents.encode("utf-8")
|
||||
|
||||
@staticmethod
|
||||
def commit(message: str, repo_path: Optional[str]) -> str:
|
||||
def commit(message: str, repo_path: Optional[str] = None) -> str:
|
||||
"""Commit."""
|
||||
repo_path_to_use = repo_path
|
||||
if repo_path is None:
|
||||
|
@ -73,10 +73,14 @@ class GitService:
|
|||
clone_dir = f"sample-process-models.{unique_hex}"
|
||||
|
||||
# clone new instance of sample-process-models, checkout branch_to_update
|
||||
destination_process_root = f"/tmp/{clone_dir}"
|
||||
os.system(
|
||||
f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}@github.com/sartography/sample-process-models.git {destination_process_root}"
|
||||
# we are adding a guid to this so the flake8 issue has been mitigated
|
||||
destination_process_root = f"/tmp/{clone_dir}" # noqa
|
||||
|
||||
cmd = (
|
||||
f"git clone https://{current_app.config['GIT_USERNAME']}:{current_app.config['GIT_USER_PASSWORD']}"
|
||||
f"@github.com/sartography/sample-process-models.git {destination_process_root}"
|
||||
)
|
||||
os.system(cmd) # noqa: S605
|
||||
with FileSystemService.cd(destination_process_root):
|
||||
# create publish branch from branch_to_update
|
||||
os.system(f"git checkout {branch_to_update}") # noqa: S605
|
||||
|
@ -84,7 +88,7 @@ class GitService:
|
|||
command = f"git show-ref --verify refs/remotes/origin/{publish_branch}"
|
||||
output = os.popen(command).read() # noqa: S605
|
||||
if output:
|
||||
os.system(f"git checkout {publish_branch}")
|
||||
os.system(f"git checkout {publish_branch}") # noqa: S605
|
||||
else:
|
||||
os.system(f"git checkout -b {publish_branch}") # noqa: S605
|
||||
|
||||
|
@ -99,10 +103,10 @@ class GitService:
|
|||
# add and commit files to publish_branch, then push
|
||||
commit_message = f"Request to publish changes to {process_model_id}, from {g.user.username}"
|
||||
cls.commit(commit_message, destination_process_root)
|
||||
os.system("git push")
|
||||
os.system("git push") # noqa
|
||||
|
||||
# build url for github page to open PR
|
||||
output = os.popen("git config --get remote.origin.url").read()
|
||||
output = os.popen("git config --get remote.origin.url").read() # noqa
|
||||
remote_url = output.strip().replace(".git", "")
|
||||
pr_url = f"{remote_url}/compare/{publish_branch}?expand=1"
|
||||
|
||||
|
|
|
@ -2664,7 +2664,7 @@ class TestProcessApi(BaseTest):
|
|||
assert "process_model.json" in listing
|
||||
assert "new_file.txt" in listing
|
||||
|
||||
modified_process_model_id = process_model_identifier.replace("/", ":")
|
||||
# modified_process_model_id = process_model_identifier.replace("/", ":")
|
||||
# response = client.post(
|
||||
# f"/v1.0/process-models/{modified_process_model_id}/publish?branch_to_update=staging",
|
||||
# headers=self.logged_in_headers(with_super_admin_user),
|
||||
|
|
Loading…
Reference in New Issue