-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement(cleanup): remove backend from argus client
Some cleanup work had to be done to better structure argus client for less problematic management: * Removed old db stuff, that cause confusion when searching for db/models related things. Along with old migration and prod dump scripts. * moved common modules for backend and client to `common` module next to `backend` and `client` modules * excluded `backend` module from client package. Including backend might cause import error due backend-only required packages * created unit tests for argus client package - build, install, basic import closes: #480
- Loading branch information
Showing
35 changed files
with
101 additions
and
1,700 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
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
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
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
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
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import shutil | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def test_dir(): | ||
return Path(__file__).parent | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def env_dir(test_dir): | ||
env_dir = test_dir / 'test_env' | ||
if env_dir.exists(): | ||
shutil.rmtree(env_dir) | ||
yield env_dir | ||
if env_dir.exists(): | ||
shutil.rmtree(env_dir) |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import subprocess | ||
import venv | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
def run_command(command: list[str], cwd: str = None, env=None): | ||
result = subprocess.run(command, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env) | ||
print(result.stdout) | ||
return result | ||
|
||
|
||
def create_virtualenv(env_dir: Path): | ||
venv.create(env_dir, with_pip=True) | ||
pip_path = env_dir / 'bin' / 'pip' | ||
return pip_path | ||
|
||
|
||
def extract_version_from_pyproject(pyproject_file: Path) -> str: | ||
with pyproject_file.open() as file: | ||
for line in file: | ||
if line.strip().startswith("version"): | ||
return line.split('=')[1].strip().strip('"') | ||
|
||
|
||
def test_should_build_package(): | ||
run_command(['poetry', 'build']) | ||
|
||
|
||
def test_should_create_env_and_install(test_dir: Path, env_dir: Path) -> None: | ||
pyproject_file = test_dir.parents[2] / 'pyproject.toml' | ||
version = extract_version_from_pyproject(pyproject_file) | ||
|
||
dist_dir = test_dir.parents[2] / 'dist' | ||
package_path = dist_dir / f"argus_alm-{version}-py3-none-any.whl" | ||
|
||
pip_path = create_virtualenv(env_dir) | ||
run_command([pip_path, 'install', str(package_path)]) | ||
|
||
|
||
def test_should_import_installed_package(env_dir): | ||
python_path = env_dir / 'bin' / 'python' | ||
|
||
run_command([python_path, '-c', 'import argus.client; import argus.common; ' | ||
'from argus.client.sct.client import ArgusSCTClient'], env={"PYTHONPATH": str(env_dir)}) | ||
with pytest.raises(subprocess.CalledProcessError): | ||
run_command([python_path, '-c', 'import argus.client.tests.test_package'], env={"PYTHONPATH": str(env_dir)}) |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.