Skip to content

Commit

Permalink
ISSUE pycontribs#1836: Added test assertions
Browse files Browse the repository at this point in the history
Included some `isinstance` assertions in the `Dashboard` tests per
@adehad's request.
  • Loading branch information
jpavlav committed Mar 20, 2024
1 parent 76a5d99 commit 9c6ec88
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/resources/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import pytest

from jira.exceptions import JIRAError
from jira.resources import (
Dashboard,
DashboardGadget,
DashboardItemProperty,
DashboardItemPropertyKey,
)
from tests.conftest import (
JiraTestCase,
allow_on_cloud,
Expand Down Expand Up @@ -68,6 +74,7 @@ def test_create_dashboard(self):
dashboard = self.jira.create_dashboard(
name=name, description=description, share_permissions=share_permissions
)
self.assertIsInstance(dashboard, Dashboard)
self.dashboards_to_delete.append(dashboard)

self.assertEqual(dashboard.name, name)
Expand All @@ -91,6 +98,7 @@ def test_update_dashboard(self):
dashboard = self.jira.create_dashboard(
name=name, description=description, share_permissions=share_permissions
)
self.assertIsInstance(dashboard, Dashboard)
self.dashboards_to_delete.append(dashboard)

dashboard.update(name=updated_name)
Expand Down Expand Up @@ -136,6 +144,7 @@ def test_copy_dashboard(self):
original_dashboard.id, name=rndstr()
)
copied_dashboard = self.jira.dashboard(copied_dashboard.id)
self.assertIsInstance(copied_dashboard, Dashboard)
self.dashboards_to_delete.append(copied_dashboard)

self.assertEqual(len(original_dashboard.gadgets), len(copied_dashboard.gadgets))
Expand All @@ -151,6 +160,7 @@ def test_all_dashboard_gadgets(self):
# the starting list ever changed.
gadgets = self.jira.all_dashboard_gadgets()
self.assertGreater(len(gadgets), 0)
self.assertIsInstance(gadgets[0], DashboardGadget)

@only_run_on_cloud
@allow_on_cloud
Expand All @@ -176,6 +186,9 @@ def test_dashboard_gadgets(self):
dashboard_gadgets = self.jira.dashboard_gadgets(dashboard.id)
self.assertEqual(len(dashboard_gadgets), gadget_count)

for dashboard_gadget in dashboard_gadgets:
self.assertIsInstance(dashboard_gadget, DashboardGadget)

@only_run_on_cloud
@allow_on_cloud
def test_update_dashboard_automatic_refresh_minutes(self):
Expand Down Expand Up @@ -211,6 +224,7 @@ def test_add_gadget_to_dashboard(self):

dashboard = self.jira.dashboard(dashboard.id)
self.assertEqual(dashboard.gadgets[0], gadget)
self.assertIsInstance(dashboard.gadgets[0], DashboardGadget)

@only_run_on_cloud
@allow_on_cloud
Expand Down Expand Up @@ -261,6 +275,7 @@ def test_update_gadget(self):
gadget = gadget.update(dashboard.id, color=new_color)
self.assertEqual(gadget.color, new_color)
self.assertEqual(gadget.raw["color"], new_color)
self.assertIsInstance(gadget, DashboardGadget)

@only_run_on_cloud
@allow_on_cloud
Expand Down Expand Up @@ -306,6 +321,7 @@ def test_dashboard_item_property_keys(self):
self.assertEqual(
dashboard_item_property_keys[0].key, self.dashboard_item_expected_key
)
self.assertIsInstance(dashboard_item_property_keys[0], DashboardItemPropertyKey)

delete_response = dashboard_item_property_keys[0].delete()
self.assertEqual(delete_response.status_code, 204)
Expand Down Expand Up @@ -351,6 +367,7 @@ def test_dashboard_item_properties(self):
self.assertEqual(
dashboard.gadgets[0].item_properties[0], dashboard_item_property
)
self.assertIsInstance(dashboard_item_property, DashboardItemProperty)

updated_item_property_payload = {"num": 10}
updated_dashboard_item_property = dashboard_item_property.update(
Expand Down

0 comments on commit 9c6ec88

Please sign in to comment.