Files
Ethan Roseman 50a2b836b9 Migrate from poetry/black to uv/ruff (#1673)
* Migrate from poetry/black to uv/ruff

* fixes

* path change

* path pt 2

* ah

* mkst tweaks (#1674)

* mkst tweaks

* tweaks++

* doh

* tweak harder

---------

Co-authored-by: Mark Street <22226349+mkst@users.noreply.github.com>
2025-09-22 19:23:55 +09:00

40 lines
1.3 KiB
Python

from typing import Any, Callable, Dict
from unittest import skip, skipIf
from coreapp import compilers, platforms
from coreapp.compilers import Compiler
from coreapp.models.scratch import Scratch
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
def requiresCompiler(*compilers: Compiler) -> Callable[..., Any]:
for c in compilers:
if not c.available():
return skip(f"Compiler {c.id} not available")
return skipIf(False, "")
class BaseTestCase(APITestCase):
def setUp(self) -> None:
super().setUp()
self.client.credentials(HTTP_USER_AGENT="Firefrogz 1.0")
# Create a scratch and return it as a DB object
def create_scratch(self, partial: Dict[str, Any]) -> Scratch:
response = self.client.post(reverse("scratch-list"), partial, format="json")
self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())
scratch = Scratch.objects.get(slug=response.json()["slug"])
assert scratch is not None
return scratch
def create_nop_scratch(self) -> Scratch:
scratch_dict = {
"compiler": compilers.DUMMY.id,
"platform": platforms.DUMMY.id,
"context": "",
"target_asm": "jr $ra\nnop\n",
}
return self.create_scratch(scratch_dict)