From 6a8472cfe20ddee796590daf3ad1b7ed8f3a5545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Cl=C3=A9net?= Date: Mon, 25 Sep 2023 14:34:31 +0200 Subject: [PATCH] [TEST] Updating test for status module --- docs/status.md | 2 +- narps_open/utils/status.py | 4 ++-- tests/utils/test_status.py | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/status.md b/docs/status.md index f323cc8f..7fde8239 100644 --- a/docs/status.md +++ b/docs/status.md @@ -36,7 +36,7 @@ print(pipeline_info['status']) report.markdown() # Returns a string containing the markdown ``` -You can also use the command-line tool as so. Option `-t` is for the team id, option `-d` allows to print only one of the sub parts of the description among : `general`, `exclusions`, `preprocessing`, `analysis`, and `categorized_for_analysis`. +You can also use the command-line tool as so. ```bash python narps_open/utils/status -h diff --git a/narps_open/utils/status.py b/narps_open/utils/status.py index e70e984d..e919b0fc 100644 --- a/narps_open/utils/status.py +++ b/narps_open/utils/status.py @@ -21,10 +21,10 @@ def get_opened_issues(): request_url += '?page={page_number}' issues = [] - page = True # Will later be replaced by a dict + page = True # Will later be replaced by a table page_number = 1 # According to the doc, first page is not page 0 # https://docs.github.com/en/rest/issues/issues#list-repository-issues - while page : # TODO check if page is empty + while bool(page) is True : # Test if the page is empty response = get(request_url.format(page_number = str(page_number)), timeout = 2) response.raise_for_status() page = response.json() diff --git a/tests/utils/test_status.py b/tests/utils/test_status.py index 0e98ef83..49c13a6f 100644 --- a/tests/utils/test_status.py +++ b/tests/utils/test_status.py @@ -36,7 +36,7 @@ def mock_api_issue(mocker): """ response = Response() response.status_code = 200 - def json_func(): + def json_func_page_0(): return [ { "html_url": "url_issue_2", @@ -50,7 +50,13 @@ def json_func(): "title" : "Pull request for pipeline 2T6S", "pull_request" : {}, "body" : "Work has been done." - }, + } + ] + + json_func_page_1 = json_func_page_0 + + def json_func_page_2(): + return [ { "html_url": "url_issue_4", "number": 4, @@ -64,6 +70,10 @@ def json_func(): "body" : "Something about 2T6S." } ] + + def json_func_page_3(): + return [] + response.json = json_func mocker.patch('narps_open.utils.status.get', return_value = response) mocker.patch(