def test_images_extracted_when_just_variants_are_images(self):
     layer_styles = [
         LayerStyle.create_from_sketch_dict(flat_color("*/element/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[selected]/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[disabled]/image")),
     ]
     group = VariantGroup.create_array_from_base_styles(layer_styles)
     found_layers = group[0].items_with_layer_style_image()
     self.assertEqual(len(found_layers), 2,
                      "image layer styles are extracted from variants")
 def test_variant_groups_images(self):
     layer_styles = [
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[selected]/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[disabled]/image")),
     ]
     group = VariantGroup.create_array_from_base_styles(layer_styles)
     self.assertEqual(
         len(group), 1,
         "array of layer styles with 1 element create 1 variant group")
 def test_images_extracted_when_all_images(self):
     layer_styles = [
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[selected]/image")),
         LayerStyle.create_from_sketch_dict(
             image_fill_fit("*/element[disabled]/image")),
     ]
     group = VariantGroup.create_array_from_base_styles(layer_styles)
     found_layers = group[0].items_with_layer_style_image()
     self.assertCountEqual(layer_styles, found_layers,
                           "image layer styles are extracted")
    def test_create_image_fill_fit_layer_style(self):
        sketch_dict = layer_styles_data.image_fill_fit()
        generated = LayerStyle.create_from_sketch_dict(sketch_dict)

        self.assertEqual(generated.name, "*/*/patternFill_Fit")
        self.assertEqual(generated.atom, "patternFill_Fit")
        self.assertIsNone(generated.element)
        self.assertIsNone(generated.section)
        self.assertIsNone(generated.outline)
        self.assertIsNotNone(generated.image)
        self.assertIsNone(generated.gradient)

        self.assertEqual(generated.color.red, 0)
        self.assertEqual(generated.color.green, 0)
        self.assertEqual(generated.color.blue, 0)
        self.assertEqual(generated.color.alpha, 0)

        image = generated.image

        self.assertEqual(image["file_name"], "layer_*_*_patternFill_Fit")
        self.assertEqual(image["tile_scale"], 1)
        self.assertEqual(image["fill_type"], 3)
        self.assertEqual(image["resizingMode"], "stretch")
        self.assertEqual(image["gravity"], "resizeAspect")