Skip to content

Commit

Permalink
[TEST] Updating test for status module
Browse files Browse the repository at this point in the history
  • Loading branch information
bclenet committed Sep 25, 2023
1 parent 01845d9 commit 6a8472c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions narps_open/utils/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 12 additions & 2 deletions tests/utils/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 6a8472c

Please sign in to comment.