chore(e2e_tests): make the linter happier
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import semver
|
||||
import tomlkit
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import os
|
||||
|
||||
from helpers import *
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
os.environ["GIT_AUTHOR_NAME"] = "Example user"
|
||||
|
||||
@@ -2,6 +2,3 @@ from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
app.url_map.strict_slashes = False
|
||||
|
||||
import github
|
||||
import gitlab
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import os.path
|
||||
|
||||
from app import app
|
||||
|
||||
from flask import Flask, request, abort, jsonify, make_response
|
||||
|
||||
import jinja2
|
||||
from app import app
|
||||
from flask import abort, jsonify, make_response, request
|
||||
|
||||
|
||||
def check_headers():
|
||||
@@ -48,7 +46,7 @@ def add_pagination(response, page, last_page):
|
||||
|
||||
def read_project_files(namespaces=[]):
|
||||
last_page = 4
|
||||
page = username = int(request.args.get("page", "1"))
|
||||
page = int(request.args.get("page", "1"))
|
||||
response_file = f"./github_api_page_{page}.json.j2"
|
||||
if not os.path.exists(response_file):
|
||||
return jsonify([])
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import os.path
|
||||
|
||||
from app import app
|
||||
|
||||
from flask import Flask, request, abort, jsonify, make_response
|
||||
|
||||
import jinja2
|
||||
from app import app
|
||||
from flask import abort, jsonify, make_response, request
|
||||
|
||||
|
||||
def check_headers():
|
||||
@@ -48,7 +46,7 @@ def add_pagination(response, page, last_page):
|
||||
|
||||
def read_project_files(namespaces=[]):
|
||||
last_page = 4
|
||||
page = username = int(request.args.get("page", "1"))
|
||||
page = int(request.args.get("page", "1"))
|
||||
response_file = f"./gitlab_api_page_{page}.json"
|
||||
if not os.path.exists(response_file):
|
||||
return jsonify([])
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import hashlib
|
||||
import inspect
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import hashlib
|
||||
import shutil
|
||||
import inspect
|
||||
|
||||
import git
|
||||
|
||||
@@ -176,7 +176,6 @@ class TempGitRemote:
|
||||
newobj.remoteid = remoteid
|
||||
return newobj, remoteid
|
||||
else:
|
||||
refresh = False
|
||||
if cachekey not in cls.obj:
|
||||
tmpdir = get_temporary_directory()
|
||||
shell(
|
||||
|
||||
1
e2e_tests/requirements.txt
Normal file
1
e2e_tests/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
git-python==1.0.3
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from helpers import *
|
||||
from helpers import grm
|
||||
|
||||
|
||||
def test_invalid_command():
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import toml
|
||||
import pytest
|
||||
import toml
|
||||
import yaml
|
||||
|
||||
from helpers import *
|
||||
from helpers import NonExistentPath, TempGitRepository, grm, shell
|
||||
|
||||
|
||||
def test_repos_find_nonexistent():
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
import toml
|
||||
import pytest
|
||||
import toml
|
||||
import yaml
|
||||
|
||||
from helpers import *
|
||||
|
||||
from helpers import grm
|
||||
|
||||
ALTERNATE_DOMAIN = os.environ["ALTERNATE_DOMAIN"]
|
||||
PROVIDERS = ["github", "gitlab"]
|
||||
@@ -275,9 +274,9 @@ def test_repos_find_remote_user(
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
cfg += "force_ssh = true\n"
|
||||
if override_remote_name:
|
||||
cfg += f'remote_name = "otherremote"\n'
|
||||
cfg += 'remote_name = "otherremote"\n'
|
||||
if use_owner:
|
||||
cfg += """
|
||||
[filters]
|
||||
@@ -475,7 +474,7 @@ def test_repos_find_remote_group(
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
cfg += "force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
@@ -591,7 +590,7 @@ def test_repos_find_remote_user_and_group(
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
cfg += "force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
@@ -742,7 +741,7 @@ def test_repos_find_remote_owner(
|
||||
if not worktree_default:
|
||||
cfg += f"worktree = {str(worktree).lower()}\n"
|
||||
if force_ssh:
|
||||
cfg += f"force_ssh = true\n"
|
||||
cfg += "force_ssh = true\n"
|
||||
if use_alternate_endpoint:
|
||||
cfg += f'api_url = "http://{ALTERNATE_DOMAIN}:5000/{provider}"\n'
|
||||
cfg += """
|
||||
@@ -873,13 +872,11 @@ def test_repos_find_remote_owner(
|
||||
assert repo["remotes"][0]["name"] == "origin"
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"ssh://git@example.com/myuser2/myproject3.git"
|
||||
repo["remotes"][0]["url"] == "ssh://git@example.com/myuser2/myproject3.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"https://example.com/myuser2/myproject3.git"
|
||||
)
|
||||
assert repo["remotes"][0]["url"] == "https://example.com/myuser2/myproject3.git"
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
group_namespace_1 = [t for t in output["trees"] if t["root"] == "/myroot/mygroup1"][
|
||||
@@ -923,13 +920,13 @@ def test_repos_find_remote_owner(
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup1/myproject4.git"
|
||||
== "ssh://git@example.com/mygroup1/myproject4.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"https://example.com/mygroup1/myproject4.git"
|
||||
== "https://example.com/mygroup1/myproject4.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
@@ -948,12 +945,11 @@ def test_repos_find_remote_owner(
|
||||
assert repo["remotes"][0]["name"] == "origin"
|
||||
if force_ssh:
|
||||
assert (
|
||||
repo["remotes"][0]["url"]
|
||||
== f"ssh://git@example.com/mygroup2/myproject5.git"
|
||||
repo["remotes"][0]["url"] == "ssh://git@example.com/mygroup2/myproject5.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "ssh"
|
||||
else:
|
||||
assert (
|
||||
repo["remotes"][0]["url"] == f"https://example.com/mygroup2/myproject5.git"
|
||||
repo["remotes"][0]["url"] == "https://example.com/mygroup2/myproject5.git"
|
||||
)
|
||||
assert repo["remotes"][0]["type"] == "https"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tempfile
|
||||
|
||||
from helpers import *
|
||||
from helpers import RepoTree, grm
|
||||
|
||||
|
||||
def test_repos_sync_worktree_clone():
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
import toml
|
||||
import git
|
||||
|
||||
from helpers import *
|
||||
import pytest
|
||||
from helpers import (
|
||||
NonExistentPath,
|
||||
TempGitFileRemote,
|
||||
TempGitRepository,
|
||||
checksum_directory,
|
||||
grm,
|
||||
shell,
|
||||
)
|
||||
|
||||
templates = {
|
||||
"repo_simple": {
|
||||
@@ -291,7 +298,9 @@ def test_repos_sync_unmanaged_repos(configtype):
|
||||
# this removes the prefix (root) from the path (unmanaged_repo)
|
||||
unmanaged_repo_name = os.path.relpath(unmanaged_repo, root)
|
||||
regex = f".*unmanaged.*{unmanaged_repo_name}"
|
||||
assert any([re.match(regex, l) for l in cmd.stderr.lower().split("\n")])
|
||||
assert any(
|
||||
[re.match(regex, line) for line in cmd.stderr.lower().split("\n")]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@@ -374,7 +383,7 @@ def test_repos_sync_repo_in_subdirectory(configtype):
|
||||
assert urls[0] == f"file://{remote}"
|
||||
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert not "found unmanaged repository" in cmd.stderr.lower()
|
||||
assert "found unmanaged repository" not in cmd.stderr.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@@ -419,7 +428,7 @@ def test_repos_sync_nested_clone(configtype):
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
print(cmd.stdout)
|
||||
print(cmd.stderr)
|
||||
assert not "found unmanaged repository" in cmd.stderr.lower()
|
||||
assert "found unmanaged repository" not in cmd.stderr.lower()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("configtype", ["toml", "yaml"])
|
||||
@@ -720,14 +729,14 @@ def test_repos_sync_invalid_syntax(configtype):
|
||||
with open(config.name, "w") as f:
|
||||
if configtype == "toml":
|
||||
f.write(
|
||||
f"""
|
||||
"""
|
||||
[[trees]]
|
||||
root = invalid as there are no quotes ;)
|
||||
"""
|
||||
)
|
||||
elif configtype == "yaml":
|
||||
f.write(
|
||||
f"""
|
||||
"""
|
||||
trees:
|
||||
wrong:
|
||||
indentation:
|
||||
@@ -779,8 +788,6 @@ def test_repos_sync_normal_change_to_worktree(configtype):
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
|
||||
with open(config.name, "w") as f:
|
||||
f.write(
|
||||
templates["worktree_repo_with_remote"][configtype].format(
|
||||
@@ -810,8 +817,6 @@ def test_repos_sync_worktree_change_to_normal(configtype):
|
||||
cmd = grm(["repos", "sync", "config", "--config", config.name])
|
||||
assert cmd.returncode == 0
|
||||
|
||||
git_dir = os.path.join(target, "test")
|
||||
|
||||
with open(config.name, "w") as f:
|
||||
f.write(
|
||||
templates["repo_with_remote"][configtype].format(
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
from helpers import *
|
||||
import pytest
|
||||
from helpers import (
|
||||
NonGitDir,
|
||||
TempGitRepository,
|
||||
TempGitRepositoryWorktree,
|
||||
checksum_directory,
|
||||
funcname,
|
||||
grm,
|
||||
shell,
|
||||
)
|
||||
|
||||
|
||||
def test_worktree_clean():
|
||||
@@ -153,13 +162,13 @@ def test_worktree_clean_configured_default_branch(
|
||||
with open(os.path.join(base_dir, "grm.toml"), "w") as f:
|
||||
if branch_list_empty:
|
||||
f.write(
|
||||
f"""
|
||||
"""
|
||||
persistent_branches = []
|
||||
"""
|
||||
)
|
||||
else:
|
||||
f.write(
|
||||
f"""
|
||||
"""
|
||||
persistent_branches = [
|
||||
"mybranch"
|
||||
]
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import os.path
|
||||
|
||||
from helpers import *
|
||||
import git
|
||||
from helpers import TempGitRepositoryWorktree, checksum_directory, funcname, grm, shell
|
||||
|
||||
|
||||
def test_worktree_never_clean_persistent_branches():
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
from helpers import *
|
||||
from helpers import (
|
||||
EmptyDir,
|
||||
NonGitDir,
|
||||
TempGitRepository,
|
||||
TempGitRepositoryWorktree,
|
||||
checksum_directory,
|
||||
funcname,
|
||||
grm,
|
||||
)
|
||||
|
||||
|
||||
def test_convert():
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from helpers import *
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
import git
|
||||
import pytest
|
||||
from helpers import (
|
||||
EmptyDir,
|
||||
TempGitFileRemote,
|
||||
TempGitRepositoryWorktree,
|
||||
funcname,
|
||||
grm,
|
||||
shell,
|
||||
)
|
||||
|
||||
|
||||
def test_worktree_fetch():
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from helpers import *
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
import git
|
||||
import pytest
|
||||
from helpers import TempGitRepositoryWorktree, funcname, grm, shell
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pull", [True, False])
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from helpers import *
|
||||
|
||||
import pytest
|
||||
from helpers import (
|
||||
NonGitDir,
|
||||
TempGitRepository,
|
||||
TempGitRepositoryWorktree,
|
||||
funcname,
|
||||
grm,
|
||||
shell,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("has_config", [True, False])
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from helpers import *
|
||||
import datetime
|
||||
import os.path
|
||||
|
||||
import git
|
||||
import pytest
|
||||
import datetime
|
||||
|
||||
import os.path
|
||||
from helpers import (
|
||||
TempGitRepositoryWorktree,
|
||||
checksum_directory,
|
||||
funcname,
|
||||
grm,
|
||||
shell,
|
||||
tempfile,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -151,18 +157,20 @@ def test_worktree_add(
|
||||
]
|
||||
)
|
||||
|
||||
cachefn = lambda nr: "_".join(
|
||||
[
|
||||
str(nr),
|
||||
str(default_remote),
|
||||
str(local_branch_exists),
|
||||
str(remote_branch_already_exists),
|
||||
str(remote_branch_with_prefix_already_exists),
|
||||
str(remote_count),
|
||||
str(remotes_differ),
|
||||
str(worktree_name),
|
||||
]
|
||||
)
|
||||
def cachefn(nr):
|
||||
return "_".join(
|
||||
[
|
||||
str(nr),
|
||||
str(default_remote),
|
||||
str(local_branch_exists),
|
||||
str(remote_branch_already_exists),
|
||||
str(remote_branch_with_prefix_already_exists),
|
||||
str(remote_count),
|
||||
str(remotes_differ),
|
||||
str(worktree_name),
|
||||
]
|
||||
)
|
||||
|
||||
remote1_cache_key = cachefn(1)
|
||||
remote2_cache_key = cachefn(2)
|
||||
|
||||
@@ -281,7 +289,7 @@ def test_worktree_add(
|
||||
and remotes_differ
|
||||
):
|
||||
assert (
|
||||
f"branch exists on multiple remotes, but they deviate"
|
||||
"branch exists on multiple remotes, but they deviate"
|
||||
in cmd.stderr.lower()
|
||||
)
|
||||
assert len(cmd.stderr.strip().split("\n")) == base + 1
|
||||
|
||||
Reference in New Issue
Block a user