Skip to content

improving unit test coverage (WIP)#3246

Open
uruwhy wants to merge 50 commits into
masterfrom
coverage-a
Open

improving unit test coverage (WIP)#3246
uruwhy wants to merge 50 commits into
masterfrom
coverage-a

Conversation

@uruwhy
Copy link
Copy Markdown
Contributor

@uruwhy uruwhy commented Jan 22, 2026

Description

  • address most unit test warnings
  • add additional unit tests to boost code coverage to
  • minor base code refactoring and adjustments to remove unused code or to allow unit testing on certain components

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Ran tests to confirm coverage

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@sonarqubecloud
Copy link
Copy Markdown

jlklos
jlklos previously approved these changes Feb 4, 2026
Copy link
Copy Markdown
Contributor

@jlklos jlklos left a comment

Choose a reason for hiding this comment

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

Tested the code locally and confirmed Caldera core runs well both with and without plugins enabled. Ran coverage tests locally and confirmed Sonarqube results. Local coverage test reports overall code coverage at 85%.

@uruwhy uruwhy marked this pull request as ready for review May 15, 2026 15:37
}
if url == 'https://api.github.com/gists':
mock_data = MOCK_GISTS
elif url.startswith('https://gist.githubusercontent.com'):
Comment thread app/api/rest_api.py
raise web.HTTPNotFound(text='File not found')
except Exception as e:
return web.HTTPNotFound(body=str(e))
raise web.HTTPNotFound(text=str(e))
Comment thread app/api/rest_api.py
def _request_errors(request):
errors = []
return errors
raise web.HTTPNotFound(text=str(e))
@sonarqubecloud
Copy link
Copy Markdown

async def delete_ability(self, request: web.Request):
await self.delete_on_disk_object(request)
return web.HTTPNoContent()
raise web.HTTPNoContent()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
raise web.HTTPNoContent()
return web.HTTPNoContent()

revert for now

except PermissionError:
response = web.HTTPForbidden(reason="Permission denied.")
return response
raise response
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
raise response
return response

revert for now

Comment thread app/api/rest_api.py
return web.Response(body=content, headers=headers)
except FileNotFoundError:
return web.HTTPNotFound(body='File not found')
raise web.HTTPNotFound(text='File not found')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
raise web.HTTPNotFound(text='File not found')
return web.HTTPNotFound(text='File not found')

revert for now

Comment thread app/api/rest_api.py
raise web.HTTPNotFound(text='File not found')
except Exception as e:
return web.HTTPNotFound(body=str(e))
raise web.HTTPNotFound(text=str(e))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
raise web.HTTPNotFound(text=str(e))
return web.HTTPNotFound(text=str(e))

revert for now

async def process(*args, **kwargs):
async with aiohttp.ClientSession(headers=dict(Authorization='token {}'.format(args[0].token)),
connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
connector=aiohttp.TCPConnector(ssl=False)) as session:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
connector=aiohttp.TCPConnector(ssl=False)) as session:
connector=aiohttp.TCPConnector(verify_ssl=False)) as session:

revert for now

async def process(*args, **kwargs):
async with aiohttp.ClientSession(headers=dict(Authorization='Bearer {}'.format(args[0].key)),
connector=aiohttp.TCPConnector(verify_ssl=False)) as session:
connector=aiohttp.TCPConnector(ssl=False)) as session:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
connector=aiohttp.TCPConnector(ssl=False)) as session:
connector=aiohttp.TCPConnector(verify_ssl=False)) as session:

revert for now

@deacon-mp
Copy link
Copy Markdown
Contributor

Replace the mocked path in tests/services/test_data_svc.py with a safe path under data/

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants