migrate to gitea
This commit is contained in:
56
tests/test_models.py
Normal file
56
tests/test_models.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
Tests for data models
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from models import TranslationItem, TranslationBatch
|
||||
|
||||
|
||||
class TestTranslationItem(unittest.TestCase):
|
||||
"""Test cases for TranslationItem model"""
|
||||
|
||||
def test_translation_item_creation(self):
|
||||
"""Test creating a TranslationItem"""
|
||||
item = TranslationItem(name="test_key", value="Test value")
|
||||
self.assertEqual(item.name, "test_key")
|
||||
self.assertEqual(item.value, "Test value")
|
||||
self.assertIsNone(item.comment)
|
||||
|
||||
def test_translation_item_with_comment(self):
|
||||
"""Test creating a TranslationItem with comment"""
|
||||
item = TranslationItem(
|
||||
name="test_key",
|
||||
value="Test value",
|
||||
comment="Test comment"
|
||||
)
|
||||
self.assertEqual(item.name, "test_key")
|
||||
self.assertEqual(item.value, "Test value")
|
||||
self.assertEqual(item.comment, "Test comment")
|
||||
|
||||
|
||||
class TestTranslationBatch(unittest.TestCase):
|
||||
"""Test cases for TranslationBatch model"""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up test fixtures"""
|
||||
self.items = [
|
||||
TranslationItem(name="key1", value="Value 1"),
|
||||
TranslationItem(name="key2", value="Value 2")
|
||||
]
|
||||
|
||||
def test_translation_batch_creation(self):
|
||||
"""Test creating a TranslationBatch"""
|
||||
batch = TranslationBatch(
|
||||
items=self.items,
|
||||
target_language="values-de-rDE",
|
||||
target_file="strings.xml"
|
||||
)
|
||||
self.assertEqual(len(batch.items), 2)
|
||||
self.assertEqual(batch.target_language, "values-de-rDE")
|
||||
self.assertEqual(batch.target_file, "strings.xml")
|
||||
self.assertEqual(batch.items[0].name, "key1")
|
||||
self.assertEqual(batch.items[1].value, "Value 2")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user