Skip to content

Commit

Permalink
Fix product clone issue with PPU items, fix clone non-fulfillment tem…
Browse files Browse the repository at this point in the history
…plates for tiers
  • Loading branch information
Francesco Faraone committed May 25, 2023
1 parent 4a8ad9c commit 653e761
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
15 changes: 8 additions & 7 deletions connect/cli/plugins/product/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ def inject(self): # noqa: CCR001

synchronizer.open(input_file, 'General Information')
synchronizer.sync()
synchronizer = ItemSynchronizer(

synchronizer = CapabilitiesSynchronizer(
self.config.active.client,
self.progress,
self.stats,
)
product_id = synchronizer.open(input_file, 'Items')
items = self.config.active.client.products[product_id].items.all()
for item in items:
self.config.active.client.products[product_id].items[item['id']].delete()
synchronizer.open(input_file, 'Capabilities')
synchronizer.sync()

synchronizer = CapabilitiesSynchronizer(
synchronizer = ItemSynchronizer(
self.config.active.client,
self.progress,
self.stats,
)
synchronizer.open(input_file, 'Capabilities')
product_id = synchronizer.open(input_file, 'Items')
items = self.config.active.client.products[product_id].items.all()
for item in items:
self.config.active.client.products[product_id].items[item['id']].delete()
synchronizer.sync()

templates = self.config.active.client.products[product_id].templates.all()
Expand Down
4 changes: 0 additions & 4 deletions connect/cli/plugins/product/sync/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ def _validate_row(data):
f'Valid template types are `pending`, `fulfillment` or `inquiring`. Provided '
f'{data.type}.',
)
if (data.scope == 'tier1' or data.scope == 'tier2') and data.type != 'fulfillment':
errors.append(
'Tier templates must be fulfillment type only',
)
if not data.title or not data.content:
errors.append(
'Title and Content are required',
Expand Down
29 changes: 0 additions & 29 deletions tests/plugins/product/sync/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,35 +83,6 @@ def test_invalid_type(mocker, fs, get_sync_templates_env):
}


def test_invalid_tier_type(mocker, fs, get_sync_templates_env):
get_sync_templates_env['Templates']['C2'] = 'create'
get_sync_templates_env['Templates']['D2'] = 'tier1'
get_sync_templates_env['Templates']['E2'] = 'inquire'
get_sync_templates_env.save(f'{fs.root_path}/test.xlsx')

stats = SynchronizerStats()
synchronizer = TemplatesSynchronizer(
client=ConnectClient(
use_specs=False,
api_key='ApiKey SU:123',
endpoint='https://localhost/public/v1',
),
progress=mocker.MagicMock(),
stats=stats,
)

synchronizer.open(f'{fs.root_path}/test.xlsx', 'Templates')
synchronizer.sync()

assert stats['Templates'].get_counts_as_dict() == {
'processed': 1, 'created': 0, 'updated': 0,
'deleted': 0, 'skipped': 0, 'errors': 1,
}
assert stats['Templates']._row_errors == {
2: ['Tier templates must be fulfillment type only'],
}


def test_invalid_no_title(mocker, fs, get_sync_templates_env):
get_sync_templates_env['Templates']['C2'] = 'create'
get_sync_templates_env['Templates']['B2'] = None
Expand Down

0 comments on commit 653e761

Please sign in to comment.