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

Check for Invisible Changes (idempotency) #12

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Changes from 1 commit
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
Next Next commit
Add idempotency tests
  • Loading branch information
DLu committed Jan 11, 2024
commit a1ba53ec9b144940239c1682ffaae731a43ca4bd
14 changes: 13 additions & 1 deletion test/test_from_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def run_case(test_config, cases):
fne(pkg_obj, config=local_config)
else:
fne(pkg_obj)

components_with_changes = [comp.rel_fn for comp in pkg_obj if comp.changed]
pkg_obj.save()

s = '{:25} >> {:25} {}'.format(test_config['in'], test_config['out'],
Expand All @@ -70,7 +72,10 @@ def run_case(test_config, cases):
contents_in = pkg_in.get_contents(filename).rstrip()
contents_out = pkg_out.get_contents(filename).rstrip()

if contents_in != contents_out:
if contents_in == contents_out:
if filename in components_with_changes and test_config['in'] == test_config['out']:
problems.append(f'File {filename} has invisible changes')
else:
print(get_diff_string(contents_in, contents_out, filename))
problems.append('The contents of {} do not match!'.format(filename))

Expand All @@ -92,3 +97,10 @@ def run_case(test_config, cases):
@pytest.mark.parametrize('test_config, test_data', parameters, ids=test_ids)
def test_from_zip(test_config, test_data):
run_case(test_config, test_data)


@pytest.mark.parametrize('test_config, test_data', parameters, ids=test_ids)
def test_idempotency_from_zip(test_config, test_data):
test_config_x = dict(test_config)
test_config_x['in'] = test_config_x['out']
run_case(test_config_x, test_data)