Files
flatcam-wsl/descartes/tests.py
Marius Stanciu a4bbb98bf1 - converted from Python2 code to Python3 code
- in camlib.py, CNCJob class -> generate_from_excellon_by_tool() was
failing in the line to sort the tools due of been unable to compare
between dict's. I replaced that section.
2018-05-26 04:43:40 +03:00

39 lines
1.5 KiB
Python

from shapely.geometry import *
import unittest
from descartes.patch import PolygonPatch
class PolygonTestCase(unittest.TestCase):
polygon = Point(0, 0).buffer(10.0).difference(
MultiPoint([(-5, 0), (5, 0)]).buffer(3.0))
def test_patch(self):
patch = PolygonPatch(self.polygon)
self.assertEqual(str(type(patch)),
"<class 'matplotlib.patches.PathPatch'>")
path = patch.get_path()
self.assertTrue(len(path.vertices) == len(path.codes) == 198)
class JSONPolygonTestCase(unittest.TestCase):
polygon = Point(0, 0).buffer(10.0).difference(
MultiPoint([(-5, 0), (5, 0)]).buffer(3.0))
def test_patch(self):
geo = self.polygon.__geo_interface__
patch = PolygonPatch(geo)
self.assertEqual(str(type(patch)),
"<class 'matplotlib.patches.PathPatch'>")
path = patch.get_path()
self.assertTrue(len(path.vertices) == len(path.codes) == 198)
class GeoInterfacePolygonTestCase(unittest.TestCase):
class GeoThing:
__geo_interface__ = None
thing = GeoThing()
thing.__geo_interface__ = Point(0, 0).buffer(10.0).difference(
MultiPoint([(-5, 0), (5, 0)]).buffer(3.0)).__geo_interface__
def test_patch(self):
patch = PolygonPatch(self.thing)
self.assertEqual(str(type(patch)),
"<class 'matplotlib.patches.PathPatch'>")
path = patch.get_path()
self.assertTrue(len(path.vertices) == len(path.codes) == 198)