# 🧪 Testing Your PyPI Package

## 🎉 Congratulations! You're Live!

Your package is now on PyPI and anyone in the world can install it with `pip install cognitive-guard`!

Let's make sure everything works perfectly before you announce it.

---

## Step 1: Test Installation (Fresh Environment)

Create a completely fresh environment to test as a new user would:

```bash
# Create a new directory for testing
cd /tmp
mkdir pypi-test
cd pypi-test

# Create fresh virtual environment
python -m venv test-env
source test-env/bin/activate  # On Windows: test-env\Scripts\activate

# Install from PyPI (this is what users will do!)
pip install cognitive-guard

# Check version
cognitive-guard --version

# Check help
cognitive-guard --help
```

**✅ Expected Result**: Should install without errors and show version 0.1.0

---

## Step 2: Test All CLI Commands

```bash
# Test 1: Initialize in a project
mkdir sample-project
cd sample-project
git init
git config user.email "test@example.com"
git config user.name "Test User"

cognitive-guard init
# ✅ Should create .cognitive-guard.yml and install git hook

# Test 2: Create a sample file with violations
cat > sample.py << 'EOL'
def complex_function(a, b, c, d):
    if a > 0:
        if b > 0:
            if c > 0:
                if d > 0:
                    return a + b + c + d
    return 0
EOL

# Test 3: Scan the file
cognitive-guard scan
# ✅ Should show violations found

# Test 4: Check statistics
cognitive-guard stats
# ✅ Should show stats (even if zeros)

# Test 5: Try TUI
cognitive-guard tui
# ✅ Should launch TUI (press 'q' to quit)

# Test 6: Test git hook
git add sample.py
git commit -m "Test commit"
# ✅ Should block commit due to undocumented complex function

# Test 7: Fix the file
cat > sample.py << 'EOL'
def complex_function(a, b, c, d):
    """
    Calculate sum of positive numbers.
    
    Args:
        a, b, c, d: Numbers to sum
        
    Returns:
        int: Sum if all positive, else 0
    """
    if a > 0:
        if b > 0:
            if c > 0:
                if d > 0:
                    return a + b + c + d
    return 0
EOL

# Test 8: Commit should succeed now
git add sample.py
git commit -m "Added documentation"
# ✅ Should allow commit
```

---

## Step 3: Test Multi-Language Support

```bash
# Test JavaScript
cat > sample.js << 'EOL'
function complexJS(a, b, c) {
    if (a > 0) {
        if (b > 0) {
            if (c > 0) {
                return a + b + c;
            }
        }
    }
    return 0;
}
EOL

# Test TypeScript
cat > sample.ts << 'EOL'
function complexTS(a: number, b: number, c: number): number {
    if (a > 0) {
        if (b > 0) {
            if (c > 0) {
                return a + b + c;
            }
        }
    }
    return 0;
}
EOL

cognitive-guard scan
# ✅ Should detect violations in JS and TS files
```

---

## Step 4: Verify PyPI Page

Open your package page and check it looks good:

**URL**: https://pypi.org/project/cognitive-guard/
(Or whatever your package name is)

**Check:**
- [ ] Package name is correct
- [ ] Version is 0.1.0
- [ ] Description is clear
- [ ] README renders properly
- [ ] License shows MIT
- [ ] Author info is correct
- [ ] Install command is visible: `pip install cognitive-guard`

---

## Step 5: Test on Different Platforms (Optional)

If you have access:

### Ubuntu/Linux
```bash
python3 -m pip install cognitive-guard
cognitive-guard --version
```

### macOS
```bash
python3 -m pip install cognitive-guard
cognitive-guard --version
```

### Windows
```cmd
python -m pip install cognitive-guard
cognitive-guard --version
```

---

## Quick Smoke Test (30 seconds)

Don't have time for full testing? Run this minimal test:

```bash
# Fresh environment
python -m venv quick-test
source quick-test/bin/activate
pip install cognitive-guard
cognitive-guard --version
cognitive-guard --help
deactivate
```

**If this works → You're good to go!** ✅

---

## Common Issues & Fixes

### Issue: "Command not found: cognitive-guard"

**Cause**: Not in PATH or virtual environment not activated

**Fix**:
```bash
# Make sure venv is activated
source test-env/bin/activate

# Or use python -m
python -m cognitive_guard --help
```

### Issue: "No module named cognitive_guard"

**Cause**: Not installed or wrong environment

**Fix**:
```bash
# Check if installed
pip list | grep cognitive

# Reinstall
pip install --force-reinstall cognitive-guard
```

### Issue: Dependencies fail to install

**Cause**: Conflicting packages or old pip

**Fix**:
```bash
# Update pip
pip install --upgrade pip

# Install again
pip install cognitive-guard
```

### Issue: Git hook doesn't work

**Cause**: Git not initialized or hook script issue

**Fix**:
```bash
# Make sure you're in a git repo
git status

# Reinitialize
cognitive-guard init

# Check hook exists
cat .git/hooks/pre-commit
```

---

## ✅ Everything Works? Next Steps!

If all tests pass, you're ready to:

1. **Create GitHub Release**
   - Go to: https://github.com/yourusername/cognitive-guard/releases
   - Create new release with tag `v0.1.0`
   - Copy changelog into release notes

2. **Update README**
   - Add PyPI badge:
     ```markdown
     [![PyPI version](https://badge.fury.io/py/cognitive-guard.svg)](https://pypi.org/project/cognitive-guard/)
     ```
   - Update installation instructions to use PyPI

3. **Announce to the World!**
   - Post on Reddit r/Python
   - Tweet about it
   - Share on LinkedIn
   - Write a blog post

---

## 🎯 Minimal Test Before Announcing

**Do this bare minimum:**

```bash
# 1. Clean environment
python -m venv test-announce
source test-announce/bin/activate

# 2. Install from PyPI
pip install cognitive-guard

# 3. Basic test
cognitive-guard --version
cognitive-guard --help

# 4. If both work → You're good to announce! 🎉
```

---

## 🚀 Ready to Announce?

Once testing passes, see:
- `LAUNCH_CHECKLIST.md` - Day 6 section for announcement templates
- `WORLD_READY.md` - Marketing strategy

**Congratulations! You've officially launched Cognitive Guard!** 🎊

---

## 📊 Monitoring After Launch

Keep an eye on:

1. **PyPI Downloads**
   - Check: https://pypistats.org/packages/cognitive-guard
   - Or: https://pypi.org/project/cognitive-guard/

2. **GitHub Issues**
   - Respond within 24 hours
   - Fix critical bugs immediately

3. **Community Feedback**
   - Reddit comments
   - Twitter mentions
   - GitHub discussions

4. **Usage Stats**
   - Watch for common issues
   - Note feature requests
   - Track adoption

---

## 🎉 You Did It!

You've gone from an idea to a published PyPI package used by developers worldwide!

**What's next?**
- Keep improving based on feedback
- Add requested features
- Build community
- Help users succeed

**The journey has just begun!** 🚀
