f
This commit is contained in:
@@ -3,19 +3,41 @@
|
||||
from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from src.tarot.attributes import (
|
||||
Month, Day, Weekday, Hour, ClockHour, Zodiac, Suit, Meaning, Letter, Sephera, Degree, Element,
|
||||
AstrologicalInfluence, TreeOfLife, Correspondences, CardImage,
|
||||
EnglishAlphabet, GreekAlphabet, HebrewAlphabet, Number, Color, Planet, God,
|
||||
Cipher, CipherResult,
|
||||
AstrologicalInfluence,
|
||||
CardImage,
|
||||
Cipher,
|
||||
CipherResult,
|
||||
ClockHour,
|
||||
Color,
|
||||
Correspondences,
|
||||
Day,
|
||||
Degree,
|
||||
Element,
|
||||
EnglishAlphabet,
|
||||
God,
|
||||
GreekAlphabet,
|
||||
HebrewAlphabet,
|
||||
Hour,
|
||||
Letter,
|
||||
Meaning,
|
||||
Month,
|
||||
Number,
|
||||
Planet,
|
||||
Sephera,
|
||||
Suit,
|
||||
TreeOfLife,
|
||||
Weekday,
|
||||
Zodiac,
|
||||
)
|
||||
from src.tarot.card.data import CardDataLoader, calculate_digital_root
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Basic Attribute Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestMonth:
|
||||
def test_month_creation(self):
|
||||
month = Month(1, "January", "Capricorn", "Aquarius")
|
||||
@@ -24,10 +46,7 @@ class TestMonth:
|
||||
assert month.zodiac_start == "Capricorn"
|
||||
|
||||
def test_month_all_months(self):
|
||||
months = [
|
||||
Month(i, f"Month_{i}", "Sign_1", "Sign_2")
|
||||
for i in range(1, 13)
|
||||
]
|
||||
months = [Month(i, f"Month_{i}", "Sign_1", "Sign_2") for i in range(1, 13)]
|
||||
assert len(months) == 12
|
||||
assert months[0].number == 1
|
||||
assert months[11].number == 12
|
||||
@@ -41,10 +60,7 @@ class TestDay:
|
||||
assert day.planetary_correspondence == "Sun"
|
||||
|
||||
def test_all_weekdays(self):
|
||||
days = [
|
||||
Day(i, f"Day_{i}", f"Planet_{i}")
|
||||
for i in range(1, 8)
|
||||
]
|
||||
days = [Day(i, f"Day_{i}", f"Planet_{i}") for i in range(1, 8)]
|
||||
assert len(days) == 7
|
||||
|
||||
|
||||
@@ -99,6 +115,7 @@ class TestMeaning:
|
||||
# Sepheric Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestSephera:
|
||||
def test_sephera_creation(self):
|
||||
sephera = Sephera(1, "Kether", "כתר", "Crown", "Metatron", "Chaioth", "Primum")
|
||||
@@ -118,6 +135,7 @@ class TestSephera:
|
||||
# Alphabet Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestEnglishAlphabet:
|
||||
def test_english_letter_creation(self):
|
||||
letter = EnglishAlphabet("A", 1, "ay")
|
||||
@@ -189,6 +207,7 @@ class TestHebrewAlphabet:
|
||||
# Number Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestNumber:
|
||||
def test_number_creation(self):
|
||||
num = Number(1, "Kether", "Spirit", 0) # compliment is auto-calculated
|
||||
@@ -220,6 +239,7 @@ class TestNumber:
|
||||
# Color Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestColor:
|
||||
def test_color_creation(self):
|
||||
color = Color("Red", "#FF0000", (255, 0, 0), "Gevurah", 5, "Fire", "Briah", "Power")
|
||||
@@ -248,7 +268,9 @@ class TestColor:
|
||||
for r in [0, 128, 255]:
|
||||
for g in [0, 128, 255]:
|
||||
for b in [0, 128, 255]:
|
||||
color = Color("Test", "#000000", (r, g, b), "Sephera", 1, "Element", "Scale", "Meaning")
|
||||
color = Color(
|
||||
"Test", "#000000", (r, g, b), "Sephera", 1, "Element", "Scale", "Meaning"
|
||||
)
|
||||
assert color.rgb == (r, g, b)
|
||||
|
||||
|
||||
@@ -260,7 +282,9 @@ class TestColor:
|
||||
class TestPlanet:
|
||||
def test_planet_creation(self):
|
||||
number = Number(6, "Tiphareth", "Fire", 0)
|
||||
color = Color("Gold", "#FFD700", (255, 215, 0), "Tiphareth", 6, "Fire", "Yetzirah", "Beauty")
|
||||
color = Color(
|
||||
"Gold", "#FFD700", (255, 215, 0), "Tiphareth", 6, "Fire", "Yetzirah", "Beauty"
|
||||
)
|
||||
planet = Planet(
|
||||
name="Sun",
|
||||
symbol="☉",
|
||||
@@ -342,6 +366,7 @@ class TestGod:
|
||||
# Cipher Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestCipher:
|
||||
def test_cipher_mapping_basic(self):
|
||||
cipher = Cipher("Test", "test", [1, 2, 3])
|
||||
@@ -374,6 +399,7 @@ class TestCipherResult:
|
||||
# Digital Root Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestDigitalRoot:
|
||||
def test_digital_root_single_digit(self):
|
||||
"""Single digits should return themselves."""
|
||||
@@ -389,7 +415,7 @@ class TestDigitalRoot:
|
||||
|
||||
def test_digital_root_large_numbers(self):
|
||||
"""Test large numbers."""
|
||||
assert calculate_digital_root(99) == 9 # 9+9 = 18, 1+8 = 9
|
||||
assert calculate_digital_root(99) == 9 # 9+9 = 18, 1+8 = 9
|
||||
assert calculate_digital_root(100) == 1 # 1+0+0 = 1
|
||||
assert calculate_digital_root(123) == 6 # 1+2+3 = 6
|
||||
|
||||
@@ -398,13 +424,13 @@ class TestDigitalRoot:
|
||||
# Major Arcana cards 0-21
|
||||
assert calculate_digital_root(14) == 5 # Card 14 (Temperance) -> 5
|
||||
assert calculate_digital_root(21) == 3 # Card 21 (The World) -> 3
|
||||
assert calculate_digital_root(1) == 1 # Card 1 (Magician) -> 1
|
||||
assert calculate_digital_root(1) == 1 # Card 1 (Magician) -> 1
|
||||
|
||||
def test_digital_root_invalid_input(self):
|
||||
"""Test that invalid inputs raise errors."""
|
||||
with pytest.raises(ValueError):
|
||||
calculate_digital_root(0)
|
||||
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
calculate_digital_root(-5)
|
||||
|
||||
@@ -413,6 +439,7 @@ class TestDigitalRoot:
|
||||
# CardDataLoader Tests
|
||||
# ============================================================================
|
||||
|
||||
|
||||
class TestCardDataLoader:
|
||||
@pytest.fixture
|
||||
def loader(self):
|
||||
@@ -443,33 +470,35 @@ class TestCardDataLoader:
|
||||
sephera = loader.sephera(i)
|
||||
assert sephera is not None
|
||||
assert sephera.number == i
|
||||
|
||||
|
||||
def test_load_ciphers(self, loader):
|
||||
"""Ensure cipher catalog is populated."""
|
||||
ciphers = loader.cipher()
|
||||
assert "english_simple" in ciphers
|
||||
assert ciphers["english_simple"].default_alphabet == "english"
|
||||
|
||||
|
||||
def test_word_cipher_request(self, loader):
|
||||
"""word().cipher() should return meaningful totals."""
|
||||
result = loader.word("tarot").cipher("english_simple")
|
||||
assert isinstance(result, CipherResult)
|
||||
assert result.total == 74
|
||||
assert result.alphabet_name == "english"
|
||||
|
||||
|
||||
def test_word_cipher_custom_alphabet(self, loader):
|
||||
result = loader.word("אמש").cipher("kabbalah_three_mother")
|
||||
assert result.values == (1, 40, 300)
|
||||
|
||||
def test_trigram_line_diagram(self, loader):
|
||||
from letter import trigram
|
||||
|
||||
tri = trigram.trigram.name("Zhen") # Thunder
|
||||
assert tri is not None
|
||||
assert tri.data.line_diagram == "|::"
|
||||
|
||||
def test_hexagram_line_diagram(self, loader):
|
||||
from letter import hexagram
|
||||
hex_result = hexagram.hexagram.filter('number:1').first()
|
||||
|
||||
hex_result = hexagram.hexagram.filter("number:1").first()
|
||||
assert hex_result is not None
|
||||
assert hex_result.data.line_diagram == "||||||"
|
||||
|
||||
@@ -575,7 +604,7 @@ class TestCardDataLoader:
|
||||
assert "english" in alphabets
|
||||
assert "greek" in alphabets
|
||||
assert "hebrew" in alphabets
|
||||
|
||||
|
||||
assert len(alphabets["english"]) == 26
|
||||
assert len(alphabets["greek"]) == 24
|
||||
assert len(alphabets["hebrew"]) == 22
|
||||
@@ -592,16 +621,16 @@ class TestCardDataLoader:
|
||||
|
||||
class TestDigitalRootIntegration:
|
||||
"""Integration tests for digital root with Tarot cards."""
|
||||
|
||||
|
||||
def test_all_major_arcana_digital_roots(self):
|
||||
"""Test digital root for all Major Arcana cards (0-21)."""
|
||||
loader = CardDataLoader()
|
||||
|
||||
|
||||
# All Major Arcana cards should map to colors 1-9
|
||||
for card_num in range(22):
|
||||
if card_num == 0:
|
||||
continue # Skip The Fool (0)
|
||||
|
||||
|
||||
color = loader.color_by_number(card_num)
|
||||
assert color is not None
|
||||
assert 1 <= color.number <= 9
|
||||
@@ -609,7 +638,7 @@ class TestDigitalRootIntegration:
|
||||
def test_color_consistency(self):
|
||||
"""Test that equivalent numbers map to same color."""
|
||||
loader = CardDataLoader()
|
||||
|
||||
|
||||
# 5 and 14 should map to same color (both have digital root 5)
|
||||
color_5 = loader.color_by_number(5)
|
||||
color_14 = loader.color_by_number(14)
|
||||
|
||||
Reference in New Issue
Block a user