create-python-tests

Instructions for writing Python unit tests with pytest, a tool for checking small pieces of code automatically, for Cortex data products.

In plain words
What is it for?
Checking that compiled SQL applies the documented business rules and produces the expected fields from SAP and other source data.
Why use it?
The tests catch incorrect data transformations, filters, joins, and field mappings before they reach users.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/googlecloudplatform/cortex-framework/create_python_tests
Any agent
npx skills add GoogleCloudPlatform/cortex-framework --skill create_python_tests
Clone the repo
git clone --depth 1 https://github.com/GoogleCloudPlatform/cortex-framework

Made for: Claude Code, Codex.

Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 960 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00028 $0.00960
Opus 5 $0.00014 $0.00480
Sonnet 5 $0.00006 $0.00192
Haiku 4.5 $0.00003 $0.00096

Measured yesterday against content hash a34872088829, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

create-python-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/create_python_tests/SKILL.md · 51 lines

How it starts

The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Creating Python Unit Tests for a Data Product

When a new data product is created or updated, you MUST create a corresponding Python unit test using pytest. This test ensures that the compiled SQL query correctly implements the business logic, transformations, joins, and filtering criteria documented in the implementation plan.


Workflow

Step 1: Analyze the Implementation Plan and Code

  1. Retrieve Assumptions & Transformations: Read the implementation plan (from /create-data-product) to identify:
    • Which source tables are joined (e.g., KNA1 and ADRC).
    • What filtering rules are applied (e.g., mandt = '100', specific system versions).
    • What columns are expected and how they are transformed (e.g., coalesced fields, calculations).
  2. Locate Scaffolding Files: Locate the custom data product's definition file (src/data_modules/<namespace>/<source>/products/<type>/definitions/*.js).
  3. Leverage SAP & Domain Knowledge (CRITICAL): Apply your technical understanding of SAP DDIC structures (e.g., how client-specific data is separated, document lines vs headers, translation checks) and the business domain (e.g., Order-to-Cash, Procure-to-Pay, General Ledger) to design meaningful assertions. If any transformations or business rules are complex, custom, or ambiguous, you MUST ask the user for clarifying inputs on how those requirements should be verified in the unit tests before writing the test file.

Step 2: Scaffold the Test File

  1. Test Location: Create the test file under tests/unit/<namespace>/ named test_<type>.py.
  2. Template Reference: Use the base test template in test_template.py.md to structure the test file.

Step 3: Implement Test Assertions

Write assertions to verify the following from the compiled query:

  1. Join Logic Verification: Parse the query to assert that the correct source tables are joined on the appropriate keys.
    • Example: Verify that KNA1 is joined with ADRC on kunnr.
  2. Filter Logic Verification: Assert that filtering constraints from the user profile or assumptions are present in the SQL.
    • Example: Verify that mandt = '100' or mandt = "100" is enforced in the WHERE or ON clauses.
  3. Field Transformations Verification: Verify that specific aliased or transformed fields exist in the SELECT statement.
    • Example: Verify that COALESCE is used on postal code fields or region fields.
  4. Important Field Existence Verification: Verify that key or important fields (like primary keys, key foreign relations, and required business dimensions) are actively selected and projected in the final SQL statement.
    • Example: Verify that fields like customer_number_kunnr or valid_from_date are selected.
  5. Custom Z-Fields Assertions: If the data product maps custom SAP fields (Z-fields, ZZ-fields, or YY-fields), write explicit assertions to verify that these custom columns are correctly projected in the SELECT query and adhere to the snake_case description mapping convention (e.g., asserting that 'zz_' or 'yy_' matches are present).

Read the full file on GitHub · 51 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 51 lines · 28 tokens per session scan A a34872088829

Subscribe to this mod's changes

create-python-tests is a skill published in the GitHub repository GoogleCloudPlatform/cortex-framework (10 stars, last pushed 6d ago), licensed Apache-2.0. It adds 28 tokens to every session and 960 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

google-mobile-ads-android-migrate-to-next-gen

Migrates Android applications from the old, legacy Google Mobile Ads (GMA) SDK (com.google.android.gms:play-services-ads) to the new GMA Next-Gen SDK (com.google.android.libraries.ads.mobile.sdk:ads-mobile-sdk). Provides comprehensive mapping tables for imports, classes, and method signatures to help determine…

google/skills · 105 tokens

agent-platform-tuning

Agent Platform Model Tuning. Use when you need to fine-tune open models or Gemini models using Agent Platform infrastructure. Don't use for model training outside Agent Platform, model deployment to endpoints (use agent-platform-deploy), or managing serving endpoints (use agent-platform-endpoint-management).

google/skills · 64 tokens

application-design-center-design-deploy

Processes GCP infrastructure design and deployment workflows within Application Design Center (ADC). Use when: - Designing GCP infrastructure with Terraform. - Validating local HCL. - Performing best-practice plan scans. - Importing templates to Application Design Center (ADC). - Deploying templates. - Troubleshooting…

google/skills · 94 tokens

cloud-run-basics

Manages Cloud Run services, jobs, and worker pools. Use when you need to deploy applications responding to HTTP requests (services), run event-triggered or scheduled tasks (jobs), or handle always-on pull-based background processing (worker pools).

google/skills · 53 tokens

google-analytics-data-api-basics

Manages Google Analytics reporting data, enables the Analytics Data API via the Cloud CLI, and creates reports using the Google Analytics Data API (v1beta). Use when you need to interact with Google Analytics properties, run customized analytics reports, query metrics (like activeUsers, screenPageViews) and dimensions…

google/skills · 111 tokens

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens