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

Add option -m/--max #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Prev Previous commit
Added test for max
donaldtn committed Oct 20, 2019
commit fd7714564e82481bc9aedc08c3bf41f140b404ef
17 changes: 16 additions & 1 deletion tests/test_diceware.py
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ def test_handle_options_defaults(self):
assert options.randomsource == "system"
assert options.wordlist == "en_eff"
assert options.verbose == 0
assert options.max == 0

def test_handle_options_infile(self, tmpdir):
# we can give an infile
@@ -69,6 +70,14 @@ def test_handle_options_caps(self):
assert options.caps is True
options = handle_options(['--no-caps', ])
assert options.caps is False

def test_handle_options_max(self):
options = handle_options([])
assert options.max == 0
options = handle_options(['-m', '0'])
assert options.max == 0
options = handle_options(['--max', '0'])
assert options.max == 0
Comment on lines +77 to +80
Copy link
Owner

Choose a reason for hiding this comment

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

Values apart from 0 would be more interesting here.


def test_handle_options_caps_conflicting_raises_exc(self):
# conflicting caps-settings raise an exception
@@ -243,6 +252,12 @@ def test_get_passphrase_delimiters(self):
options.delimiter = " "
phrase = get_passphrase(options)
assert " " in phrase

def test_get_passphrase_max(self):
options = handle_options(args=[])
options.max = 15
phrase = get_passphrase(options)
assert len(phrase) == 15
Comment on lines +256 to +260
Copy link
Owner

Choose a reason for hiding this comment

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

This test would be more meaningful if it could ensure, that the original phrase was longer or shorter than 15 chars.


def test_print_version(self, capsys):
# we can print version infos
@@ -362,4 +377,4 @@ def test_main_wordlist(self, argv_handler, capsys, wordlists_dir):
sys.argv = ['diceware', '-w', 'foo']
main()
out, err = capsys.readouterr()
assert out == 'FooFooFooFooFooFoo\n'
assert out == 'FooFooFooFooFooFoo\n'
Copy link
Owner

Choose a reason for hiding this comment

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

The trailing newline is nitpicking, I know.