Skip to content

Commit 5292f3b

Browse files
committed
Add tests for OWASP awards sync command
1 parent 16ac8e3 commit 5292f3b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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"

0 commit comments

Comments
 (0)