-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_types.py
More file actions
64 lines (45 loc) · 1.75 KB
/
Copy pathtest_types.py
File metadata and controls
64 lines (45 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Unit tests for PostgreSQL type conversions."""
import pytest
def test_replication_message_type_exists():
"""Test that ReplicationMessage class exists in the module."""
try:
from pgoutput_decoder._pgoutput_decoder import ReplicationMessage
assert ReplicationMessage is not None
except ImportError:
# Module not built yet
pytest.skip("pgoutput_decoder module not built yet")
def test_message_type_values():
"""Test expected message type values."""
expected_types = ["INSERT", "UPDATE", "DELETE", "BEGIN", "COMMIT"]
# These will be created by the Rust code during actual replication
assert all(isinstance(t, str) for t in expected_types)
def test_decimal_type_handling():
"""Test that DECIMAL values are handled correctly."""
from decimal import Decimal
# Test decimal values that appear in e-commerce schema
price = Decimal("1299.99")
assert price == Decimal("1299.99")
quantity = 5
total = price * quantity
assert total == Decimal("6499.95")
def test_boolean_type_handling():
"""Test boolean type for _deleted flag."""
deleted_flag = False
assert isinstance(deleted_flag, bool)
assert deleted_flag is False
deleted_flag = True
assert deleted_flag is True
def test_varchar_type_handling():
"""Test VARCHAR type for IDs and names."""
customer_id = "CUST001"
assert isinstance(customer_id, str)
assert len(customer_id) > 0
customer_name = "Alice Johnson"
assert isinstance(customer_name, str)
def test_integer_type_handling():
"""Test INTEGER type for credit limits and quantities."""
credit_limit = 5000
assert isinstance(credit_limit, int)
assert credit_limit > 0
quantity = 3
assert isinstance(quantity, int)