[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F1YM724899JE61W26BNXDK":3,"skill-same:01M6F1YM724899JE61W26BNXDK":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":29,"linkOnly":30,"markdownContent":31,"markdownBody":32,"frontMatter":33,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":39,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M6F1YM724899JE61W26BNXDK","testing.fix_mock_tests",null,"Remove mocking approach from unit tests","causify-ai\u002Fhelpers","causify-ai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121828442?v=4","01M6BZFTHW2MQR7FWK8CDW0DRA","Causify.AI","01M6F1K6CCKKF8YKTBN4ZV509G",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftesting.fix_mock_tests\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28],"testing","testing fix mock tests","fix","tests","mock","unit tests","haiku","remove","unit","mocking","2026-11-10 10:12:30",false,"---\ndescription: Remove mocking approach from unit tests\nmodel: haiku\n---\n\n# Goal\n- When the user passes a test file, apply the following transformations to\n  remove mocking from unit testing code without changing behavior\n- Mocking often signals that your design could be more modular\n  - Avoiding mocking in Python unit tests means designing code so dependencies\n    are easy to control naturally, rather than being intercepted artificially\n\n# Workflow\n- Avoid mocking using the strategies below\n\n## Prefer Pure Functions\n- Functions that depend only on inputs and return outputs are trivial to test\n  - **Example:**\n    ```python\n    def add(a: int, b: int) -> int:\n        return a + b\n    ```\n- No mocking needed because there are no external dependencies\n\n## Design for Dependency Injection (DI)\n- Instead of hard coding dependencies inside functions or classes, pass them in\n- **Bad** (hardcodes the dependency, forcing a mock to test it)\n  ```python\n  from typing import Any\n  import requests\n\n  def get_user(user_id: int) -> Any:\n    return requests.get(f\"https:\u002F\u002Fapi.com\u002Fusers\u002F{user_id}\").json()\n  ```\n- **Good** (injects the dependency, so a fake can be substituted in tests)\n  ```python\n  from typing import Any, Protocol\n\n  class HttpClient(Protocol):\n      def get(self, url: str) -> Any: ...\n\n  def get_user(user_id: int, http_client: HttpClient) -> Any:\n    return http_client.get(f\"https:\u002F\u002Fapi.com\u002Fusers\u002F{user_id}\").json()\n  ```\n- **Bad** (creates its own dependency inside `__init__`)\n  ```python\n  class Database: pass\n\n  class UserService:\n    def __init__(self) -> None:\n      self.db: Database = Database()\n  ```\n- **Good** (accepts the dependency, so a fake can be passed in)\n  ```python\n  class Database: pass\n\n  class UserService:\n    def __init__(self, db: Database) -> None:\n      self.db: Database = db\n  ```\n\n## Create Lightweight Fakes Instead of Mocks\n- A fake is a real implementation with simplified behavior\n  - More maintainable and less brittle than mocks\n  - **Example:**\n    ```python\n    from typing import Any\n\n    class FakeDatabase:\n        def __init__(self) -> None:\n            self.data: dict[str, Any] = {}\n\n        def save(self, key: str, value: Any) -> None:\n            self.data[key] = value\n\n        def get(self, key: str) -> Any:\n            return self.data.get(key)\n    ```\n\n## Separate Side Effects From Logic\n- Keep core logic independent from I\u002FO\n- **Bad** (mixes I\u002FO and logic, forcing mocks for the database and email)\n  ```python\n  from typing import Any\n\n  def process_user(user_id: int) -> None:\n      user: Any = db.get(user_id)\n      send_email(user)\n  ```\n- **Good** (logic is separated from I\u002FO, so no mocking is needed)\n  ```python\n  from typing import Any, Callable\n\n  def process_user(user: Any, send_email_fn: Callable[[Any], None]) -> None:\n      send_email_fn(user)\n  ```\n- Now you can test logic without mocking the database or email system\n\n## Test Behavior Via Public Interfaces\n- Avoid testing internal calls (which often leads to mocking)\n- Focus on outputs and state changes\n  - Verify the final result or state instead of verifying a method was called\n\n## Use Real Collaborators When Cheap\n- If a dependency is fast and deterministic, just use it\n  - JSON parsing\n  - Simple utility classes\n  - Pure transformations\n- Mocking these adds unnecessary complexity\n\n## Use Integration Tests Strategically\n- Sometimes the best way to avoid mocking is not to unit test in isolation, but\n  to test a small system working together\n\n# Important\n- All invariants and conventions for unit tests are documented in\n  `.claude\u002Fskills\u002Ftesting.rules.md`\n- For all code you must follow the instructions in\n  `.claude\u002Fskills\u002Fcoding.rules.md`\n\n# Verification\n- [ ] Run the tests and confirm they still pass\n- [ ] Confirm no mocking constructs (`Mock`, `patch`, `MagicMock`) remain\n  unless truly unavoidable\n","# Goal\n- When the user passes a test file, apply the following transformations to\n  remove mocking from unit testing code without changing behavior\n- Mocking often signals that your design could be more modular\n  - Avoiding mocking in Python unit tests means designing code so dependencies\n    are easy to control naturally, rather than being intercepted artificially\n\n# Workflow\n- Avoid mocking using the strategies below\n\n## Prefer Pure Functions\n- Functions that depend only on inputs and return outputs are trivial to test\n  - **Example:**\n    ```python\n    def add(a: int, b: int) -> int:\n        return a + b\n    ```\n- No mocking needed because there are no external dependencies\n\n## Design for Dependency Injection (DI)\n- Instead of hard coding dependencies inside functions or classes, pass them in\n- **Bad** (hardcodes the dependency, forcing a mock to test it)\n  ```python\n  from typing import Any\n  import requests\n\n  def get_user(user_id: int) -> Any:\n    return requests.get(f\"https:\u002F\u002Fapi.com\u002Fusers\u002F{user_id}\").json()\n  ```\n- **Good** (injects the dependency, so a fake can be substituted in tests)\n  ```python\n  from typing import Any, Protocol\n\n  class HttpClient(Protocol):\n      def get(self, url: str) -> Any: ...\n\n  def get_user(user_id: int, http_client: HttpClient) -> Any:\n    return http_client.get(f\"https:\u002F\u002Fapi.com\u002Fusers\u002F{user_id}\").json()\n  ```\n- **Bad** (creates its own dependency inside `__init__`)\n  ```python\n  class Database: pass\n\n  class UserService:\n    def __init__(self) -> None:\n      self.db: Database = Database()\n  ```\n- **Good** (accepts the dependency, so a fake can be passed in)\n  ```python\n  class Database: pass\n\n  class UserService:\n    def __init__(self, db: Database) -> None:\n      self.db: Database = db\n  ```\n\n## Create Lightweight Fakes Instead of Mocks\n- A fake is a real implementation with simplified behavior\n  - More maintainable and less brittle than mocks\n  - **Example:**\n    ```python\n    from typing import Any\n\n    class FakeDatabase:\n        def __init__(self) -> None:\n            self.data: dict[str, Any] = {}\n\n        def save(self, key: str, value: Any) -> None:\n            self.data[key] = value\n\n        def get(self, key: str) -> Any:\n            return self.data.get(key)\n    ```\n\n## Separate Side Effects From Logic\n- Keep core logic independent from I\u002FO\n- **Bad** (mixes I\u002FO and logic, forcing mocks for the database and email)\n  ```python\n  from typing import Any\n\n  def process_user(user_id: int) -> None:\n      user: Any = db.get(user_id)\n      send_email(user)\n  ```\n- **Good** (logic is separated from I\u002FO, so no mocking is needed)\n  ```python\n  from typing import Any, Callable\n\n  def process_user(user: Any, send_email_fn: Callable[[Any], None]) -> None:\n      send_email_fn(user)\n  ```\n- Now you can test logic without mocking the database or email system\n\n## Test Behavior Via Public Interfaces\n- Avoid testing internal calls (which often leads to mocking)\n- Focus on outputs and state changes\n  - Verify the final result or state instead of verifying a method was called\n\n## Use Real Collaborators When Cheap\n- If a dependency is fast and deterministic, just use it\n  - JSON parsing\n  - Simple utility classes\n  - Pure transformations\n- Mocking these adds unnecessary complexity\n\n## Use Integration Tests Strategically\n- Sometimes the best way to avoid mocking is not to unit test in isolation, but\n  to test a small system working together\n\n# Important\n- All invariants and conventions for unit tests are documented in\n  `.claude\u002Fskills\u002Ftesting.rules.md`\n- For all code you must follow the instructions in\n  `.claude\u002Fskills\u002Fcoding.rules.md`\n\n# Verification\n- [ ] Run the tests and confirm they still pass\n- [ ] Confirm no mocking constructs (`Mock`, `patch`, `MagicMock`) remain\n  unless truly unavoidable\n",{"model":25,"description":7},"master","804ae3e928c04740cec553be0eb28c8d06ff420e",".claude\u002Fskills\u002Ftesting.fix_mock_tests",1,"https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers","https:\u002F\u002Fcausify-ai.github.io\u002Fhelpers\u002F","https:\u002F\u002Fgithub.com\u002Fcausify-ai","2026-11-02 21:54:29",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add causify-ai\u002Fhelpers --skill testing.fix_mock_tests",{"tool":48,"command":49},"bunx","bunx skills add causify-ai\u002Fhelpers --skill testing.fix_mock_tests",{"tool":51,"command":52},"pnpm","pnpm dlx skills add causify-ai\u002Fhelpers --skill testing.fix_mock_tests","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftesting.fix_mock_tests\u002FSKILL.md",true,[],[57,73,88,100,109,123],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":29},"01M6F209RASRBEK7GBNG5M00K0","tutorial_in_60_mins.propagate_docker_changes","Sync tutorial and class-project Docker files to match project_template","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftutorial_in_60_mins.propagate_docker_changes\u002FSKILL.md",[],[64,65,66,67,68,69,25,70,71,72],"docker","tutorial","tutorial in 60 mins propagate docker changes","propagate","template","sync","files","project","match",{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":29},"01M6F207XZ5YDAJ0KNDRE6EN0R","tutorial_in_60_mins.merge_markdown","Merge the content of a markdown file into a Jupyter notebook","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftutorial_in_60_mins.merge_markdown\u002FSKILL.md",[],[80,81,65,82,83,84,25,85,86,87],"markdown","merge","tutorial in 60 mins merge markdown","notebook","jupyter","file","jupyter notebook","content",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":29},"01M6F2059X95Q1A13HD67E9JRF","tutorial_in_60_mins.format","Format a directory to follow the \"Learn X in 60 Minutes\" tutorial conventions","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftutorial_in_60_mins.format\u002FSKILL.md",[],[95,65,96,97,98,25,99],"tutorial in 60 mins format","format","directory","learn","conventions",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":29},"01M6F202MDHMNYD5S1YHG2PKZD","tutorial_in_60_mins.create","Create a tutorial directory for the Learn X in 60 Minutes conventions","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftutorial_in_60_mins.create\u002FSKILL.md",[],[107,65,108,98,97,99],"tutorial in 60 mins create","create",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":29},"01M6F2004BW13GQ59N3RGSAYVN","todo.reorg_in_progress","Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftodo.reorg_in_progress\u002FSKILL.md",[],[116,117,118,119,120,121,122],"progress","todo","todo reorg in progress","tasks","queue","task","stage",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":29},"01M6F1ZXN0G6HBD08GT8HE5FYA","todo.reorg_headers","Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage","https:\u002F\u002Fgithub.com\u002Fcausify-ai\u002Fhelpers\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Ftodo.reorg_headers\u002FSKILL.md",[],[130,117,120,121,122],"todo reorg headers"]