Skip to content

Commit

Permalink
0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyProger1 committed Feb 12, 2024
1 parent fa735e3 commit 5147ca1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://github.com/CrazyProger1/Translatable-Enums/blob/master/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/CrazyProger1/Translatable-Enums"></a>
<a href="https://github.com/CrazyProger1/Translatable-Enums/releases/latest"><img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/CrazyProger1/Translatable-Enums"></a>
<a href="https://pypi.org/project/translatable-enums/"><img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/translatable-enums"></a>
<img src="https://img.shields.io/badge/coverage-98%25-brightgreen" alt="Coverage"/>
<img src="https://img.shields.io/badge/coverage-99%25-brightgreen" alt="Coverage"/>
</p>

Translatable-Enums is an i18n tool which uses built-in Enums as a convenient way to store translation keys.
Expand Down Expand Up @@ -89,7 +89,7 @@ msgstr ""

## Status

``0.0.2`` - RELEASED
``0.0.3`` - RELEASED

## Licence

Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@

- v0.0.2
- Added one-field translation (field.language)


- v0.0.3
- Expanded supported range of Python versions(3.10+)
- Added more tests. Improved coverage percentage (to 99%)
2 changes: 1 addition & 1 deletion i18n/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP = 'Translatable-Enums'
DESCRIPTION = ('Translatable-Enums is a i18n tool which uses built-in Enums '
'as an convenient way to store translation keys.')
VERSION = '0.0.2'
VERSION = '0.0.3'
AUTHOR = 'crazyproger1'
4 changes: 2 additions & 2 deletions i18n/utils/potfile/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from typing import Literal
from typing import Literal, NewType

type TextFileMode = Literal['r', 'w', 'a']
TextFileMode = NewType('TextFileMode', Literal['r', 'w', 'a'])
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "translatable-enums"
version = "0.0.2"
version = "0.0.3"
description = "Translatable-Enums is a i18n tool which uses built-in Enums as an convenient way to store translation keys."
authors = ["CrazyProger1 <crazyproger1@gmail.com>"]
license = "MIT"
Expand All @@ -13,7 +13,7 @@ repository = "https://github.com/CrazyProger1/Translatable-Enums"
documentation = "https://github.com/CrazyProger1/Translatable-Enums"

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.10"


[tool.poetry.group.dev.dependencies]
Expand Down
35 changes: 35 additions & 0 deletions tests/utils/test_potfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import re

from i18n.utils.potfile import POTFile

Expand All @@ -17,6 +18,11 @@ def keys():
}


@pytest.fixture
def template():
return 'Template'


@pytest.fixture
def create_potfile(file, keys):
with open(file=file, mode='w') as f:
Expand Down Expand Up @@ -44,3 +50,32 @@ def test_add_keys(file, keys):

assert len(keys) == 0


def test_template(file, template):
with POTFile(file, mode='w', template=template):
pass

with open(file, mode='r') as potfile:
assert potfile.read().strip() == template


def test_duplicate_keys(file, keys):
keys_with_duplicates = list(keys)
keys_with_duplicates.append(keys.pop())

with POTFile(file, 'w') as potfile:
with pytest.raises(KeyError):
for key in keys_with_duplicates:
potfile.write(key=key, check_key=True)


def test_comment_adding(file):
comment = 'test_comment'
with POTFile(file, 'w') as potfile:
potfile.write(
key='test',
comment=comment
)

with open(file, mode='r') as potfile:
assert len(re.findall(r'#\s+' + comment, potfile.read())) == 1

0 comments on commit 5147ca1

Please sign in to comment.