Пример #1
0
def test_updated_setter_bad_string_data():
    obj = PackMetaData(PACK_METADATA)
    original_updated_date = obj.updated

    obj.updated = 'Obviously not a date'

    assert obj.updated == original_updated_date
Пример #2
0
def test_author_getter(caplog, support, author, expected_author, expected_log):
    obj = PackMetaData(PACK_METADATA)
    obj.support = support
    obj.author = author

    assert obj.author == expected_author
    assert expected_log in caplog.text
Пример #3
0
def test_legacy_setter():
    obj = PackMetaData(PACK_METADATA)

    obj.legacy = False
    assert not obj.legacy

    obj.legacy = True
    assert obj.legacy
Пример #4
0
def test_updated_setter_datetime():
    obj = PackMetaData(PACK_METADATA)

    new_date_time = datetime(2020, 12, 31, 23, 59, 59)

    obj.updated = new_date_time

    assert obj.updated == new_date_time
Пример #5
0
def test_support_details_getter(url, support, email, expected_url,
                                expected_email):
    obj = PackMetaData(PACK_METADATA)
    obj.url = url
    obj.support = support
    obj.email = email

    support_details = obj.support_details

    assert expected_url == support_details.get('url')
    assert expected_email == support_details.get('email')
Пример #6
0
    def pack_metadata(self) -> Optional[PackMetaData]:
        obj = None
        file = self._path / "pack_metadata.json"
        if file.exists():
            obj = PackMetaData(file)

        return obj
Пример #7
0
 def __init__(self, path: Union[str, Path]):
     self._path = Path(path)
     # in case the given path are a Pack and not zipped pack - we init the metadata from the pack
     if not str(path).endswith('.zip'):
         self._metadata = PackMetaData(self._path.joinpath('metadata.json'))
     self._filter_items_by_id_set = False
     self._pack_info_from_id_set: Dict[Any, Any] = {}
Пример #8
0
def test_dump_with_price(mocker):
    def mock_json_dump(file_content, metadata_file, indent):
        assert file_content['premium'] is not None
        assert file_content['vendorId']
        assert file_content['vendorName']

    import json
    import builtins

    obj = PackMetaData(PACK_METADATA)
    obj.price = 1
    obj.premium = True
    obj.vendor_id = 'id'
    obj.vendor_name = 'name'

    mocker.patch.object(builtins, 'open', autospec=True)
    mocker.patch.object(json, 'dump', side_effect=mock_json_dump)

    obj.dump('metadata_file')
Пример #9
0
 def __init__(self, path: Union[str, Path]):
     self._path = Path(path)
     self._metadata = PackMetaData(self._path.joinpath('metadata.json'))
Пример #10
0
def test_prefix():
    obj = PackMetaData(PACK_METADATA)
    assert obj.normalize_file_name() == PACK_METADATA.name
Пример #11
0
def test_price_setter_bad_int(new_price, expected_price):
    obj = PackMetaData(PACK_METADATA)

    obj.price = new_price

    assert obj.price == expected_price