-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: refactored tests to make them easier to maintain #215
Conversation
Reviewer's Guide by SourceryThe changes focus on refactoring and simplifying tests across multiple components. The main changes include removing redundant test assertions, simplifying test data fixtures, and standardizing error message handling. The implementation moves towards more focused testing by verifying core functionality rather than exact response matching. Class diagram for refactored test structureclassDiagram
class TestClient {
+get(url: str) TestResponse
}
class TestResponse {
+status_code: int
+json() dict
}
class Mock {
+status_code: int
+text: str
}
class PlayerGamemode {
<<enumeration>>
QUICKPLAY
}
class PlayerPlatform {
<<enumeration>>
PC
CONSOLE
}
class HeroKeyCareerFilter {
<<enumeration>>
ANA
}
class CacheManager {
+update_search_data_cache(data: dict)
}
class MapsParser {
+data: list
+parse() void
}
class OverfastError {
}
class Settings {
+internal_server_error_message: str
}
class RouteTag {
<<enumeration>>
HEROES
GAMEMODES
MAPS
PLAYERS
}
class FastAPI {
+title: str
+description: str
+version: str
+openapi_tags: list
+servers: list
+contact: dict
+license_info: dict
}
class StaticFiles {
+directory: str
}
class Logger {
+info(message: str)
}
class StarletteHTTPException {
}
class PydanticValidationError {
}
class Profiler {
<<enumeration>>
MEMRAY
PYINSTRUMENT
}
class MemrayInMemoryMiddleware {
}
class PyInstrumentMiddleware {
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Quality Gate passedIssues Measures |
🧙 Sourcery is reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1 similar comment
🧙 Sourcery is reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @TeKrop - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Found a potential Optimizely project ID hardcoded in the JavaScript code (link)
- Found a hardcoded Optimizely project ID that could potentially be used to access the account (link)
- Found a hardcoded Optimizely project ID that could potentially be used to access the project configuration (link)
- Found a hardcoded Optimizely project ID that could potentially be used to access the project configuration (link)
- Found a potential Optimizely API key/project ID in the JavaScript code (link)
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🔴 Security: 5 blocking issues
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
</script><script>var BlzCookieConsent = JSON.parse('{"host":".blizzard.com","cookieInfoUrlPattern":"/cookies/?$","onetrustScriptUrl":"https://cdn.cookielaw.org/scripttemplates/otSDKStub.js","onetrustDomainScript":"22011b0f-2c46-49a3-a7bf-5f98a4d4da65"}');</script><script src="https://static.playoverwatch.com/js/cookie-consent-filter-ed6098b4bf.js"></script><link rel="preload" as="script" crossorigin href="https://cdn.optimizely.com/js/8304241110.js"><link rel="preconnect" href="//logx.optimizely.com"><script>window.addEventListener('CookieConsentChange', (event) => { | ||
if (typeof BlzCookieConsent !== 'undefined' && BlzCookieConsent.initialized && BlzCookieConsent.isPerformanceStorageAllowed() && !window.document.querySelector('script[data-optimizely]')) { | ||
var script = document.createElement('script'); | ||
script.src = `https://cdn.optimizely.com/js/8304241110.js`; |
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.
🚨 issue (security): Found a potential Optimizely project ID hardcoded in the JavaScript code
The Optimizely project ID '8304241110' appears to be hardcoded in the source. While this may be a test fixture, it's worth verifying if this is a real production ID that should be moved to configuration.
</script><script>var BlzCookieConsent = JSON.parse('{"host":".blizzard.com","cookieInfoUrlPattern":"/cookies/?$","onetrustScriptUrl":"https://cdn.cookielaw.org/scripttemplates/otSDKStub.js","onetrustDomainScript":"22011b0f-2c46-49a3-a7bf-5f98a4d4da65"}');</script><script src="https://static.playoverwatch.com/js/cookie-consent-filter-ed6098b4bf.js"></script><link rel="preload" as="script" crossorigin href="https://cdn.optimizely.com/js/8304241110.js"><link rel="preconnect" href="//logx.optimizely.com"><script>window.addEventListener('CookieConsentChange', (event) => { | ||
if (typeof BlzCookieConsent !== 'undefined' && BlzCookieConsent.initialized && BlzCookieConsent.isPerformanceStorageAllowed() && !window.document.querySelector('script[data-optimizely]')) { | ||
var script = document.createElement('script'); | ||
script.src = `https://cdn.optimizely.com/js/8304241110.js`; |
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.
🚨 issue (security): Found a hardcoded Optimizely project ID that could potentially be used to access the account
The Optimizely project ID '8304241110' appears to be hardcoded in the JavaScript. While this ID is often public, it's better to store it in a configuration file or environment variable to make it easier to manage across environments.
</script><script>var BlzCookieConsent = JSON.parse('{"host":".blizzard.com","cookieInfoUrlPattern":"/cookies/?$","onetrustScriptUrl":"https://cdn.cookielaw.org/scripttemplates/otSDKStub.js","onetrustDomainScript":"22011b0f-2c46-49a3-a7bf-5f98a4d4da65"}');</script><script src="https://static.playoverwatch.com/js/cookie-consent-filter-ed6098b4bf.js"></script><link rel="preload" as="script" crossorigin href="https://cdn.optimizely.com/js/8304241110.js"><link rel="preconnect" href="//logx.optimizely.com"><script>window.addEventListener('CookieConsentChange', (event) => { | ||
if (typeof BlzCookieConsent !== 'undefined' && BlzCookieConsent.initialized && BlzCookieConsent.isPerformanceStorageAllowed() && !window.document.querySelector('script[data-optimizely]')) { | ||
var script = document.createElement('script'); | ||
script.src = `https://cdn.optimizely.com/js/8304241110.js`; |
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.
🚨 issue (security): Found a hardcoded Optimizely project ID that could potentially be used to access the project configuration
While this may be intended for client-side use, it's recommended to load Optimizely IDs from configuration rather than hardcoding them to make project ID rotation easier and prevent potential misuse.
</script><script>var BlzCookieConsent = JSON.parse('{"host":".blizzard.com","cookieInfoUrlPattern":"/cookies/?$","onetrustScriptUrl":"https://cdn.cookielaw.org/scripttemplates/otSDKStub.js","onetrustDomainScript":"22011b0f-2c46-49a3-a7bf-5f98a4d4da65"}');</script><script src="https://static.playoverwatch.com/js/cookie-consent-filter-ed6098b4bf.js"></script><link rel="preload" as="script" crossorigin href="https://cdn.optimizely.com/js/8304241110.js"><link rel="preconnect" href="//logx.optimizely.com"><script>window.addEventListener('CookieConsentChange', (event) => { | ||
if (typeof BlzCookieConsent !== 'undefined' && BlzCookieConsent.initialized && BlzCookieConsent.isPerformanceStorageAllowed() && !window.document.querySelector('script[data-optimizely]')) { | ||
var script = document.createElement('script'); | ||
script.src = `https://cdn.optimizely.com/js/8304241110.js`; |
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.
🚨 issue (security): Found a hardcoded Optimizely project ID that could potentially be used to access the project configuration
While this appears to be a client-side Optimizely project ID, it's recommended to store such configuration values in environment variables or configuration files rather than hardcoding them in source code.
</script><script>var BlzCookieConsent = JSON.parse('{"host":".blizzard.com","cookieInfoUrlPattern":"/cookies/?$","onetrustScriptUrl":"https://cdn.cookielaw.org/scripttemplates/otSDKStub.js","onetrustDomainScript":"22011b0f-2c46-49a3-a7bf-5f98a4d4da65"}');</script><script src="https://static.playoverwatch.com/js/cookie-consent-filter-ed6098b4bf.js"></script><link rel="preload" as="script" crossorigin href="https://cdn.optimizely.com/js/8304241110.js"><link rel="preconnect" href="//logx.optimizely.com"><script>window.addEventListener('CookieConsentChange', (event) => { | ||
if (typeof BlzCookieConsent !== 'undefined' && BlzCookieConsent.initialized && BlzCookieConsent.isPerformanceStorageAllowed() && !window.document.querySelector('script[data-optimizely]')) { | ||
var script = document.createElement('script'); | ||
script.src = `https://cdn.optimizely.com/js/8304241110.js`; |
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.
🚨 issue (security): Found a potential Optimizely API key/project ID in the JavaScript code
The number '8304241110' appears to be an Optimizely project identifier. While this may be intended for client-side use, it's recommended to review if this should be exposed or if it provides access to sensitive Optimizely features.
Summary by Sourcery
Refactor test cases to enhance maintainability by simplifying parameterization and removing redundant assertions, and streamline test setup and execution.
Enhancements:
Tests: