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

Refactor unit tests #36

Merged
merged 40 commits into from
Sep 25, 2023
Merged

Refactor unit tests #36

merged 40 commits into from
Sep 25, 2023

Conversation

Thanhphan1147
Copy link
Collaborator

Overview

Relates to #19, rewrite unit tests to :

  • Directly set up the test charm in the test function
  • Write files to the charm's containers directly instead of using push/pull mocks

Rationale

This makes the test functions easier to understand, avoid complicated fixture dependencies

Juju Events Changes

N/A

Module Changes

N/A

Library Changes

N/A

Checklist

@Thanhphan1147 Thanhphan1147 requested a review from a team as a code owner September 13, 2023 08:26
@Thanhphan1147 Thanhphan1147 marked this pull request as draft September 13, 2023 08:27
.gitignore Outdated Show resolved Hide resolved
@Thanhphan1147 Thanhphan1147 changed the title refactor unit test : update test_enable_metrics_success refactor unit tests Sep 14, 2023
@Thanhphan1147 Thanhphan1147 changed the title refactor unit tests Refactor unit tests Sep 14, 2023
@canonical canonical deleted a comment from github-actions bot Sep 15, 2023
@Thanhphan1147 Thanhphan1147 marked this pull request as ready for review September 15, 2023 13:50
@Thanhphan1147 Thanhphan1147 requested review from jdkandersson and a team September 15, 2023 14:25
src/constants.py Outdated Show resolved Hide resolved
src/constants.py Outdated Show resolved Hide resolved
src/synapse/api.py Outdated Show resolved Hide resolved
src/synapse/api.py Outdated Show resolved Hide resolved
arturo-seijas
arturo-seijas previously approved these changes Sep 25, 2023
Copy link
Collaborator

@arturo-seijas arturo-seijas left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@amandahla amandahla left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions
Copy link
Contributor

Test coverage for 5b47b6d

Name                            Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------------------------------
src/actions/__init__.py             3      0      0      0   100%
src/actions/register_user.py       21      0      2      0   100%
src/actions/reset_instance.py      21      3      2      1    83%   54-58
src/charm.py                      107      4     14      1    96%   108-109, 161-162
src/charm_state.py                 57      2     10      2    94%   22, 85
src/charm_types.py                 11      0      0      0   100%
src/database_client.py             53      1     10      3    94%   35, 47->exit, 69->exit
src/database_observer.py           54      4      6      0    93%   70-72, 88
src/exceptions.py                   4      0      0      0   100%
src/mjolnir.py                     94      2     22      4    95%   68, 80->exit, 116, 164->169
src/observability.py                9      0      0      0   100%
src/pebble.py                      73      4      2      1    93%   90-91, 109-110
src/saml_observer.py               45      1      8      0    98%   64
src/synapse/__init__.py             3      0      0      0   100%
src/synapse/api.py                161      5     20      2    96%   144, 315, 399-401
src/synapse/workload.py           171      8     20      4    94%   208-209, 245-246, 262, 292->295, 311->314, 350, 481-486
src/user.py                        24      0      4      0   100%
---------------------------------------------------------------------------
TOTAL                             911     34    120     18    95%

Static code analysis report

Run started:2023-09-25 14:10:58.721948

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 4261
  Total lines skipped (#nosec): 7
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@Thanhphan1147 Thanhphan1147 merged commit 30ab190 into main Sep 25, 2023
@Thanhphan1147 Thanhphan1147 deleted the tphan025/ISD-997 branch September 25, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants