first commi
This commit is contained in:
27
checker/tests/conftest.py
Normal file
27
checker/tests/conftest.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""测试配置文件"""
|
||||
import pytest
|
||||
import requests
|
||||
from checker import Card, StripeChecker
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_card():
|
||||
"""示例卡片fixture"""
|
||||
return Card(
|
||||
number="4111111111111111",
|
||||
month="12",
|
||||
year="2025",
|
||||
cvv="123"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def session():
|
||||
"""HTTP会话fixture"""
|
||||
return requests.Session()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def checker():
|
||||
"""检测器fixture"""
|
||||
return StripeChecker(timeout=15, max_retries=3)
|
||||
39
checker/tests/test_cards_parser.py
Normal file
39
checker/tests/test_cards_parser.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""测试卡片解析器"""
|
||||
from checker.cards import parse_card_file, deduplicate_cards
|
||||
from checker import Card
|
||||
|
||||
|
||||
def test_card_parse():
|
||||
"""测试卡片解析"""
|
||||
card_string = "4111111111111111|12|2025|123"
|
||||
card = Card.parse(card_string)
|
||||
|
||||
assert card is not None
|
||||
assert card.number == "4111111111111111"
|
||||
assert card.month == "12"
|
||||
assert card.year == "2025"
|
||||
assert card.cvv == "123"
|
||||
|
||||
|
||||
def test_card_bin():
|
||||
"""测试BIN提取"""
|
||||
card = Card(number="4111111111111111", month="12", year="2025", cvv="123")
|
||||
assert card.bin == "411111"
|
||||
|
||||
|
||||
def test_card_formatted():
|
||||
"""测试格式化输出"""
|
||||
card = Card(number="4111111111111111", month="12", year="2025", cvv="123")
|
||||
assert card.formatted == "4111111111111111|12|25|123"
|
||||
|
||||
|
||||
def test_deduplicate_cards():
|
||||
"""测试去重"""
|
||||
cards = [
|
||||
Card(number="4111111111111111", month="12", year="2025", cvv="123"),
|
||||
Card(number="4111111111111111", month="12", year="2025", cvv="123"),
|
||||
Card(number="5555555555554444", month="11", year="2024", cvv="456"),
|
||||
]
|
||||
|
||||
unique = deduplicate_cards(cards)
|
||||
assert len(unique) == 2
|
||||
Reference in New Issue
Block a user