Unit tests
Unit tests will be written using pytest for CollabyBot’s backend methods as well as its REST API.
GitHub Component
test_github_webhook_creation()
Test: Tests the creation of a webhook for a repository based on a set of events
Returns: True if the webhook matches the expected URL for the given scope, otherwise false
test_github_webhook_receive()
Test: Tests whether a JSON object can be received over the webhook
Returns: True if the JSON object is received, otherwise false
test_github_webhook_send()
Test: Tests whether a JSON object can be sent over the webhook
Return: True if the JSON object is successfully sent, otherwise false
test_github_object_string()
Test: Tests whether object_string() creates the correct notification string for a GitHub event
Returns: True if the notification string matches the expected output, otherwise false
test_pr_payload_handler()
Test: Tests whether the pull request payload handler is triggered when a PR event is received
Returns:
test_issue_payload_handler()
Test: Tests whether the issue payload handler is triggered when an issue event is received
Returns:
test_commit_payload_handler()
Test: Tests whether the commit payload handler is triggered when a commit event is received
Returns:
test_get_notifications_by_date()
Test: Tests whether find_notifications() fetches the correct notifications when a date filter is specified
Returns: True is the returned set of notifications contains all of the notifications within the specified date range, otherwise false
test_get_notifications_by_username()
Test: Tests whether find_notifications() fetches the correct notifications when a username filter is specified
Returns: True is the returned set of notifications contains all of the notifications triggered by the specified user, otherwise false
test_get_notifications_by_event()
Test: Tests whether find_notifications() fetches the correct notifications when an event type filter is specified
Returns: True is the returned set of notifications contains all of the notifications matching the specified event type, otherwise false
Database Component
test_database_connection()
Test: Tests whether the database can be successfully connected to
Returns: True if the database connection was successful, otherwise false
test_database_store_notification()
Test: Tests whether a notification can be entered into the database
Returns: True if the notification is successfully stored in the database, otherwise false
test_database_get_notification()
Test: Tests whether a notification can retrieved from the database
Returns: True if a query returns the expected notification, otherwise false
Jira Component
test_jira_webhook_creation()
Test: Tests the creation of a webhook for a Jira workspace according to a given scope
Returns: True if the webhook matches the expected URL for the given scope, otherwise false
test_jira_webhook_receive()
Test: Tests whether a JSON object can be received over the webhook
Returns: True if the JSON object is received, otherwise false
test_jira_webhook_send()
Test: Tests whether a JSON object can be sent over the webhook
Return: True if the JSON object is successfully sent, otherwise false
test_assign_ticket():
Test: Tests whether assign_ticket() successfully assigns the specified ticket to the specified user
Returns: True if the ticket has the specified user assigned to it after assign_ticket() is called, otherwise false
test_current_sprint():
Test: Tests whether current_sprint() successfully retrieves the current Jira sprint
Returns: True if the Sprint object returned by current_sprint() matches the expected object for the current sprint, otherwise false
Discord Bot component:
Discord Bot command logic is separated into a different file, as a service whose method can execute code or even return data back to Discord Bot Event Handler. This way we can run unit tests on the functionality.
Current methods to be tested are:
test_ping:
Test: Tests whether the bot successfully returns string “pong” in response to “ping command”
Returns: True if ping method in the service class returns string “pong”, otherwise returns false
test_get_commands:
Test: Tests whether the bot successfully returns the list of available commands as string
Returns: True if ping get_commands in the service class returns string containing the available discord bot commands, otherwise returns false