Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.1.0.dev1
current_version = 2.1.0.dev2
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:

- name: Run flake8 on test directory
working-directory: ${{ matrix.package }}
run: python -m flake8 test/main/python --max-line-length 88
run: python -m flake8 src/test/python --max-line-length 88

#format:
#name: Check format ${{ matrix.package}}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/python/dlpx/virtualization/common/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
2 changes: 1 addition & 1 deletion dvp/src/main/python/dlpx/virtualization/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
2 changes: 1 addition & 1 deletion libs/src/main/python/dlpx/virtualization/libs/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0.dev1
2.1.0.dev2
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,23 @@ def prepare_upload_artifact(plugin_config_content, src_dir, schemas, manifest):
if plugin_config_content.get('externalVersion'):
artifact['externalVersion'] = plugin_config_content['externalVersion']

if plugin_config_content.get('luaName'):
if plugin_config_content.get(
'luaName') and not plugin_config_content.get('minimumLuaVersion'):
raise exceptions.UserError(
'Failed to process property "luaName" without "minimumLuaVersion" '
'set in the plugin config.')

if plugin_config_content.get('minimumLuaVersion') and not \
plugin_config_content.get('luaName'):
raise exceptions.UserError(
'Failed to process property "minimumLuaVersion" without "luaName" '
'set in the plugin config.')

if plugin_config_content.get('luaName') and plugin_config_content.get(
'minimumLuaVersion'):
artifact['luaName'] = plugin_config_content['luaName']
artifact['minimumLuaVersion'] = plugin_config_content[
'minimumLuaVersion']

