Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Test cases for MilestoneNode."""

import math
from unittest.mock import Mock

import pytest

from apps.github.api.internal.nodes.milestone import MilestoneNode


Expand Down Expand Up @@ -77,7 +76,7 @@ def test_progress_with_issues(self):
mock_milestone.open_issues_count = 3

result = MilestoneNode.progress(mock_milestone)
assert result == pytest.approx(70.0)
assert math.isclose(result, 70.0)

def test_progress_without_issues(self):
"""Test progress calculation without issues."""
Expand All @@ -86,7 +85,7 @@ def test_progress_without_issues(self):
mock_milestone.open_issues_count = 0

result = MilestoneNode.progress(mock_milestone)
assert result == pytest.approx(0.0)
assert math.isclose(result, 0.0)

def test_repository_name_with_repository(self):
"""Test repository_name field when repository exists."""
Expand Down
7 changes: 3 additions & 4 deletions backend/tests/apps/github/api/internal/nodes/user_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Test cases for UserNode."""

import math
from unittest.mock import Mock

import pytest

from apps.github.api.internal.nodes.user import UserNode
from apps.nest.api.internal.nodes.badge import BadgeNode

Expand Down Expand Up @@ -54,7 +53,7 @@ def test_created_at_field(self):
mock_user.idx_created_at = 1234567890.0

result = UserNode.created_at(mock_user)
assert result == pytest.approx(1234567890.0)
assert math.isclose(result, 1234567890.0)

def test_issues_count_field(self):
"""Test issues_count field resolution."""
Expand All @@ -78,7 +77,7 @@ def test_updated_at_field(self):
mock_user.idx_updated_at = 1234567890.0

result = UserNode.updated_at(mock_user)
assert result == pytest.approx(1234567890.0)
assert math.isclose(result, 1234567890.0)

def test_url_field(self):
"""Test url field resolution."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for Committee GraphQL node."""

import math
from unittest.mock import Mock

from apps.owasp.api.internal.nodes.committee import CommitteeNode
Expand All @@ -25,7 +26,7 @@ def test_created_at_resolver(self):

result = CommitteeNode.created_at(mock_committee)

assert result == 1234567890.0
assert math.isclose(result, 1234567890.0)

def test_forks_count_resolver(self):
"""Test forks_count returns count from repository."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for common GraphQL nodes."""

import math
from unittest.mock import Mock

from apps.owasp.api.internal.nodes.common import GenericEntityNode
Expand Down Expand Up @@ -43,7 +44,7 @@ def test_updated_at_resolver(self):

result = GenericEntityNode.updated_at(mock_entity)

assert result == 1234567890.0
assert math.isclose(result, 1234567890.0)

def test_url_resolver(self):
"""Test url returns indexed URL."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_get_metadata_with_full_project_data(self, mock_project):
assert metadata["audience"] == ["builder", "defender"]
assert metadata["type"] == "tool"
assert math.isclose(metadata["level"], 3.5)

assert metadata["website"] == "https://owasp.org/www-project-awesome/"

assert len(metadata["leaders"]) == 1
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/apps/slack/admin/member_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_approve_suggested_users_success(self, admin_instance):
assert mock_member.user == mock_suggested_user
mock_member.save.assert_called_once()
admin_instance.message_user.assert_called_with(
request, pytest.approx(f" assigned user for {mock_member}."), messages.SUCCESS
request, f" assigned user for {mock_member}.", messages.SUCCESS
)

def test_approve_suggested_users_multiple_error(self, admin_instance):
Expand Down