Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket 8211 unit test #190

Merged
merged 9 commits into from
Mar 1, 2024
Merged

Ticket 8211 unit test #190

merged 9 commits into from
Mar 1, 2024

Conversation

danielmaclaren
Copy link
Contributor

@danielmaclaren danielmaclaren commented Feb 16, 2024

Created a framework for unit testing & unit tests for a few backup tasks

Daniel Maclaren and others added 6 commits February 12, 2024 11:20
Co-authored-by: esmith1729 <[email protected]>
Co-authored-by: Zsolt Kebel <[email protected]>
Co-authored-by: esmith1729 <[email protected]>
Co-authored-by: Zsolt Kebel <[email protected]>
Co-authored-by: Zsolt Kebel <[email protected]>
Co-authored-by: esmith1729 <[email protected]>
@danielmaclaren danielmaclaren linked an issue Feb 16, 2024 that may be closed by this pull request
1 task
@danielmaclaren
Copy link
Contributor Author

danielmaclaren commented Feb 16, 2024

To test:

Open a powershell window and use the following command:

cd .\Instrument\Dev\ibex_utils\installation_and_upgrade\

from this folder location, enter:

python -m pytest

to run the test files, which should result in the tests passing

image

pytest==8.0.0
pywin32==306
semantic_version==2.10.0
six==1.16.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since your adding specific requirements other than the default system ones this should probably use a venv.

Copy link
Contributor

@zsoltkebel zsoltkebel Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This txt contains the requirements of the ibex_utils repository (apart from pytest which is only for testing). We needed this file to set up the GitHub runner with the neccessary dependencies to be able to run ibex_util code

from ibex_install_utils.tasks import BaseTasks
from ibex_install_utils.user_prompt import UserPrompt

EPICS_PATH_BACKUP = os.path.join(BaseTasks._get_backup_dir(),'EPICS', 'VERSION.txt')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseTasks._get_backup_dir() raises an exception on machines without a C:\\Data directory, which is not guaranteed to be present on a developer machine. As this is done before running the tests, this prevents them from running instead of failing the test.

It might be worth running this with os.path.exists() mocked out so that whether this test runs is not coupled to whether the machine has a specific folder present.

@patch('sys.stdout', new_callable=io.StringIO)
def test_WHEN_updating_THEN_progress_bar_works(self, mockstdout):

BackupTasks('','','','','').update_progress_bar(10, 20)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth creating a variable empty_argument = '' or the like, just for clarity.

Daniel Maclaren and others added 3 commits February 29, 2024 14:25
Co-authored-by: esmith1729 <[email protected]>
Co-authored-by: Zsolt Kebel <[email protected]>
…h and explained the empty strings within the constructor

Co-authored-by: esmith1729 <[email protected]>
Co-authored-by: Zsolt Kebel <[email protected]>
@LowriJenkins LowriJenkins merged commit 24ae083 into master Mar 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deploy Script: Add Unit Tests
3 participants