return artifact

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"luaName": {
"type": "string",
"pattern": "^[a-z0-9_:-]+$"
},
"minimumLuaVersion": {
"type": "string",
"pattern": "^([0-9]+)\\.([0-9]+)$"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"luaName": {
"type": "string",
"pattern": "^[a-z0-9_:-]+$"
},
"minimumLuaVersion": {
"type": "string",
"pattern": "^([0-9]+)\\.([0-9]+)$"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ def test_zip_and_encode_source_files_invalid_dir(src_dir):

@staticmethod
@mock.patch('compileall.compile_dir')
def test_zip_and_encode_source_files_compileall_fail(mock_compile, src_dir):
def test_zip_and_encode_source_files_compileall_fail(
mock_compile, src_dir):
mock_compile.return_value = 0
with pytest.raises(exceptions.UserError) as err_info:
build.zip_and_encode_source_files(src_dir)
Expand Down Expand Up @@ -655,10 +656,46 @@ def test_build_number_parameter(plugin_config_content, src_dir,
@staticmethod
@pytest.mark.parametrize('lua_name, expected', [
pytest.param('lua-toolkit-1', 'lua-toolkit-1'),
pytest.param(None, None)
pytest.param('nix_staged_python', 'nix_staged_python')
])
def test_lua_name_parameter(plugin_config_content, src_dir,
schema_content, expected):
upload_artifact = build.prepare_upload_artifact(
plugin_config_content, src_dir, schema_content, {})
assert expected == upload_artifact.get('luaName')

@staticmethod
@pytest.mark.parametrize(
'minimum_lua_version, expected',
[pytest.param('2.3', '2.3'),
pytest.param('2.4', '2.4')])
def test_minimum_lua_version_parameter(plugin_config_content, src_dir,
schema_content, expected):
upload_artifact = build.prepare_upload_artifact(
plugin_config_content, src_dir, schema_content, {})
assert expected == upload_artifact.get('minimumLuaVersion')

@staticmethod
def test_build_lua_name_without_lua_name(
plugin_config_content_missing_lua_name, src_dir, schema_content):
with pytest.raises(exceptions.UserError) as err_info:
build.prepare_upload_artifact(
plugin_config_content_missing_lua_name, src_dir,
schema_content, {})

message = err_info.value.message
assert ('Failed to process property "minimumLuaVersion" without '
'"luaName" set in the plugin config.' in message)

@staticmethod
def test_build_lua_name_without_minimum_lua_version(
plugin_config_content_missing_minimum_lua_version, src_dir,
schema_content):
with pytest.raises(exceptions.UserError) as err_info:
build.prepare_upload_artifact(
plugin_config_content_missing_minimum_lua_version, src_dir,
schema_content, {})

message = err_info.value.message
assert ('Failed to process property "luaName" without '
'"minimumLuaVersion" set in the plugin config.' in message)
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,27 @@ def httpretty_enabled():

JOB_RESP_FAIL = (('{"type": "OKResult", "status": "OK", "result": '
'{"jobState": "FAILED", "events": []}}'), {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})

JOB_RESP_TIMED_OUT = (('{"type": "OKResult", "status": "OK", "result": '
'{"jobState": "RUNNING", "events": []}}'), {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Cache-Control': 'max-age=0',
'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT',
'Content-Type': 'application/json',
'Content-Length': '71',
'Date': 'Mon, 09 Mar 2020 12:09:27 GMT'
})

PLUGIN_RESP_SUCCESS = (
'{"type": "ListResult", "status": "OK", "result": ['
Expand Down
123 changes: 122 additions & 1 deletion tools/src/test/python/dlpx/virtualization/_internal/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def artifact_file_created():
@pytest.fixture
def plugin_config_content(plugin_id, plugin_name, external_version, language,
host_types, plugin_type, entry_point, src_dir,
schema_file, manual_discovery, build_number, lua_name):
schema_file, manual_discovery, build_number,
lua_name, minimum_lua_version):
"""
This fixutre creates the dict expected in the properties yaml file the
customer must provide for the build and compile commands.
Expand All @@ -181,6 +182,63 @@ def plugin_config_content(plugin_id, plugin_name, external_version, language,
'rootSquashEnabled': True,
}

if plugin_id:
config['id'] = plugin_id

if plugin_name:
config['name'] = plugin_name

if external_version:
config['externalVersion'] = external_version

if language:
config['language'] = language

if host_types:
config['hostTypes'] = host_types

if plugin_type:
config['pluginType'] = plugin_type

if entry_point:
config['entryPoint'] = entry_point

if src_dir:
config['srcDir'] = src_dir

if schema_file:
config['schemaFile'] = schema_file

# Here we do an 'is not None' check because we will be passing in
# booleans as a parameter in tests.
if manual_discovery is not None:
config['manualDiscovery'] = manual_discovery

if build_number:
config['buildNumber'] = build_number

if lua_name:
config['luaName'] = lua_name

if minimum_lua_version:
config['minimumLuaVersion'] = minimum_lua_version

return config


@pytest.fixture
def plugin_config_content_missing_minimum_lua_version(
plugin_id, plugin_name, external_version, language, host_types,
plugin_type, entry_point, src_dir, schema_file, manual_discovery,
build_number, lua_name):
"""
This fixture is missing a minimumLuaVersion while luaName is defined.
"""
config = {
'defaultLocale': 'en-us',
'rootSquashEnabled': True,
}

if plugin_id:
config['id'] = plugin_id

Expand Down Expand Up @@ -222,6 +280,62 @@ def plugin_config_content(plugin_id, plugin_name, external_version, language,
return config


@pytest.fixture
def plugin_config_content_missing_lua_name(plugin_id, plugin_name,
external_version, language,
host_types, plugin_type,
entry_point, src_dir, schema_file,
manual_discovery, build_number,
minimum_lua_version):
"""
This fixture is missing a minimumLuaVersion while luaName is defined.
"""
config = {
'defaultLocale': 'en-us',
'rootSquashEnabled': True,
}

if plugin_id:
config['id'] = plugin_id

if plugin_name:
config['name'] = plugin_name

if external_version:
config['externalVersion'] = external_version

if language:
config['language'] = language

if host_types:
config['hostTypes'] = host_types

if plugin_type:
config['pluginType'] = plugin_type

if entry_point:
config['entryPoint'] = entry_point

if src_dir:
config['srcDir'] = src_dir

if schema_file:
config['schemaFile'] = schema_file

# Here we do an 'is not None' check because we will be passing in
# booleans as a parameter in tests.
if manual_discovery is not None:
config['manualDiscovery'] = manual_discovery

if build_number:
config['buildNumber'] = build_number

if minimum_lua_version:
config['minimumLuaVersion'] = minimum_lua_version

return config


@pytest.fixture
def plugin_id():
return '16bef554-9470-11e9-b2e3-8c8590d4a42c'
Expand Down Expand Up @@ -282,6 +396,11 @@ def lua_name():
return 'lua-toolkit-1'


@pytest.fixture
def minimum_lua_version():
return "2.3"


@pytest.fixture
def artifact_manual_discovery():
return True
Expand Down Expand Up @@ -570,6 +689,7 @@ def basic_artifact_content(engine_api, virtual_source_definition,
'rootSquashEnabled': True,
'buildNumber': '2',
'luaName': 'lua-toolkit-1',
'minimumLuaVersion': '2.3',
'sourceCode': 'UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==',
'manifest': {}
}
Expand Down Expand Up @@ -618,6 +738,7 @@ def artifact_content(engine_api, virtual_source_definition,
'rootSquashEnabled': True,
'buildNumber': '2',
'luaName': 'lua-toolkit-1',
'minimumLuaVersion': '2.3',
'manifest': {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TestPackageUtil:
@staticmethod
def test_get_version():
assert package_util.get_version() == '2.1.0.dev1'
assert package_util.get_version() == '2.1.0.dev2'

@staticmethod
def test_get_virtualization_api_version():
Expand Down
Loading