copilot-swe-agent[bot] 7fd32f2da8 fix(provider.namecom): address PR review comments 5 gün önce
..
config e66dcf0240 feat(config): 支持远程配置文件 add remote HTTP(S) config loading support (#539) 5 ay önce
scripts 09af9a094d feat(install): 一键安装脚本 add POSIX-compatible one-click installation script with multilingual support and comprehensive testing (#546) 4 ay önce
README.md 485e6a3e26 Refact(config): 统一配置 (#506) 5 ay önce
__init__.py 6c24557505 feat(cli): add task subcommand for automated scheduled task management (#541) 4 ay önce
base_test.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_cache.py 96b4ca2e0c feat(config): 支持多配置文件和多服务商 优化http support multi config/providers (#531) 5 ay önce
test_config_cli.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_cli_extra.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_config_cli_task.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_config.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_env.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_env_extra.py 1600e57aff feat(config): add support for extra configuration fields (#562) 2 ay önce
test_config_extra.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_config_file.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_file_remote.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_init.py e66dcf0240 feat(config): 支持远程配置文件 add remote HTTP(S) config loading support (#539) 5 ay önce
test_config_init_multi.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_config_log_file_dir.py 21539a6cb4 fix(config): create parent directories for log file automatically (#600) 1 ay önce
test_config_schema_v4_1.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_ip.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_provider__signature.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_provider_alidns.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_aliesa.py d910a06fb7 fix(provider): ensure extra params take priority over old_record in _update_record (#566) 2 ay önce
test_provider_base.py e66dcf0240 feat(config): 支持远程配置文件 add remote HTTP(S) config loading support (#539) 5 ay önce
test_provider_base_simple.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_callback.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_cloudflare.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_debug.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_dnscom.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_dnspod.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_dnspod_com.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_edgeone.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_edgeone_dns.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_provider_he.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_huaweidns.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_namecom.py 7fd32f2da8 fix(provider.namecom): address PR review comments 5 gün önce
test_provider_namesilo.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_noip.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_proxy_list.py f175521870 refactor(tests): replace authid with id in all tests for consistency (#584) 1 ay önce
test_provider_tencentcloud.py f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588) 1 ay önce
test_scheduler_base.py 1463020411 fix(scheduler): 优化 Windows 打包和定时任务 and command executio… (#547) 4 ay önce
test_scheduler_cron.py 6f5984c588 fix(scheduler ): scheduler path and check (#550) 4 ay önce
test_scheduler_init.py 1463020411 fix(scheduler): 优化 Windows 打包和定时任务 and command executio… (#547) 4 ay önce
test_scheduler_launchd.py 6f5984c588 fix(scheduler ): scheduler path and check (#550) 4 ay önce
test_scheduler_schtasks.py 6f5984c588 fix(scheduler ): scheduler path and check (#550) 4 ay önce
test_scheduler_systemd.py 6f5984c588 fix(scheduler ): scheduler path and check (#550) 4 ay önce
test_util_comment.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_util_fileio.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_util_http.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce
test_util_http_proxy_list.py 6c24557505 feat(cli): add task subcommand for automated scheduled task management (#541) 4 ay önce
test_util_http_retry.py f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544) 4 ay önce

README.md

DDNS 测试指南 / DDNS Testing Guide

本文档说明如何运行DDNS项目的测试。unittest 是默认的测试框架,因为它是Python内置的,无需额外依赖。

This document explains how to run tests for the DDNS project. unittest is the default testing framework as it's built into Python and requires no additional dependencies.

快速开始 / Quick Start

默认方法 unittest / Default Method (unittest)

# 运行所有测试(推荐)/ Run all tests (recommended)
python -m unittest discover tests -v

# 运行基础测试文件 / Run base test file
python tests/base_test.py -v  

# 运行特定测试文件 / Run specific test file
python -m unittest tests.test_provider_he -v
python -m unittest tests.test_provider_dnspod -v

# 运行特定测试类 / Run specific test class
python -m unittest tests.test_provider_he.TestHeProvider -v

# 运行特定测试方法 / Run specific test method
python -m unittest tests.test_provider_he.TestHeProvider.test_init_with_basic_config -v

可选:使用 pytest / Optional: Using pytest (Advanced Users)

如果你偏好pytest的特性,需要先安装:

If you prefer pytest features, install it first:

# 或者直接安装 / or directly: 
pip install pytest

# 运行所有测试 / Run all tests
pytest tests/ -v

# 运行特定测试文件 / Run specific test file
pytest tests/test_provider_he.py -v

测试结构 / Test Structure

tests/
├── __init__.py         # 测试包初始化 / Makes tests a package
├── base_test.py        # 共享测试工具和基类 / Shared test utilities and base classes
├── test_provider_*.py  # 各个提供商的测试文件 / Tests for each provider  
└── README.md           # 本测试指南 / This testing guide

测试配置 / Test Configuration

项目同时支持unittest(默认)和pytest测试框架:

The project supports both unittest (default) and pytest testing frameworks:

编写测试 / Writing Tests

使用基础测试类 / Using the Base Test Class

所有提供商测试都应该继承BaseProviderTestCase

All provider tests should inherit from BaseProviderTestCase:

from base_test import BaseProviderTestCase, unittest, patch, MagicMock
from ddns.provider.your_provider import YourProvider

class TestYourProvider(BaseProviderTestCase):
    def setUp(self):
        super(TestYourProvider, self).setUp()
        # 提供商特定的设置 / Provider-specific setup
        
    def test_your_feature(self):
        provider = YourProvider(self.id, self.token)
        # 测试实现 / Test implementation

测试命名约定 / Test Naming Convention

  • 测试文件 / Test files: test_provider_*.py
  • 测试类 / Test classes: Test*Provider
  • 测试方法 / Test methods: test_*

Python版本兼容性 / Python Version Compatibility

测试设计为同时兼容Python 2.7和Python 3.x:

Tests are designed to work with both Python 2.7 and Python 3.x:

  • mock vs unittest.mock的导入处理 / Import handling for mock vs unittest.mock
  • 字符串类型兼容性 / String type compatibility
  • 异常处理兼容性 / Exception handling compatibility
  • print语句/函数兼容性 / Print statement/function compatibility

常见问题 / Common Issues

  1. 导入错误 / Import errors: 确保从项目根目录运行测试 / Ensure you're running tests from the project root directory
  2. 找不到Mock / Mock not found: 为Python 2.7安装mock包:pip install mock / Install mock package for Python 2.7: pip install mock==3.0.5
  3. 找不到pytest / pytest not found: 安装pytest:pip install pytest / Install pytest: pip install pytest

注意: 项目已通过修改 tests/__init__.py 解决了模块导入路径问题,现在所有运行方式都能正常工作。

Note: The project has resolved module import path issues by modifying tests/__init__.py, and now all running methods work correctly.