-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from TicClick/default-language
- Loading branch information
Showing
6 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .base import LanguageMeta # noqa | ||
from . import ( | ||
ru, | ||
ru, special, | ||
) | ||
|
||
__all__ = ("ru",) | ||
__all__ = ("ru", "special",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from librarian.discord.languages import base | ||
|
||
|
||
class UnspecifiedLanguage(base.Language): | ||
""" | ||
Matches everything that don't match the "[LANGUAGE_CODE] PR title" format | ||
""" | ||
|
||
code = "none" | ||
highlights = [""] | ||
|
||
@classmethod | ||
def match(cls, line): | ||
return not line.strip().startswith("[") | ||
|
||
|
||
class EveryLanguage(base.Language): | ||
""" | ||
Matches everything | ||
""" | ||
|
||
code = "all" | ||
highlights = [""] | ||
|
||
@classmethod | ||
def match(cls, _): | ||
return True | ||
|
||
@property | ||
def random_highlight(self): | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import re | ||
|
||
import pytest | ||
|
||
from librarian.discord.languages import base, special | ||
|
||
|
||
class TestLanguages: | ||
def test__matching__unspecified_language(self): | ||
assert base.LanguageMeta.get("none") is special.UnspecifiedLanguage | ||
for good_title in ( | ||
"Update OWC2022", | ||
"Update dependencies", | ||
" Some spaces! Wow", | ||
"\"Special\" pull request", | ||
): | ||
assert special.UnspecifiedLanguage.match(good_title) | ||
|
||
for bad_title in ( | ||
"[EN] Update OWC2022", | ||
"[TEST] Update dependencies", | ||
"[EN/RU] Test", | ||
): | ||
assert not special.UnspecifiedLanguage.match(bad_title), bad_title | ||
|
||
def test__matching__every_language(self): | ||
assert base.LanguageMeta.get("all") is special.EveryLanguage | ||
for any_title in ( | ||
"Update OWC2022", | ||
"[RU] Update OWC2023", | ||
"[RU/EN] Update OWC2024", | ||
" Spa ces", | ||
"\"Rhythm Games from Outer Space\" (Short 1992)", | ||
): | ||
assert special.EveryLanguage.match(any_title) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters