Skip to content

Commit

Permalink
Remove discrepancy in help message
Browse files Browse the repository at this point in the history
coala_quickstart/Strings.py: Updated GLOB_HELP message and added
PROJECT_DIR_HELP message.

coala_quickstart.py: Displayed help message for project directory
question. Added corresponding tests.

Closes #252
  • Loading branch information
djmgit authored and gitmate-bot committed Jun 28, 2018
1 parent ba4bcba commit 9a24071
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
12 changes: 8 additions & 4 deletions coala_quickstart/Strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"We can help you with that. Let's get started with "
'some basic questions.']

PROJECT_DIR_HELP = """
Enter the directory whose contents you want to analyse.
For example, you may want to include your src/ folder.
To do this, simply enter `src/`. To select the present
directory simply press enter and continue.
"""

GLOB_HELP_URL = 'http://coala.readthedocs.io/en/latest/Users/Glob_Patterns.html'
GLOB_HELP = """
Expand All @@ -34,10 +40,8 @@
separated by commas. To learn more about glob patterns
please visit: {}
For example, you may want to include your src/ folder and
all its contents but exclude your .git directory and all
.o files. To do this, simply give `src/` for the first
question and `.git/**,**/*.o` for the second question.
For example, you may want to exclude your .git directory and all
.o files. To do this, simply give `.git/**,**/*.o` for this question.
""".format(GLOB_HELP_URL)

BEAR_DOCS_URL = ('https://github.com/coala/bear-docs/blob/master/'
Expand Down
2 changes: 2 additions & 0 deletions coala_quickstart/coala_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from coala_quickstart.generation.Project import (
valid_path, get_used_languages, print_used_languages)
from coala_quickstart.generation.FileGlobs import get_project_files
from coala_quickstart.Strings import PROJECT_DIR_HELP
from coala_quickstart.generation.Bears import (
filter_relevant_bears,
print_relevant_bears,
Expand Down Expand Up @@ -85,6 +86,7 @@ def main():
fpc = FilePathCompleter()
fpc.activate()
print_welcome_message(printer)
printer.print(PROJECT_DIR_HELP)
project_dir = ask_question(
'What is your project directory?',
default=project_dir,
Expand Down
7 changes: 5 additions & 2 deletions tests/generation/FileGlobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

from pyprint.ConsolePrinter import ConsolePrinter
from coala_utils.ContextManagers import (
simulate_console_inputs, suppress_stdout)
simulate_console_inputs, suppress_stdout, retrieve_stdout)
from coala_utils.FilePathCompleter import FilePathCompleter
from coala_quickstart.generation.FileGlobs import get_project_files
from coala_quickstart.generation.Utilities import get_gitignore_glob
from coalib.collecting.Collectors import collect_files
from coala_quickstart.Strings import GLOB_HELP


class TestQuestion(unittest.TestCase):
Expand All @@ -30,11 +31,13 @@ def test_get_project_files(self):
open(os.path.join("ignore_dir", "src.c"), "w").close()
open(os.path.join("ignore_dir", "src.js"), "w").close()

with suppress_stdout(), simulate_console_inputs("ignore_dir/**"):
with retrieve_stdout() as custom_stdout, \
simulate_console_inputs("ignore_dir/**"):
res, _ = get_project_files(self.log_printer,
self.printer,
os.getcwd(),
self.file_path_completer)
self.assertIn(GLOB_HELP, custom_stdout.getvalue())
self.assertIn(os.path.normcase(
os.path.join(os.getcwd(), "src", "file.c")), res)
self.assertIn(os.path.normcase(
Expand Down
6 changes: 6 additions & 0 deletions tests/interaction/Logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from coala_utils.ContextManagers import retrieve_stdout
from coala_quickstart.interaction.Logo import (
print_welcome_message, print_side_by_side)
from coala_quickstart.Strings import PROJECT_DIR_HELP


class TestLogo(unittest.TestCase):
Expand All @@ -28,3 +29,8 @@ def test_print_welcome_message(self):
with retrieve_stdout() as custom_stdout:
print_welcome_message(self.printer)
self.assertIn("o88Oo", custom_stdout.getvalue())

def test_print_ask_dir_help_message(self):
with retrieve_stdout() as custom_stdout:
self.printer.print(PROJECT_DIR_HELP)
self.assertIn(PROJECT_DIR_HELP, custom_stdout.getvalue())

0 comments on commit 9a24071

Please sign in to comment.