-
Notifications
You must be signed in to change notification settings - Fork 1
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
[PR] Unit Testing for Core Components #45
Conversation
tests/test_certificate_factory.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CertificateFactory and Certificate should have been deleted xd
tests/test_certificate_model.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certificate should have been deleted xd
mock_s3_client = MockS3Client() | ||
|
||
def mock_boto3_client(*args, **kwargs): | ||
return mock_s3_client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert args[0] == "s3"
s3_delivery.upload_file("path", "bucket", "") | ||
|
||
|
||
def test_s3_delivery_upload_file_no_credentials(monkeypatch, s3_delivery, tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary test. NoCredentialsError
is an exception from boto3
🥇
) | ||
|
||
|
||
def test_sftp_delivery_connect(monkeypatch, sftp_delivery): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should check that __establish_ssh_connection
and open_sftp
methods have been called.
assert sftp_delivery.sftp_client is not None | ||
|
||
|
||
def test_sftp_delivery_connect_invalid_credentials(monkeypatch, sftp_delivery): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary test. AuthenticationException
is an exception from paramiko
🥇
sftp_delivery.connect() | ||
|
||
|
||
def test_sftp_delivery_upload_file(monkeypatch, sftp_delivery, tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should check that put
has been called with local_file
and remote_file
args.
assert sftp_delivery.sftp_client.files[remote_file] == b"Test content." | ||
|
||
|
||
def test_sftp_delivery_download_file(monkeypatch, sftp_delivery, tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should check that get
has been called with remote_file
and local_file
args.
assert local_file.read_bytes() == b"Test content." | ||
|
||
|
||
def test_sftp_delivery_upload_with_verification(monkeypatch, sftp_delivery, tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should check that upload_file
and __verify_upload
methods has been called with local_file
, remote_file
and algorithm
args. It should mock __verify_upload
and check if upload
returns the same.
assert result is True | ||
|
||
|
||
def test_sftp_delivery_upload_with_verification_failure( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should check that upload_file
and __verify_upload
methods has been called with local_file
, remote_file
and algorithm
args. It should mock __verify_upload
and check if upload
returns the same.
sftp_delivery.upload_file(str(local_file), remote_file) | ||
|
||
|
||
def test_sftp_delivery_connect_invalid_private_key(monkeypatch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary test. SSHException
is an exception from paramiko
🥇
sftp_delivery.upload(str(local_file), remote_file, algorithm="invalid_algo") | ||
|
||
|
||
def test_sftp_delivery_calculate_checksum(sftp_delivery, tmp_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rework this test 👍
assert email_builder.custom_headers == {} | ||
|
||
|
||
def test_add_recipient(email_builder): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertions missing 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
[PR] Unit Testing for Core Components
Description
This PR adds unit tests for several components and models in the project. Each component has been tested to ensure that it meets functional requirements and properly handles potential errors. Tests include type validations, attribute initialization, and expected behavior of key methods.
Summary of Tested Components:
Test Objectives:
tmp_path
for temporary files and mocks for configurations and external dependencies.