class TestDxfInput(ComparisonMixin, TestCase): effect_class = DhwInput compare_file = [ 'io/PAGE_001.DHW', 'io/PGLT_161.DHW', 'io/PGLT_162.DHW', 'io/PGLT_163.DHW', ] compare_filters = [CompareNumericFuzzy()] comparisons = [()]
class InterpBasicTest(ComparisonMixin, TestCase): effect_class = Interp comparisons = [('--id=path1', '--id=path2', '--id=path3', '--id=path4', '--id=path5', '--id=path6', '--id=path7', '--id=path8', '--id=path9', '--id=path10'), ('--id=path1', '--id=path2', '--id=path3', '--id=path4', '--id=path5', '--id=path6', '--id=path7', '--id=path8', '--id=path9', '--id=path10', '--method=2')] compare_filters = [CompareNumericFuzzy()] compare_file = 'svg/interp_shapes.svg'
class MeshToPathTest(ComparisonMixin, TestCase): """Test mesh to path with comparisons""" compare_filters = [CompareNumericFuzzy()] effect_class = MeshToPath comparisons = [ ('--id=mesh1', '--mode=outline'), ('--id=mesh1', '--mode=gridlines'), ('--id=mesh1', '--mode=meshpatches'), ('--id=mesh1', '--mode=faces'), ] compare_file = 'svg/mesh.svg'
class PrintingMarksBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = PrintingMarks compare_filters = [ CompareNumericFuzzy(), CompareWithPathSpace(), CompareOrderIndependentStyle(), ] compare_file = 'svg/shapes.svg' comparisons = {('--crop_marks', 'True', '--bleed_marks', 'True', '--registration_marks', 'True', '--star_target', 'True', '--colour_bars', 'True', '--page_info', 'True')}
class TestDxfInputBasic(ComparisonMixin, TestCase): compare_file = ['io/test_r12.dxf', 'io/test_r14.dxf'] compare_filters = [CompareNumericFuzzy()] comparisons = [()] effect_class = DxfInput def _apply_compare_filters(self, data, is_saving=None): """Remove the full pathnames""" if is_saving is True: return data data = super()._apply_compare_filters(data) return data.replace((self.datadir() + '/').encode('utf-8'), b'')
class TestDxfInputTextHeight(ComparisonMixin, TestCase): compare_file = ['io/CADTextHeight.dxf'] compare_filters = [CompareNumericFuzzy()] comparisons = [(), ('--textscale=1.411', )] effect_class = DxfInput def _apply_compare_filters(self, data, is_saving=None): """Remove the full pathnames""" if is_saving is True: return data data = super()._apply_compare_filters(data) return data.replace((self.datadir() + '/').encode('utf-8'), b'')
class LengthBasicTest(ComparisonMixin, TestCase): effect_class = MeasureLength compare_filters = [CompareNumericFuzzy()] comparisons = [ ('--id=p1', '--id=p2'), ('--method=presets', '--presetFormat=TaP_start', '--id=p1'), ('--method=presets', '--presetFormat=TaP_end', '--id=p2'), ('--method=presets', '--presetFormat=FT_start', '--id=p1'), ('--method=presets', '--presetFormat=FT_bbox', '--id=p2'), ('--method=presets', '--presetFormat=FT_bbox', '--id=p2'), ('--type=area', '--id=p1'), ('--type=cofm', '--id=c3'), ]
class TestNiceChartBasic(ComparisonMixin, TestCase): effect_class = NiceChart compare_file = 'svg/default-plain-SVG.svg' compare_filters = [CompareNumericFuzzy()] @property def comparisons(self): filename = self.data_file('io/nicechart_01.csv') filearg = '--file={}'.format(filename) return ( (filearg, ), (filearg, '--type=pie'), (filearg, '--type=pie_abs'), (filearg, '--type=stbar'), )
class SplitItBasicTest(ComparisonMixin, TestCase): effect_class = AddNodes compare_filters = [ CompareWithPathSpace(), CompareNumericFuzzy(), ] def test_basic(self): args = ['--id=dashme', self.data_file('svg', 'dash.svg')] effect = self.effect_class() effect.run(args) old_path = effect.original_document.getroot().getElement( '//svg:path').path new_path = effect.svg.getElement('//svg:path').path assert len(new_path) > len(old_path)
class Edge3dBasicTest(ComparisonMixin, TestCase): effect_class = Edge3D compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()] comparisons = [ ('--id=p1', '--id=r3'), ] def test_basic(self): args = ['--id=edgeme', self.data_file('svg', 'edge3d.svg')] self.effect.run(args) old_paths = self.effect.original_document.getroot()\ .xpath('//svg:path[@id="edgeme"]') new_paths = self.effect.svg.xpath('//svg:path[@id="edgeme"]') self.assertEqual(len(old_paths), 1) self.assertEqual(len(new_paths), 1) old_paths = self.effect.original_document.getroot().xpath('//svg:path') new_paths = self.effect.svg.xpath('//svg:path') self.assertEqual(len(old_paths), 1) self.assertEqual(len(new_paths), 4)
class GuidesCreatorBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = GuidesCreator compare_file = 'svg/guides.svg' compare_filters = [ CompareNumericFuzzy(), ] comparisons = [ ('--tab=regular_guides', '--guides_preset=custom'), ('--tab=regular_guides', '--guides_preset=golden', '--delete=True'), ('--tab=regular_guides', '--guides_preset=5;5', '--start_from_edges=True'), ('--tab=diagonal_guides', ), ('--tab=margins', '--start_from_edges=True', '--margins_preset=custom'), ('--tab=margins', '--start_from_edges=True', '--margins_preset=book_left'), ('--tab=margins', '--start_from_edges=True', '--margins_preset=book_right'), ]
class FuncPlotBasicTest(ComparisonMixin, TestCase): effect_class = FuncPlot compare_filters = [CompareNumericFuzzy()] comparisons = [ ('--id=p1', '--id=r3'), ]
class SegmentStraightenerBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = SegmentStraightener compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()]
class TestParamCurvesBasic(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = ParamCurves compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()]
class TestDPIto90to96(ComparisonMixin, TestCase): """Test file with transformed objects in root""" compare_file = 'svg/dpiswitcher_96dpi.svg' comparisons = [('--switcher=0', ), ('--switcher=1', )] compare_filters = [CompareNumericFuzzy()] effect_class = DPISwitcher
class TestDPISwitcherBasic(ComparisonMixin, TestCase): """Default Test with shapes.svg""" effect_class = DPISwitcher compare_filters = [CompareNumericFuzzy()]
class SeamlessPatternBasicTest(ComparisonMixin, TestCase): effect_class = SeamlessPattern compare_filters = [CompareNumericFuzzy()] comparisons = [('--width=100', '--height=100')]
def setUp(self): self.effect_class = Hershey self.compare_filters = [CompareNumericFuzzy(), CompareOrderIndependentStyle()] self.comparisons = self.comparisons_outfile_dict.keys()
class TestWireframeSphereBasic(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = WireframeSphere compare_filters = [CompareNumericFuzzy(), CompareOrderIndependentStyle()]
class CalendarArguments(ComparisonMixin, TestCase): """Test arguments to calendar extensions""" effect_class = Calendar compare_filters = [CompareOrderIndependentStyle(), CompareNumericFuzzy()] comparisons = [()] mocks = [(datetime, 'datetime', FrozenDateTime)] def test_default_names_list(self): """Test default names""" effect = self.assertEffect() self.assertEqual(effect.options.month_names[0], 'January') self.assertEqual(effect.options.month_names[11], 'December') self.assertEqual(effect.options.day_names[0], 'Sun') self.assertEqual(effect.options.day_names[6], 'Sat') self.assertEqual(effect.options.year, datetime.datetime.today().year) self.assertEqual(calendar.firstweekday(), 6) def test_modifyed_names_list(self): """Test modified names list""" effect = self.assertEffect(args=[ '--month-names=JAN FEV MAR ABR MAI JUN JUL AGO SET OUT NOV DEZ', '--day-names=DOM SEG TER QUA QUI SEX SAB', ]) self.assertEqual(effect.options.month_names[0], 'JAN') self.assertEqual(effect.options.month_names[11], 'DEZ') self.assertEqual(effect.options.day_names[0], 'DOM') self.assertEqual(effect.options.day_names[6], 'SAB') def test_starting_names_list(self): """Starting or ending spaces must not affect names""" effect = self.assertEffect(args=[ '--month-names= JAN FEV MAR ABR MAI JUN JUL AGO SET OUT NOV DEZ ', '--day-names= DOM SEG TER QUA QUI SEX SAB ', ]) self.assertEqual(effect.options.month_names[0], 'JAN') self.assertEqual(effect.options.month_names[11], 'DEZ') self.assertEqual(effect.options.day_names[0], 'DOM') self.assertEqual(effect.options.day_names[6], 'SAB') def test_inner_extra_spaces(self): """Extra spaces must not affect names""" effect = self.assertEffect(args=[ '--month-names=JAN FEV MAR ABR MAI JUN JUL AGO SET OUT NOV DEZ', '--day-names=DOM SEG TER QUA QUI SEX SAB', ]) self.assertEqual(effect.options.month_names[0], 'JAN') self.assertEqual(effect.options.month_names[2], 'MAR') self.assertEqual(effect.options.month_names[11], 'DEZ') self.assertEqual(effect.options.day_names[0], 'DOM') self.assertEqual(effect.options.day_names[2], 'TER') self.assertEqual(effect.options.day_names[6], 'SAB') def test_converted_year_zero(self): """Year equal to 0 is converted to correct year""" effect = self.assertEffect(args=['--year=0']) self.assertEqual(effect.options.year, datetime.datetime.today().year) def test_converted_year_thousand(self): """Year equal to 2000 configuration""" effect = self.assertEffect(args=['--year=2000']) self.assertEqual(effect.options.year, 2000) def test_configuring_week_start_sun(self): """Week start is set to Sunday""" self.assertEffect(args=['--start-day=sun']) self.assertEqual(calendar.firstweekday(), 6) def test_configuring_week_start_mon(self): """Week start is set to Monday""" self.assertEffect(args=['--start-day=mon']) self.assertEqual(calendar.firstweekday(), 0) def test_recognize_a_weekend(self): """Recognise a weekend""" effect = self.assertEffect(args=[ '--start-day=sun', '--weekend=sat+sun', ]) self.assertTrue(effect.is_weekend(0), 'Sunday is weekend in this configuration') self.assertTrue(effect.is_weekend(6), 'Saturday is weekend in this configuration') self.assertFalse(effect.is_weekend(1), 'Monday is NOT weekend')
class MotionBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = Motion compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()] comparisons = [ ('--id=c3', '--id=p2'), ]
class TriangleBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = Triangle compare_filters = [CompareNumericFuzzy(), CompareOrderIndependentStyle()]
class WhirlBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): effect_class = Whirl compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()] comparisons = [('--id=p1', '--id=r3')]
class FlattenBasicTest(ComparisonMixin, InkscapeExtensionTestMixin, TestCase): compare_filters = [CompareNumericFuzzy(), CompareWithPathSpace()] effect_class = Flatten