Demo
REFERENCE

testzeus-environments

AUTO-GENERATEDBUILD 2026.12.05

Manage TestZeus environments (dev, staging, production configurations).

Category: data · Version: 1.0.0 · Requires: testzeus-auth

Triggers: environment, create environment, manage environment, upload to environment, staging, production, dev environment, environment config, environment file, environment variables

Overview

Environments in TestZeus store configuration data and files that tests use during execution. They represent different deployment targets (dev, staging, production) with their specific settings.

Quick Reference

bash
# List environments
testzeus environments list

# Create environment
testzeus environments create --name "Staging" \
  --data-file ./staging-config.json

# Get environment
testzeus environments get env_id

# Upload file
testzeus environments upload-file env_id ./config.yaml

# Upload a mobile app file (APK/ZIP) to a mobile environment
testzeus environments upload-mobile-file env_id ./app.apk

# Update
testzeus environments update env_id --name "New Name"

# Delete
testzeus environments delete env_id

Environment Structure

Configuration Data

json
{
  "base_url": "https://staging.example.com",
  "api_url": "https://api.staging.example.com",
  "database": {
    "host": "db.staging.example.com",
    "port": 5432
  },
  "features": {
    "new_checkout": true,
    "beta_features": false
  }
}

File Attachments

Environments can have files attached:

  • Configuration files (yaml, json, env)
  • Certificates and keys
  • Test fixtures

Create Environment

Basic Creation

bash
# From inline JSON
testzeus environments create \
  --name "Development" \
  --data '{
    "base_url": "http://localhost:3000",
    "debug": true
  }'

# From file
testzeus environments create \
  --name "Staging" \
  --data-file ./staging-config.json

# From a config file
testzeus environments create \
  --name "Production" \
  --data-file ./prod-config.json

With Tags

bash
testzeus environments create \
  --name "QA" \
  --data '{}' \
  --tags qa \
  --tags automated

Manage Environments

List Environments

bash
# List all
testzeus environments list

# Filter by status
testzeus environments list --filters status=ready

# Filter by name
testzeus environments list --filters name~"staging"

# Get with details
testzeus environments get env_id
testzeus environments get env_id --expand related_entities

Update Environment

bash
# Update name
testzeus environments update env_id --name "New Name"

# Update
testzeus environments update env_id --name "Updated name"
# Update data
testzeus environments update env_id \
  --data '{"updated": true}'

# Update from file
testzeus environments update env_id \
  --data-file ./new-config.json

Delete Environment

bash
# Delete all files first (recommended)
testzeus environments delete-all-files env_id

# Then delete
testzeus environments delete env_id

File Management

Upload Files

bash
# Upload single file
testzeus environments upload-file env_id ./config.yaml

# Upload multiple files
testzeus environments upload-file env_id ./app-config.yaml
testzeus environments upload-file env_id ./database.yaml
testzeus environments upload-file env_id ./secrets.env

# Upload certificates
testzeus environments upload-file env_id ./server.crt
testzeus environments upload-file env_id ./server.key

# Upload a mobile app build (APK/ZIP) to a mobile environment
testzeus environments upload-mobile-file env_id ./app-release.apk

Remove Files

bash
# Remove specific file
testzeus environments remove-file env_id ./old-config.yaml

# Remove all files
testzeus environments delete-all-files env_id

List Files

Files are accessible via the API or can be viewed in the TestZeus UI.

Environment Examples

Development

bash
testzeus environments create \
  --name "Development" \
  --data '{
    "base_url": "http://localhost:3000",
    "api_url": "http://localhost:8080",
    "debug": true,
    "mock_external_services": true,
    "database": {
      "host": "localhost",
      "port": 5432,
      "name": "testdb"
    }
  }'

Staging

bash
testzeus environments create \
  --name "Staging" \
  --tags staging \
  --data '{
    "base_url": "https://staging.example.com",
    "api_url": "https://api.staging.example.com",
    "debug": false,
    "mock_external_services": false,
    "database": {
      "host": "db.staging.example.com",
      "port": 5432,
      "name": "staging_db"
    },
    "features": {
      "new_checkout": true,
      "beta_ui": true
    }
  }'

Production

bash
testzeus environments create \
  --name "Production" \
  --tags production \
  --data '{
    "base_url": "https://www.example.com",
    "api_url": "https://api.example.com",
    "debug": false,
    "mock_external_services": false,
    "features": {
      "new_checkout": false,
      "beta_ui": false
    }
  }'

Connected Environments

Connected environments track integration status with external systems.

Check Connection Status

bash
# Via SDK
connected = await client.connected_environments.get_one("conn_env_id")

# Check if connected
if connected.has_connection():
    print(f"Connected to: {connected.connection}")
    print(f"Status: {connected.connection_status}")

Create Connected Environment

bash
# Via SDK
connected = await client.connected_environments.create({
    "name": "AWS Staging",
    "type": "aws",
    "config": {
        "region": "us-west-2",
        "account_id": "123456789"
    }
})

Connected Environment Properties

python
connected = await client.connected_environments.get_one("conn_env_id")

# Properties
connected.id           # UUID
connected.name        # "AWS Staging"
connected.type        # "aws", "azure", "gcp", "custom"
connected.config       # Connection config
connected.status      # Connection status

# Methods
connected.has_connection()       # Is connected?
connected.get_connection_info()   # Connection details

SDK Usage

python
from testzeus_sdk import TestZeusClient

async def main():
    async with TestZeusClient() as client:
        # Create environment
        env = await client.environments.create({
            "name": "E2E Tests",
            "data": {
                "base_url": "https://e2e.example.com",
                "timeout": 30000
            },
            "status": "ready"
        })

        # Upload config file
        await client.environments.upload_file(
            env.id,
            "./e2e-config.yaml"
        )

        # Upload certificates
        await client.environments.upload_file(
            env.id,
            "./client.crt"
        )

        # List environments
        all_envs = await client.environments.get_list()

        # Use with tests
        test = await client.tests.create(
            name="E2E Test",
            test_feature="...",
            environment=env.id
        )

Environment Variables

Best Practices

  1. Separate sensitive data

    • Use environments for non-sensitive config
    • Use secrets management for API keys/passwords
    • Don't commit credentials to git
  2. Environment-specific settings

    json
    {
      "debug": true,           // Dev only
      "log_level": "debug",    // Dev only
      "cache_ttl": 300
    }
  3. Feature flags

    json
    {
      "features": {
        "new_ui": false,       // Disabled in prod initially
        "beta_api": true       // Enabled for testing
      }
    }

Error Handling

Common Errors

Error Cause Solution
Env not found Wrong ID List environments first
File too large Exceeds limit Compress or split files
Invalid JSON Malformed config Validate JSON/YAML
Status conflict Can't update archived Restore or create new

Validation

Always validate your config before creating:

bash
# Validate JSON
cat config.json | python -m json.tool > /dev/null && echo "Valid JSON"

# Validate YAML
python -c "import yaml; yaml.safe_load(open('config.yaml'))"

Component Schema

Use EnvironmentCard component:

json
{
  "component": "EnvironmentCard",
  "props": {
    "name": "Staging",
    "status": "ready",
    "type": "staging",
    "tags": ["staging", "automated"],
    "data": {
      "base_url": "https://staging.example.com"
    }
  }
}