from http import HTTPStatus
from django.test import tag
from django.urls import reverse
from tests.BaseTestWithDB import BaseTestWithDB
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator


@tag("resource")
class PixelPainterResourceViewTest(BaseTestWithDB):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.test_data = ResourcesTestDataGenerator()
        self.language = "en"

    def test_grid_resource_form_view(self):
        resource = self.test_data.create_resource(
            "pixel-painter",
            "Pixel Painter",
            "resources/pixel-painter.html",
            "PixelPainterResourceGenerator",
        )
        kwargs = {
            "resource_slug": resource.slug,
        }
        url = reverse("resources:resource", kwargs=kwargs)
        response = self.client.get(url)
        self.assertEqual(HTTPStatus.OK, response.status_code)

@@ -211,16 +211,239 @@
 nerator%0A
+from resources.utils.get_resource_generator import get_resource_generator%0Afrom utils.create_query_string import query_string%0Afrom resources.utils.resource_valid_test_configurations import resource_valid_test_configurations%0A
 %0A%0A@tag(%22
@@ -676,26 +676,432 @@
 en%22%0A
-%0A    def test_grid
+        self.image_strings = %7B%0A            %22boat%22: %22Boat%22,%0A            %22fish%22: %22Fish%22,%0A            %22hot-air-balloon%22: %22Hot air balloon%22,%0A            %22parrots%22: %22Parrots%22,%0A        %7D%0A        self.method_strings = %7B%0A            %22black-white%22: %22Black and White%22,%0A            %22run-length-encoding%22: %22Run length encoding%22,%0A            %22greyscale%22: %22Greyscale%22,%0A            %22colour%22: %22Colour%22,%0A        %7D%0A%0A    def test_pixel_painter
 _res
@@ -1565,8 +1565,1370 @@
 s_code)%0A
+%0A    def test_pixel_painter_resource_generation_valid_configurations(self):%0A        resource = self.test_data.create_resource(%0A            %22pixel-painter%22,%0A            %22Pixel Painter%22,%0A            %22resources/pixel-painter.html%22,%0A            %22PixelPainterResourceGenerator%22,%0A        )%0A        kwargs = %7B%0A            %22resource_slug%22: resource.slug,%0A        %7D%0A        base_url = reverse(%22resources:generate%22, kwargs=kwargs)%0A        empty_generator = get_resource_generator(resource.generator_module)%0A        combinations = resource_valid_test_configurations(%0A            empty_generator.valid_options%0A        )%0A%0A        print()%0A        for combination in combinations:%0A            print(%22   - Testing combination: %7B%7D ... %22.format(combination), end=%22%22)%0A            url = base_url + query_string(combination)%0A            response = self.client.get(url)%0A            self.assertEqual(HTTPStatus.OK, response.status_code)%0A            subtitle = %22%7B%7D - %7B%7D - %7B%7D%22.format(%0A                self.image_strings%5Bcombination%5B%22image%22%5D%5D,%0A                self.method_strings%5Bcombination%5B%22method%22%5D%5D,%0A                combination%5B%22paper_size%22%5D%0A            )%0A            self.assertEqual(%0A                response.get(%22Content-Disposition%22),%0A                'attachment; filename=%22Resource Pixel Painter (%7Bsubtitle%7D).pdf%22'.format(subtitle=subtitle)%0A            )%0A            print(%22ok%22)%0A

Add basic test for pixel painter resource