Skip to content

Commit

Permalink
fix(test): make HookBackendTestCase abstract with test_git
Browse files Browse the repository at this point in the history
Converted `HookBackendTestCase` to an abstract class by adding the `ABC` base and `abstractmethod`. Standardized `test_git` method across test cases to enforce implementation in subclasses.
  • Loading branch information
Ron31 committed Jan 16, 2025
1 parent 2cd8473 commit 6c4db10
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions weblate/trans/tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""Test for notification hooks."""

import json
from abc import ABC, abstractmethod
from unittest.mock import patch

from django.test import SimpleTestCase
Expand Down Expand Up @@ -1582,7 +1583,7 @@ def test_hook_pagure(self) -> None:
self.assertContains(response, "Hook working", status_code=201)


class HookBackendTestCase(SimpleTestCase):
class HookBackendTestCase(SimpleTestCase, ABC):
hook: str = ""

def assert_hook(self, payload, expected) -> None:
Expand All @@ -1595,6 +1596,10 @@ def assert_hook(self, payload, expected) -> None:
self.maxDiff = None
self.assertEqual(expected, result)

@abstractmethod
def test_git(self):
raise NotImplementedError


class GitHubBackendTest(HookBackendTestCase):
hook = "github"
Expand Down Expand Up @@ -1867,7 +1872,7 @@ def test_git_old(self) -> None:
},
)

def test_git_new(self) -> None:
def test_git(self) -> None:
self.assert_hook(
AZURE_PAYLOAD_NEW,
{
Expand Down

0 comments on commit 6c4db10

Please sign in to comment.