Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions connect/cli/plugins/product/clone.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from datetime import datetime
from tempfile import TemporaryDirectory

from click import ClickException
from connect.client import ClientError
from fs.tempfs import TempFS
from openpyxl import load_workbook

from connect.cli.plugins.product.export import dump_product
Expand All @@ -20,9 +20,17 @@
from connect.cli.plugins.shared.utils import get_translation_attributes_sheets


class _TempDir:
# ponytail: stdlib stand-in for the archived pyfilesystem2 TempFS, which broke
# on setuptools>=81 (pkg_resources removed). Cleaned up on garbage collection.
def __init__(self, identifier):
self._tmp = TemporaryDirectory(suffix=identifier)
self.root_path = self._tmp.name


class ProductCloner:
def __init__(self, config, source_account, destination_account, product_id, progress, stats):
self.fs = TempFS(identifier=f'_clone_{product_id}')
self.fs = _TempDir(f'_clone_{product_id}')
self.config = config
self.source_account = source_account if source_account else config.active.id
self.destination_account = destination_account if destination_account else config.active.id
Expand Down
41 changes: 7 additions & 34 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ connect-eaas-core = ">=37.0"
rich = "^12.4.1"
poetry-core = "^1.3.0"
uvloop = { version = "^0.22.0", markers = "sys_platform == \"linux\" or sys_platform == \"darwin\"" }
fs = "^2.4.12"
pyyaml = "^6.0"
# interrogatio (and other deps) import the legacy pkg_resources API, removed in setuptools 81.
setuptools = "<81"

[tool.poetry.group.test.dependencies]
black = "23.*"
Expand Down
19 changes: 16 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import pytest
import responses
from fs.tempfs import TempFS
from openpyxl import load_workbook
from responses.registries import OrderedRegistry

Expand All @@ -24,8 +23,22 @@


@pytest.fixture(scope='function')
def fs():
return TempFS()
def fs(tmp_path):
# ponytail: pytest's tmp_path (auto-cleaned) replaces pyfilesystem2 TempFS;
# tests only need root_path plus these three path helpers, relative to the root.
class _FS:
root_path = str(tmp_path)

def makedir(self, path):
os.mkdir(os.path.join(self.root_path, path))

def makedirs(self, path):
os.makedirs(os.path.join(self.root_path, path))

def create(self, path):
open(os.path.join(self.root_path, path), 'w').close()

return _FS()


@pytest.fixture(scope='session', autouse=True)
Expand Down
Loading