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

get_upstream_artifacts_full_paths_per_task_id(): Add test to ensure s… #245

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 31 additions & 6 deletions scriptworker/test/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,24 @@ async def foo(_, url, path, **kwargs):

def test_get_upstream_artifacts_full_paths_per_task_id(context):
artifacts_to_succeed = [{
'paths': ['public/file_a'],
'paths': ['public/file_a1'],
'taskId': 'dependency1',
'taskType': 'signing',
}, {
'paths': ['public/file_b'],
'paths': ['public/file_b1', 'public/file_b2'],
'taskId': 'dependency2',
'taskType': 'signing',
}, {
'paths': ['some_other_folder/file_c'],
'taskId': 'dependency3',
'taskType': 'signing',
}, {
# Case where the same taskId was given. In some occasion we may want to split
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, this is neat, wasn't sure this is possible.

# upstreamArtifacts of the same taskId into 2. For instance: 1 taskId with a given
# parameter (like beetmover's "locale") but not the other
'paths': ['public/file_a2'],
'taskId': 'dependency1',
'taskType': 'signing',
}]

context.task['payload'] = {
Expand All @@ -241,14 +252,28 @@ def test_get_upstream_artifacts_full_paths_per_task_id(context):
context.task['payload']['upstreamArtifacts'].extend(artifacts_to_succeed)
for artifact in artifacts_to_succeed:
folder = os.path.join(context.config['work_dir'], 'cot', artifact['taskId'])
os.makedirs(os.path.join(folder, 'public'))
touch(os.path.join(folder, artifact['paths'][0]))

for path in artifact['paths']:
try:
os.makedirs(os.path.join(folder, os.path.dirname(path)))
except FileExistsError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

touch(os.path.join(folder, path))

succeeded_artifacts, failed_artifacts = get_upstream_artifacts_full_paths_per_task_id(context)

assert succeeded_artifacts == {
'dependency1': [os.path.join(context.config['work_dir'], 'cot', 'dependency1', 'public', 'file_a')],
'dependency2': [os.path.join(context.config['work_dir'], 'cot', 'dependency2', 'public', 'file_b')],
'dependency1': [
os.path.join(context.config['work_dir'], 'cot', 'dependency1', 'public', 'file_a1'),
os.path.join(context.config['work_dir'], 'cot', 'dependency1', 'public', 'file_a2'),
],
'dependency2': [
os.path.join(context.config['work_dir'], 'cot', 'dependency2', 'public', 'file_b1'),
os.path.join(context.config['work_dir'], 'cot', 'dependency2', 'public', 'file_b2'),
],
'dependency3': [
os.path.join(context.config['work_dir'], 'cot', 'dependency3', 'some_other_folder', 'file_c'),
],
}
assert failed_artifacts == {
'failedDependency1': ['public/failed_optional_file1'],
Expand Down