Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fd66181
python-tests.yml
Danie1 Jun 3, 2022
07f1c6a
Update python-app.yml
Danie1 Jun 3, 2022
6e5f58b
Update python-app.xml
Danie1 Jun 3, 2022
bc36bf6
Update python-app.yml
Danie1 Jun 3, 2022
49e8da3
Support nurse pytest on Python2
Danie1 Jun 5, 2022
fb06623
Merge pull request #2 from Danie1/fix/python2-pytest
Danie1 Jun 5, 2022
3a094e7
Added matrix support to action
Danie1 Jun 5, 2022
a69f43e
Updated action
Danie1 Jun 5, 2022
820715c
Updated action
Danie1 Jun 5, 2022
9511881
Updated action
Danie1 Jun 5, 2022
42e87a7
Updated action
Danie1 Jun 5, 2022
230304a
Updated action
Danie1 Jun 5, 2022
3634c66
Updated action
Danie1 Jun 5, 2022
2d4f34c
Updated action
Danie1 Jun 5, 2022
9732652
Updated action
Danie1 Jun 5, 2022
a2c8fb7
Updated action
Danie1 Jun 5, 2022
85309d0
Updated action
Danie1 Jun 5, 2022
9a4afc7
Updated action
Danie1 Jun 5, 2022
2c9c4b5
Updated action
Danie1 Jun 5, 2022
8756b0f
Updated action
Danie1 Jun 5, 2022
8dce3df
Updated action
Danie1 Jun 5, 2022
51d3442
Updated action
Danie1 Jun 5, 2022
5276020
Updated action
Danie1 Jun 5, 2022
60cf281
Merge branch 'main' of github.com:Danie1/atyourservice into github-ac…
Danie1 Jun 5, 2022
8d7ba66
Updated action
Danie1 Jun 5, 2022
909c349
Updated action
Danie1 Jun 5, 2022
ebae205
Updated action
Danie1 Jun 5, 2022
2311910
Fix issue
Danie1 Jun 6, 2022
39dea7d
Fix issue
Danie1 Jun 6, 2022
cfd9c84
Fix issue
Danie1 Jun 6, 2022
1496134
Fix issue
Danie1 Jun 6, 2022
957de63
Fix issue
Danie1 Jun 6, 2022
795faa4
Fix issue
Danie1 Jun 6, 2022
fb29cdc
Fix issue
Danie1 Jun 7, 2022
083353a
Fix issue
Danie1 Jun 7, 2022
237a480
Fix issue
Danie1 Jun 7, 2022
e0c9669
Fix issue
Danie1 Jun 7, 2022
8df6c56
Fix issue
Danie1 Jun 7, 2022
9f52de9
Fix issue
Danie1 Jun 7, 2022
30039be
Fix issue
Danie1 Jun 8, 2022
8058876
Fix issue
Danie1 Jun 8, 2022
4bbdc18
Fix issue
Danie1 Jun 8, 2022
dea2881
Fix issue
Danie1 Jun 9, 2022
42bc10a
Fix issue
Danie1 Jun 9, 2022
6d44794
Fix
Danie1 Jun 29, 2022
36f698e
Fix
Danie1 Jun 29, 2022
1c4d358
Fix
Danie1 Jun 29, 2022
fc0dfba
Fix
Danie1 Jun 29, 2022
ac50f6f
Fix
Danie1 Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/python-tests-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read
issues: write
pull-requests: write

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.10']
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and run pytest
run: |
pip install pipenv
cd nurse
pipenv --python ${{ matrix.python-version }} install --dev
pipenv run pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=. tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: nurse/pytest-coverage.txt
title: Coverage Report
badge-title: Coverage Badge
hide-badge: false
hide-report: false
create-new-comment: false
hide-comment: false
report-only-changed-files: false
junitxml-path: nurse/pytest.xml
junitxml-title: JUnit Xml Summary
34 changes: 34 additions & 0 deletions .github/workflows/python-tests-platforms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10']
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and run pytest
run: |
pip install pipenv
cd nurse
pipenv --python ${{ matrix.python-version }} install --dev
pipenv run pytest --html=report.html
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ Pipfile.lock
**/__pycache__
**/assets
*.html
**/.unotes
**/.unotes
*.pyc
.coverage
pytest.xml
pytest-coverage.txt
2 changes: 2 additions & 0 deletions nurse/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = tests/*
3 changes: 2 additions & 1 deletion nurse/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ name = "pypi"
[dev-packages]
pytest = "*"
pytest-html = "*"
pytest-mock = "*"
pytest-mock = "*"
pytest-cov = "*"
1 change: 1 addition & 0 deletions nurse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═══╝ ╚═╝
```

[![Pytest](https://github.com/cyberark/atyourservice/actions/workflows/python-tests.yml/badge.svg)](https://github.com/cyberark/atyourservice/actions/workflows/python-tests.yml)
- - -

`nurse.py` is a command-line tool to retrieve diagnostic information from user's environments with their consent.
Expand Down
1 change: 0 additions & 1 deletion nurse/nurse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import datetime
import os
import sys, traceback
import pwd
from zipfile import ZipFile
import json
import copy
Expand Down
6 changes: 3 additions & 3 deletions nurse/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def _get_user_input_mock(self, prompt, prefill):
prompt = prompt.replace("-> ", "")

# assert priority
expected_question = list(self.value.keys())[0]
expected_question = self.value[0][0]
assert expected_question == prompt

user_answer = self.value[prompt]
user_answer = self.value[0][1]

# it will not be called again
del self.value[prompt]
del self.value[0]

return user_answer

Expand Down
151 changes: 75 additions & 76 deletions nurse/tests/test_all_questions_asked_in_priority.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import pytest
from .checklists import checklist_1
from .common import UserInputMocker, TestApp

def test_all_questions_asked_in_order_priority_100(mocker):
user_input_dict = {"Question 7" : "Y",
"Question 1" : "Y",
"Followup to Question 1" : "Y",
"Followup to Followup Question 1": "Y",
"Question 8" : "Y",
"Followup to Question 8" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 2" : "Y",
"Question 3" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 7" , "Y"),
("Question 1" , "Y"),
("Followup to Question 1" , "Y"),
("Followup to Followup Question 1", "Y"),
("Question 8" , "Y"),
("Followup to Question 8" , "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 2" , "Y"),
("Question 3" , "Y"),
("Question 6" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -26,19 +25,19 @@ def test_all_questions_asked_in_order_priority_100(mocker):
assert mock.isSuccess()

def test_all_questions_asked_in_order_priority_200(mocker):
user_input_dict = {"Question 7" : "Y",
"Question 1" : "Y",
"Followup to Question 1" : "Y",
"Followup to Followup Question 1": "Y",
"Question 2" : "Y",
"Question 8" : "Y",
"Followup to Question 8" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 3" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 7" , "Y"),
("Question 1" , "Y"),
("Followup to Question 1" , "Y"),
("Followup to Followup Question 1", "Y"),
("Question 2" , "Y"),
("Question 8" , "Y"),
("Followup to Question 8" , "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 3" , "Y"),
("Question 6" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -49,19 +48,19 @@ def test_all_questions_asked_in_order_priority_200(mocker):
assert mock.isSuccess()

def test_all_questions_asked_in_order_priority_50(mocker):
user_input_dict = {"Question 7" : "Y",
"Question 8" : "Y",
"Followup to Question 8" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 1" : "Y",
"Followup to Question 1" : "Y",
"Followup to Followup Question 1": "Y",
"Question 2" : "Y",
"Question 3" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 7" , "Y"),
("Question 8" , "Y"),
("Followup to Question 8" , "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 1" , "Y"),
("Followup to Question 1" , "Y"),
("Followup to Followup Question 1", "Y"),
("Question 2" , "Y"),
("Question 3" , "Y"),
("Question 6" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -72,19 +71,19 @@ def test_all_questions_asked_in_order_priority_50(mocker):
assert mock.isSuccess()

def test_all_questions_asked_in_order_priority_10(mocker):
user_input_dict = {"Question 8" : "Y",
"Followup to Question 8" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 7" : "Y",
"Question 1" : "Y",
"Followup to Question 1" : "Y",
"Followup to Followup Question 1": "Y",
"Question 2" : "Y",
"Question 3" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 8" , "Y"),
("Followup to Question 8" , "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 7" , "Y"),
("Question 1" , "Y"),
("Followup to Question 1" , "Y"),
("Followup to Followup Question 1", "Y"),
("Question 2" , "Y"),
("Question 3" , "Y"),
("Question 6" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -95,19 +94,19 @@ def test_all_questions_asked_in_order_priority_10(mocker):
assert mock.isSuccess()

def test_all_questions_asked_in_order_priority_300(mocker):
user_input_dict = {"Question 7" : "Y",
"Question 1" : "Y",
"Followup to Question 1" : "Y",
"Followup to Followup Question 1": "Y",
"Question 2" : "Y",
"Question 8" : "Y",
"Followup to Question 8" : "Y",
"Question 3" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 7" , "Y"),
("Question 1" , "Y"),
("Followup to Question 1" , "Y"),
("Followup to Followup Question 1", "Y"),
("Question 2" , "Y"),
("Question 8" , "Y"),
("Followup to Question 8" , "Y"),
("Question 3", "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 6" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -118,16 +117,16 @@ def test_all_questions_asked_in_order_priority_300(mocker):
assert mock.isSuccess()

def test_all_questions_asked_in_order_priority_300_no_followup(mocker):
user_input_dict = {"Question 7" : "Y",
"Question 1" : "N",
"Question 2" : "Y",
"Question 8" : "N",
"Question 3" : "Y",
"Question 9" : "Y",
"Question 10" : "Y",
"Question 4" : "Y",
"Question 5" : "Y",
"Question 6" : "Y",}
user_input_dict = [("Question 7" , "Y"),
("Question 1" , "N"),
("Question 2" , "Y"),
("Question 8" , "N"),
("Question 3" , "Y"),
("Question 9" , "Y"),
("Question 10" , "Y"),
("Question 4" , "Y"),
("Question 5" , "Y"),
("Question 6" , "Y"),]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand Down
4 changes: 2 additions & 2 deletions nurse/tests/test_commands_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_output_into_file(mocker):
expected_archived_paths = ["a/b/c/echo_command.txt",
"b/c/d/python_command.txt"]

user_input_dict = {"Question 1" : "Y"}
user_input_dict = [("Question 1" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand Down Expand Up @@ -44,7 +44,7 @@ def test_output_into_file(mocker):
def test_output_into_file_and_inline(mocker):
expected_archived_paths = ["b/c/d/python_command.txt"]

user_input_dict = {"Question 1" : "Y"}
user_input_dict = [("Question 1" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand Down
18 changes: 9 additions & 9 deletions nurse/tests/test_different_checklist_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def test_checklist_no_questions(mocker):
assert mock.isSuccess()

def test_checklist_numerous_followups(mocker):
user_input_dict = {"Question 1" : "Y",
"Followup 1" : "Y",
"Followup 2" : "Y",
"Followup 3" : "Y",
"Followup of Followup 3" : "Y"}
user_input_dict = [("Question 1" , "Y"),
("Followup 1" , "Y"),
("Followup 2" , "Y"),
("Followup 3" , "Y"),
("Followup of Followup 3" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand All @@ -27,10 +27,10 @@ def test_checklist_numerous_followups(mocker):
assert mock.isSuccess()

def test_checklist_nested_followups(mocker):
user_input_dict = {"Question 1" : "Y",
"Followup 1" : "Y",
"Followup 2" : "Y",
"Followup 3" : "Y"}
user_input_dict = [("Question 1" , "Y"),
("Followup 1" , "Y"),
("Followup 2" , "Y"),
("Followup 3" , "Y")]

mock = UserInputMocker(user_input_dict).patch(mocker)

Expand Down
Loading