Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed validation for price in pack metadata #342

Merged
merged 28 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0f2631a
Removed validation for price in pack metadata
Shellyber Apr 12, 2020
058f443
Merge branch 'master' into price-tag-fix
Shellyber Apr 12, 2020
cfdbcef
Fixing isort
Shellyber Apr 12, 2020
460c36c
Merge branch 'master' into price-tag-fix
Shellyber Apr 12, 2020
22b7de9
Merge remote-tracking branch 'origin/price-tag-fix' into price-tag-fix
Shellyber Apr 12, 2020
7ba18f4
Fixed test
Shellyber Apr 12, 2020
7ed069c
Merge branch 'master' into price-tag-fix
Shellyber Apr 13, 2020
47f8d3a
added TODO comments
Shellyber Apr 13, 2020
d96dedc
added another test
Shellyber Apr 13, 2020
878b522
Fixed json
Shellyber Apr 13, 2020
36293ce
-
Shellyber Apr 13, 2020
164e588
one more test
Shellyber Apr 13, 2020
7043487
Fixed json
Shellyber Apr 13, 2020
04d0472
-
Shellyber Apr 13, 2020
b9e9dae
And another test
Shellyber Apr 13, 2020
f1dd8f5
Added back the price, but it will not validate on it if not given
Shellyber Apr 13, 2020
1fc49e8
Removed comment
Shellyber Apr 13, 2020
01a9844
fixing isort
Shellyber Apr 13, 2020
0ad3682
removed again validation
Shellyber Apr 13, 2020
cce93c9
remove unnecessary function
Itay4 Apr 13, 2020
99ec5a1
-
Shellyber Apr 13, 2020
9b59677
isort
Shellyber Apr 13, 2020
9bb15e0
isort
Shellyber Apr 13, 2020
a339730
revert change
Shellyber Apr 13, 2020
ed50d61
added todo
Shellyber Apr 13, 2020
7c78fc8
more tests
Shellyber Apr 13, 2020
476d2a0
add test for initiator.yml_reformatting
Itay4 Apr 13, 2020
79cce26
Merge remote-tracking branch 'origin/price-tag-fix' into price-tag-fix
Itay4 Apr 13, 2020
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
31 changes: 13 additions & 18 deletions demisto_sdk/commands/common/hook_validations/pack_unique_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
import os
import re

from demisto_sdk.commands.common.constants import (API_MODULES_PACK,
PACK_METADATA_CATEGORIES,
PACK_METADATA_DEPENDENCIES,
PACK_METADATA_FIELDS,
PACK_METADATA_KEYWORDS,
PACK_METADATA_PRICE,
PACK_METADATA_TAGS,
PACK_METADATA_USE_CASES,
PACKS_PACK_IGNORE_FILE_NAME,
PACKS_PACK_META_FILE_NAME,
PACKS_README_FILE_NAME,
PACKS_WHITELIST_FILE_NAME)
from demisto_sdk.commands.common.constants import ( # PACK_METADATA_PRICE,
API_MODULES_PACK, PACK_METADATA_CATEGORIES, PACK_METADATA_DEPENDENCIES,
PACK_METADATA_FIELDS, PACK_METADATA_KEYWORDS, PACK_METADATA_TAGS,
PACK_METADATA_USE_CASES, PACKS_PACK_IGNORE_FILE_NAME,
PACKS_PACK_META_FILE_NAME, PACKS_README_FILE_NAME,
PACKS_WHITELIST_FILE_NAME)
from demisto_sdk.commands.common.tools import pack_name_to_path


Expand Down Expand Up @@ -151,12 +145,13 @@ def _is_pack_meta_file_structure_valid(self):
if not isinstance(dependencies_field, dict):
self._add_error('The dependencies field in the pack must be a dictionary.')
return False
price_field = metadata[PACK_METADATA_PRICE]
try:
int(price_field)
except Exception:
self._add_error('The price field in the pack must be a number.')
return False
# TODO: add it back after #23546 is ready.
# price_field = metadata[PACK_METADATA_PRICE]
# try:
# int(price_field)
# except Exception:
# self._add_error('The price field in the pack must be a number.')
# return False
for list_field in (PACK_METADATA_KEYWORDS, PACK_METADATA_TAGS, PACK_METADATA_CATEGORIES,
PACK_METADATA_USE_CASES):
field = metadata[list_field]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ def test_metadata_validator_valid(self, mocker):
validator = PackUniqueFilesValidator('fake')
assert validator.validate_pack_meta_file()

# TODO: add the validation for price after #23546 is ready.
@pytest.mark.parametrize('metadata', [os.path.join(FILES_PATH, 'pack_metadata_missing_fields.json'),
os.path.join(FILES_PATH, 'pack_metadata_invalid_price.json'),
# os.path.join(FILES_PATH, 'pack_metadata_invalid_price.json'),
os.path.join(FILES_PATH, 'pack_metadata_invalid_tags.json'),
os.path.join(FILES_PATH, 'pack_metadata_list.json')])
def test_metadata_validator_invalid(self, mocker, metadata):
Expand Down
8 changes: 4 additions & 4 deletions demisto_sdk/commands/init/initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def create_metadata(fill_manually: bool) -> Dict:
'certification': 'certified',
'useCases': [],
'keywords': [],
'price': '0',
# 'price': '0',
'dependencies': {},
}

Expand All @@ -232,9 +232,9 @@ def create_metadata(fill_manually: bool) -> Dict:
tags = input("\nTags of the pack, comma separated values: ")
tags_list = [t.strip() for t in tags.split(',')]
metadata['tags'] = tags_list

price = input("\nThe price of the pack: ")
metadata['price'] = price
# TODO: add it back after #23546 is ready.
# price = input("\nThe price of the pack: ")
# metadata['price'] = price

return metadata

Expand Down
10 changes: 6 additions & 4 deletions demisto_sdk/commands/init/tests/initiator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PACK_URL = 'https://www.github.com/pack'
PACK_EMAIL = 'author@mail.com'
PACK_TAGS = 'Tag1,Tag2'
PACK_PRICE = '0'
# PACK_PRICE = '0'


@pytest.fixture
Expand Down Expand Up @@ -61,6 +61,7 @@ def test_get_object_id(monkeypatch, initiator):
assert initiator.id == 'SomeIntegrationID'


# TODO: add the validation for price after #23546 is ready.
def test_create_metadata(monkeypatch, initiator):
# test create_metadata without user filling manually
pack_metadata = initiator.create_metadata(False)
Expand All @@ -82,7 +83,7 @@ def test_create_metadata(monkeypatch, initiator):
'certification': 'certified',
'useCases': [],
'keywords': [],
'price': '0',
# 'price': '0',
'dependencies': {},
}

Expand All @@ -92,7 +93,8 @@ def test_create_metadata(monkeypatch, initiator):
generate_multiple_inputs(
deque([
PACK_NAME, PACK_DESC, '1', PACK_SERVER_MIN_VERSION, PACK_AUTHOR,
PACK_URL, PACK_EMAIL, '1', PACK_TAGS, PACK_PRICE
PACK_URL, PACK_EMAIL, '1', PACK_TAGS
# PACK_PRICE
])
)
)
Expand All @@ -109,7 +111,7 @@ def test_create_metadata(monkeypatch, initiator):
'email': PACK_EMAIL,
'keywords': [],
'name': PACK_NAME,
'price': PACK_PRICE,
# 'price': PACK_PRICE,
'serverMinVersion': PACK_SERVER_MIN_VERSION,
'support': PACK_SUPPORT_OPTIONS[0],
'tags': ['Tag1', 'Tag2'],
Expand Down