Code Duplication    Length = 24-24 lines in 2 locations

tests/test_rule_handling.py 2 locations

@@ 390-413 (lines=24) @@
387
        assert str(not_wanted) not in messages[0].text
388
389
390
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
391
def test_evaluation_passwd_minlen_short_passwd(
392
        proxy_getter, rule_data, ksdata_mock, storage_mock):
393
    password_proxy_mock = mock.MagicMock()
394
    proxy_getter.return_value = password_proxy_mock
395
    password_proxy_mock.IsRootPasswordCrypted = False
396
    password_proxy_mock.RootPassword = "aaaa"
397
398
    rule_data.new_rule("passwd --minlen=8")
399
400
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=False)
401
402
    # minimal password length greater than actual length --> one warning
403
    assert len(messages) == 1
404
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
405
406
    # warning has to mention the length
407
    assert "8" in messages[0].text
408
409
    # warning should mention that something is wrong with the old password
410
    assert "is" in messages[0].text
411
412
    # doing changes --> password should not be cleared
413
    assert password_proxy_mock.RootPassword == "aaaa"
414
415
416
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
@@ 416-439 (lines=24) @@
413
    assert password_proxy_mock.RootPassword == "aaaa"
414
415
416
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
417
def test_evaluation_passwd_minlen_short_passwd_report_only(
418
        proxy_getter, rule_data, ksdata_mock, storage_mock):
419
    password_proxy_mock = mock.MagicMock()
420
    proxy_getter.return_value = password_proxy_mock
421
    password_proxy_mock.IsRootPasswordCrypted = False
422
    password_proxy_mock.RootPassword = "aaaa"
423
424
    rule_data.new_rule("passwd --minlen=8")
425
426
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=True)
427
428
    # minimal password length greater than actual length --> one warning
429
    assert len(messages) == 1
430
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
431
432
    # warning has to mention the length
433
    assert "8" in messages[0].text
434
435
    # warning should mention that something is wrong with the old password
436
    assert "is" in messages[0].text
437
438
    # doing changes --> password should not be cleared
439
    assert password_proxy_mock.RootPassword == "aaaa"
440
441
442
@mock.patch("pyanaconda.dbus.DBus.get_proxy")