예제 #1
0
def test_get_solver(docopt,
                    _get_grid,
                    _get_words,
                    _get_word_lengths,
                    _check_word_lengths,
                    _print_solution,
                    Solver):
    """Ensure that `main` tries to get the all of the resources specified on
    the command-line.
    """
    args = mock.Mock()
    docopt.return_value = args

    solver = mock.Mock()
    Solver.return_value = solver

    grid = mock.Mock()
    _get_grid.return_value = grid

    words = mock.Mock()
    _get_words.return_value = words

    word_lengths = mock.Mock()
    _get_word_lengths.return_value = word_lengths

    main()

    _get_grid.assert_called_once_with(args)
    _get_words.assert_called_once_with(args)
    _get_word_lengths.assert_called_once_with(args)
    _check_word_lengths.assert_called_once_with(grid, word_lengths)
    Solver.assert_called_once_with(words, grid, word_lengths=word_lengths)
    _print_solution.assert_called_once_with(solver)
예제 #2
0
def test_main_return_value(docopt,
                           _get_solver,
                           _print_solution,
                           print_solution_return_value,
                           return_code):
    args = mock.Mock()
    docopt.return_value = args

    solver = mock.Mock()
    _get_solver.return_value = solver

    _print_solution.return_value = print_solution_return_value
    assert main() == return_code

    docopt.assert_called_once_with(__doc__)
    _get_solver.assert_called_once_with(args)
    _print_solution.assert_called_once_with(solver)