File tree Expand file tree Collapse file tree
backend/tests/apps/owasp/management/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """Tests for owasp_sync_awards management command."""
2+
3+ from unittest .mock import patch
4+
5+ from django .test import TestCase
6+
7+ from apps .owasp .management .commands .owasp_sync_awards import Command
8+ from apps .owasp .models .award import Award
9+
10+
11+ class OwaspSyncAwardsTest (TestCase ):
12+ """Test owasp_sync_awards command."""
13+
14+ @patch ("apps.owasp.management.commands.owasp_sync_awards.get_repository_file_content" )
15+ def test_sync_awards (self , mock_get_content ):
16+ """Test syncing awards from YAML data."""
17+ mock_get_content .return_value = """
18+ - title: WASPY
19+ type: category
20+ description: Test category
21+ - title: Project Person of the Year
22+ type: award
23+ category: WASPY
24+ year: 2024
25+ winners:
26+ - name: Test Winner
27+ info: Test winner info
28+ """
29+
30+ command = Command ()
31+ command .handle ()
32+
33+ # Check that award was created
34+ award = Award .objects .get (name = "Project Person of the Year - Test Winner (2024)" )
35+ assert award .category == "WASPY"
36+ assert award .year == 2024
37+ assert award .description == "Test winner info"
You can’t perform that action at this time.
0 commit comments