# Advanced Software Engineering: Inventory Approvals

Northline Retail, a fictional two-store business, needs a browser-based stock adjustment workflow. Employees submit requests, store managers approve or reject, and operations staff need an audit trail. Duplicate submissions, self-approval and cross-store access must not change stock decisions.

## Required tools
Python 3.11+, a text editor and a terminal. All required Python dependencies are standard library. Git is recommended. No video, paid cloud service or real credentials are required.

## Getting started
Extract this archive to a new folder, then open a terminal in that folder.
```sh
python --version
python -m unittest -v test_service
```
If your system names Python `python3` or `py`, substitute that command throughout. The starter intentionally raises NotImplementedError. These are assignments, not completed solutions.

## Five checkpoints

1. Model requests and persistence
   `python -m unittest -v test_service.TestModel`

2. Enforce store-level authorization
   `python -m unittest -v test_service.TestAuthorization`

3. Make retries and decisions atomic
   `python -m unittest -v test_service.TestReliability`

4. Connect the browser to the Python API
   `python -m unittest -v test_service.TestCapstone`

5. Defend and hand off the application
   `python -m unittest -v test_service.TestCapstone`

Later test classes include earlier checks. Do not remove assertions to obtain a pass. Add your own boundary, fault and regression tests. The suite is a specified acceptance baseline, not exhaustive proof of production security or reliability.

## Troubleshooting
- ModuleNotFoundError: run commands from the extracted kit folder.
- NotImplementedError: implement the named function using its docstring and the lesson.
- AssertionError: compare the expected business rule to the actual result, add a small reproduction and fix the implementation.
- Database locked: close stale processes, use a fresh temporary database for tests, and document transaction behavior.

## Evidence
Save the command, full output, Python version and Git commit SHA. Record any manual checks separately. Submit a permitted HTTPS repository/artifact link plus results, decisions, limitations and assistance in SkillProof. The platform labels this self-reported; it does not run uploaded code or award an external certification.

## Project change
Choose a module's stakeholder change. Write a failing regression test before changing implementation. Explain which acceptance assumptions changed.

## Rights
Fictional business case and synthetic data, created for SkillProof. Adapt the starter and tests for your learning portfolio. Do not include confidential employer data, production credentials or fabricated customer results.

## Local browser workflow
```sh
python server.py
```
Open http://127.0.0.1:8080. Complete web/index.html. Fixture tokens worker-demo and manager-demo are not production authentication. API routes: GET /requests; POST /requests with {item,quantity,key}; POST /requests/{id}/decision with {approve:true|false}. Set Authorization: Bearer <fixture token>. HTTP controls reject extra create fields. Frontend checks are manual: create, list, approve, reject, denied worker decision, keyboard navigation and visible error states.

## Repeatable HTTP acceptance
With `python server.py` running in one terminal, run `python http_checks.py` in a second terminal. This creates uniquely named synthetic adjustment records in the local lab database and checks 401/403 boundaries, retry behavior and decision transitions. Browser keyboard interaction and UI errors still need a manual demonstration. Stop the local server with Ctrl+C when finished.
