Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@with_setup(usual_setup_func, usual_teardown_func)
def test_simple():
create_file('xxx', '1/a')
create_file('xxx', '2/a')
create_file('xxx', 'a')
head, *data, footer = run_rmlint('-p -D --rank-by A')
assert 2 == sum(find['type'] == 'duplicate_dir' for find in data)
# One original, one dupe
assert 1 == sum(find['type'] == 'duplicate_file' for find in data if find['is_original'])
assert 1 == sum(find['type'] == 'duplicate_file' for find in data if not find['is_original'])
assert data[0]['size'] == 3
# -S A should sort in reverse lexigraphic order.
assert data[0]['is_original']
@with_setup(usual_setup_func, usual_teardown_func)
def test_hidden():
create_file('xxx', '.a/1')
create_file('xxx', '.b/1')
create_file('xxx', '.1')
head, *data, footer = run_rmlint('--no-hidden')
assert footer['duplicates'] == 0
assert footer['ignored_folders'] == 2
assert footer['ignored_files'] == 3
assert footer['duplicate_sets'] == 0
@attr('fails_on_rgw')
@nose.with_setup(
setup=lambda: nuke_prefixed_buckets(prefix='a'+prefix),
teardown=lambda: nuke_prefixed_buckets(prefix='a'+prefix),
)
def test_bucket_create_naming_good_starts_alpha():
check_good_bucket_name('foo', _prefix='a'+prefix)
@with_setup(setup)
def test_jsonschema_version(self):
"""
Checks for the version of json installed
"""
import jsonschema
version = float(jsonschema.__version__[0:3]) >= 2.5
assert_equal(version,True)
@with_setup(clear_db)
def test_fails2():
authorize()
text = add_text()[0]
authorize('forbidden')
c.get(app.url_for(':text.delete', id=text['_id']), code=403)
authorize()
c.get(app.url_for(':text.delete', id=text['_id']))
c.post(app.url_for(':text.bit', id=text['_id']), data=DATA, code=404)
c.get(app.url_for(':text.edit', id=text['_id']), query_string={
'node': 'wrong-node'
}, code=404)
@nose.with_setup(teardown=_clear_custom_headers)
def test_bucket_create_bad_ua_empty():
_add_custom_headers({'User-Agent': ''})
bucket = get_new_bucket()
@with_setup(clean_auth)
def test_logout():
test_login()
c.get(app.url_for(':auth.logout'), code=200, follow_redirects=True)
aye('==', app.url_for(':home'), c.path)
aye('in', app.url_for(':auth.login'), c.data)
aye('not in', 'user', app.session)
aye(False, app.user)
@nose.with_setup(teardown=_clear_custom_headers)
def test_object_create_bad_ua_empty():
key = _setup_bad_object({'User-Agent': ''})
key.set_contents_from_string('bar')
browser.find_by_css('.btn.login-button').click()
do_sleep()
assert not browser.is_text_present("Username or password was incorrect.")
assert_that(browser.url, ends_with("#/setup"))
def clear_dashboards(user="e2e_user", password="e2e_password",
fqdn="e2e_fqdn"):
delete_all_dashboards(user, password, fqdn)
log_back_in_before = with_setup(re_login)
log_in_nodevices_before = with_setup(re_login_no_devices)
clear_dashboards_before = with_setup(lambda: clear_dashboards)
clear_dashboards_nodevices_before = with_setup(
lambda: clear_dashboards("e2e_user_nodevices", fqdn="login.etherios.com"))
clear_dashboards_test_before = with_setup(
lambda: clear_dashboards("test_user", fqdn="login.etherios.com"))
#clear_dashboards = with_setup(clear_dashboards)
def get_user_device_option_labels(username='e2e_user'):
user = get_e2e_user(username)
if not user:
raise ValueError("Failed to find user")
options = []
for device in user.devices['items']:
template = "{id}"
@with_setup(usual_setup_func, usual_teardown_func)
def test_keep_hardlinks():
create_file('xxx', 'file_a')
create_link('file_a', 'file_b')
create_file('xxx', 'file_z')
head, *data, footer = run_rmlint('--no-hardlinked -S a')
assert data[0]["path"].endswith("file_a")
assert data[0]["is_original"] is True
assert data[1]["path"].endswith("file_z")
assert data[1]["is_original"] is False
head, *data, footer = run_rmlint('--hardlinked -S a')
assert data[0]["path"].endswith("file_a")
assert data[0]["is_original"] is True
assert data[1]["path"].endswith("file_b")
assert data[1]["is_original"] is False