Quiz 2

Learning Objectives

161 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Learning Objectives - Write unit and integration tests - Debug API endpoints - Handle edge cases ## Step 1: Backend Tests ## Step 2: Frontend Tests - **500 errors**: Check Flask debug output - **404 errors**: Verify route registration - **CORS**: Check flask-cors configuration - **Database**: Run migrations - Back...

Learning Objectives

  • Write unit and integration tests
  • Debug API endpoints
  • Handle edge cases

Step 1: Backend Tests

python
# tests/test_api.py
import unittest
from app import app, db
from models import Post
class TestAPI(unittest.TestCase):
    def setUp(self):
        app.config['TESTING'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
        self.client = app.test_client()
    def test_create_post(self):
        response = self.client.post('/api/posts', json={
            'title': 'Test', 'content': 'Test content'
        })
        self.assertEqual(response.status_code, 201)
        self.assertIn('id', response.get_json())
    def test_get_posts(self):
        response = self.client.get('/api/posts')
        self.assertEqual(response.status_code, 200)

Step 2: Frontend Tests

jsx
// frontend/src/__tests__/App.test.js
import { render, screen } from '@testing-library/react';
import App from '../App';
test('renders app title', () => {
  render(<App />);
  const title = screen.getByText(/MAD1 Project/i);
  expect(title).toBeInTheDocument();
});
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.