def invalid_argument_error_message(context, argument):
    """Check the error message."""
    if "context" in argument or "project" in argument:
        message = f"argument <context|project>: {argument} name missing"
    else:
        message = "argument -d/--due: invalid date: "
    assert_in(f"next-action: error: {message}", context.next_action())
Beispiel #2
0
 def multipart_post_request_with_empty_file(self) -> None:
     self.env["REQUEST_METHOD"] = "POST"
     self.setup_multipart_request("my-file", "test")
     args = parse_args(self.env,
                       [("my-file", "file-or-str", Multiplicity.REQUIRED)])
     assert_in("my-file", args)
     assert_equal("test", args["my-file"])
Beispiel #3
0
 def wrong_method_escape_method(self) -> None:
     self.router.add_routes([("foo", "GET", fail_if_called)])
     response = self.handle_wsgi("G<T", "/foo")
     html = b"".join(response).decode("utf-8")
     assert_in(
         "<p>Method &#x27;G&lt;T&#x27; not allowed. Please try GET.</p>",
         html,
     )
Beispiel #4
0
 def read_value_as_file_with_umlauts(self) -> None:
     self.env["REQUEST_METHOD"] = "GET"
     self.add_path_argument("foo", "bär")
     args = parse_args(self.env, [("foo", "file", Multiplicity.REQUIRED)])
     assert_in("foo", args)
     f = args["foo"]
     assert_equal("", f.filename)
     assert_equal("application/octet-stream", f.content_type)
     assert_equal("bär".encode("utf-8"), f.read())
Beispiel #5
0
 def multipart_post_request_with_file_and_umlauts(self) -> None:
     self.env["REQUEST_METHOD"] = "POST"
     self.setup_multipart_file_request("föo", "my-filé.txt", "cöntent",
                                       "text/plain; charset=utf-8")
     args = parse_args(self.env, [("föo", "file", Multiplicity.REQUIRED)])
     assert_in("föo", args)
     f = args["föo"]
     assert_equal("my-filé.txt", f.filename)
     assert_equal("text/plain", f.content_type)
     assert_equal("cöntent".encode("utf-8"), f.read())
Beispiel #6
0
 def multipart_put_request_with_file(self) -> None:
     self.env["REQUEST_METHOD"] = "PUT"
     self.setup_multipart_file_request("my-file", "my-file.txt", "content",
                                       "text/plain")
     args = parse_args(self.env,
                       [("my-file", "file", Multiplicity.REQUIRED)])
     assert_in("my-file", args)
     f = args["my-file"]
     assert_equal("my-file.txt", f.filename)
     assert_equal("text/plain", f.content_type)
     assert_equal(b"content", f.read())
Beispiel #7
0
def assertIn(content, res):
    try:
        asserts.assert_in(content, res)
    except Exception as e:
        logger.error(e)
Beispiel #8
0
def invalid_config_file_error(context):
    """Check that Nect-action gives the correct error message."""
    assert_in(f"next-action: error: {context.config_file.name} is invalid:",
              context.next_action())
Beispiel #9
0
def parse_config_file_error(context):
    """Check that Nect-action gives the correct error message."""
    assert_in(f"next-action: error: can't parse {context.config_file.name}:",
              context.next_action())
def show_next_action_with_min_prio(context):
    """Check that the next actions have the minimum priority."""
    for line in context.next_action().strip().split("\n"):
        assert_in("(A)", line)
def show_named_next_action(context, action):
    """Check that the named next action is shown."""
    assert_in(action, context.next_action())
def show_blocked_task(context, task):
    """Check that the task is shown as blocked task."""
    assert_in(task, context.next_action())
Beispiel #13
0
 def encode_url(self) -> None:
     page = temporary_redirect_page('/foo/"bar"')
     assert_in('<a href="/foo/&quot;bar&quot;">/foo/&quot;bar&quot;</a>',
               page)
def unreadable_file_error_message(context):
    """Check the error message."""
    assert_in("next-action: error: can't open file: ", context.next_action())
def c_or_p_in_and_ex_error_message(context, context_or_project):
    """Check the error message."""
    argument_type = "@" if "context" in context_or_project else "+"
    assert_in(
        f"next-action: error: {argument_type}name is both included and excluded",
        context.next_action())
def show_next_action_due_tomorrow(context):
    """Check that the next action is due tomorrow."""
    assert_in(tomorrow(), context.next_action())
def show_next_actions_grouped_by(context, groupby):
    """Show all next actions grouped by context, project, ..."""
    expected_header = context.files[-1].name if groupby == "source" \
        else f"No {groupby.replace('due date', 'due date')}"
    assert_in(f"{expected_header}:\n- Task\n", context.next_action())
def invalid_priority_error_message(context):
    """Check the error message."""
    assert_in("next-action: error: argument -p/--priority: invalid choice:",
              context.next_action())
def invalid_number_error_message(context):
    """Check the error message."""
    assert_in("next-action: error: argument -n/--number: invalid number:",
              context.next_action())
Beispiel #20
0
 def html(self) -> None:
     request = Request(self.environment)
     response = see_other(request, self.start_response, "foo/bar")
     html = b"".join(response).decode("utf-8")
     assert html.startswith("<!DOCTYPE html>")
     assert_in("http://www.example.com/foo/bar", html)
Beispiel #21
0
 def encode_url(self) -> None:
     page = created_at_page('/foo/"bar"')
     assert_in('<a href="/foo/&quot;bar&quot;">/foo/&quot;bar&quot;</a>',
               page)
Beispiel #22
0
def check_config_argument(context, argument, value):
    """Check that Next-action includes the argument in the configuration file."""
    assert_in(argument + ": " + value, context.next_action())
Beispiel #23
0
 def encode_url(self) -> None:
     page = see_other_page('/foo/"bar"')
     assert_in('<a href="/foo/&quot;bar&quot;">/foo/&quot;bar&quot;</a>',
               page)
def check_reference(context):
    """Check the filename reference."""
    assert_in("/", context.next_action())
Beispiel #25
0
 def not_found_escape_path(self) -> None:
     response = self.handle_wsgi("GET", "/foo/<bar")
     html = b"".join(response).decode("utf-8")
     assert_in("<p>Path &#x27;/foo/&lt;bar&#x27; not found.</p>", html)
Beispiel #26
0
def non_existing_config_file_error(context):
    """Check that Nect-action gives the correct error message."""
    assert_in("next-action: error: can't open file:", context.next_action())
Beispiel #27
0
def check_config_option(context, option):
    """Check that Next-action includes the option in the configuration file."""
    assert_in(option.replace("-", "_") + ": true", context.next_action())
def show_next_action_over_due(context):
    """Check that the next action was due yesterday."""
    assert_in(yesterday(), context.next_action())
Beispiel #29
0
def check_config_filter(context, filter_type):
    """Check that Next-action includes the filter in the configuration file."""
    filter_option = "'@home'" if filter_type == "context" else "+Project"
    assert_in("filters:\n- " + filter_option, context.next_action())
def check_line_number(context):
    """Check the line number reference."""
    assert_in("1]", context.next_action())