Create and configure an instance for authentication tests
(db)
| 19 | |
| 20 | @pytest.fixture |
| 21 | def setup_instance(db): |
| 22 | """Create and configure an instance for authentication tests""" |
| 23 | instance_id = uuid.uuid4() if not Instance.objects.exists() else Instance.objects.first().id |
| 24 | |
| 25 | # Create or update instance with all required fields |
| 26 | instance, _ = Instance.objects.update_or_create( |
| 27 | id=instance_id, |
| 28 | defaults={ |
| 29 | "instance_name": "Test Instance", |
| 30 | "instance_id": str(uuid.uuid4()), |
| 31 | "current_version": "1.0.0", |
| 32 | "domain": "http://localhost:8000", |
| 33 | "last_checked_at": timezone.now(), |
| 34 | "is_setup_done": True, |
| 35 | }, |
| 36 | ) |
| 37 | return instance |
| 38 | |
| 39 | |
| 40 | @pytest.fixture |