예제 #1
0
	def setUp(self):
		self.gi = GraffleInterpreter()
		self.MockTarget = Mock()
		self.MockTarget.style=scope()
		self.gi.setTarget(self.MockTarget)
예제 #2
0
 def setUp(self):
     self.gi = GraffleInterpreter()
     self.MockTarget = Mock()
     self.MockTarget.style = scope()
     self.gi.setTarget(self.MockTarget)
예제 #3
0
class TestGraffleInterpreterBoundingBox(TestCase):
	def setUp(self):
		self.gi = GraffleInterpreter()
		self.MockTarget = Mock()
		self.MockTarget.style=scope()
		self.gi.setTarget(self.MockTarget)
		
	def tearDown(self):
		del self.MockTarget
		del self.gi

	@patch('graffle2svg.geom.out_of_boundingbox')
	def testTextWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(self, mockBounds):
		self.gi.bounding_box = ((-1, -1),  (1,  1))
		mockBounds.return_value = True
		self.gi.iterateGraffleGraphics([{'Class':'ShapedGraphic', 'Bounds':'{{0, 0}, {756, 553}}','Shape':'RoundRect', 'ID':5, 'Text':{'Text':'test'}}])
		self.assertFalse(any([ mthd_call[0]=='addText' for mthd_call in self.MockTarget.method_calls]))

	@patch('graffle2svg.geom.out_of_boundingbox')
	def testShapedGraphicWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(self, mockBounds):
		self.gi.bounding_box = ((-1, -1),  (1,  1))
		mockBounds.return_value = True
		self.gi.iterateGraffleGraphics([{'Class':'ShapedGraphic', 'Bounds':'{{0, 0}, {756, 553}}','Shape':'RoundRect', 'ID':5}])
		self.assertFalse(any([ mthd_call[0]=='addRect' for mthd_call in self.MockTarget.method_calls]))
		
	@patch('graffle2svg.geom.out_of_boundingbox')
	def testShapedGraphicWithCoordinatesInBoundingBoxShouldAddToTarget(self, mockBounds):
		self.gi.bounding_box = ((-1, -1),  (1,  1))
		mockBounds.return_value = False
		self.gi.iterateGraffleGraphics([{'Class':'ShapedGraphic', 'Bounds':'{{0, 0}, {756, 553}}','Shape':'RoundRect',  'ID':5}])
		self.assertTrue(any([ mthd_call[0]=='addRect' for mthd_call in self.MockTarget.method_calls]))

	def testShapedGraphicWithNoBoundingBoxShouldAddToTarget(self):
		self.gi.bounding_box=None
		self.gi.iterateGraffleGraphics([{'Class':'ShapedGraphic', 'Bounds':'{{0, 0}, {756, 553}}','Shape':'RoundRect',  'ID':5}])
		self.assertTrue(any([ mthd_call[0]=='addRect' for mthd_call in self.MockTarget.method_calls]))

	@patch('graffle2svg.geom.out_of_boundingbox')
	def testLineGraphicWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(self, mockBounds):
		self.gi.bounding_box = ((-1, -1),  (1,  1))
		mockBounds.return_value = True
		self.gi.iterateGraffleGraphics([{'Class':'LineGraphic', 'Points':['{0, 0}', '{756, 553}'], 'ID':5}])
		self.assertFalse(any([ mthd_call[0]=='addPath' for mthd_call in self.MockTarget.method_calls]))
		
	@patch('graffle2svg.geom.out_of_boundingbox')
	def testLineGraphicWithCoordinatesInBoundingBoxShouldAddToTarget(self, mockBounds):
		self.gi.bounding_box = ((-1, -1),  (1,  1))
		mockBounds.return_value = False
		self.gi.iterateGraffleGraphics([{'Class':'LineGraphic', 'Points':['{0, 0}', '{756, 553}'], 'ID':5}])
		self.assertTrue(any([ mthd_call[0]=='addPath' for mthd_call in self.MockTarget.method_calls]))

	def testLineGraphicWithNoBoundingBoxShouldAddToTarget(self):
		self.gi.iterateGraffleGraphics([{'Class':'LineGraphic', 'Points':['{0, 0}', '{756, 553}'], 'ID':5}])
		self.assertTrue(any([ mthd_call[0]=='addPath' for mthd_call in self.MockTarget.method_calls]))
예제 #4
0
class TestGraffleInterpreterBoundingBox(TestCase):
    def setUp(self):
        self.gi = GraffleInterpreter()
        self.MockTarget = Mock()
        self.MockTarget.style = scope()
        self.gi.setTarget(self.MockTarget)

    def tearDown(self):
        del self.MockTarget
        del self.gi

    @patch('graffle2svg.geom.out_of_boundingbox')
    def testTextWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(
            self, mockBounds):
        self.gi.bounding_box = ((-1, -1), (1, 1))
        mockBounds.return_value = True
        self.gi.iterateGraffleGraphics([{
            'Class': 'ShapedGraphic',
            'Bounds': '{{0, 0}, {756, 553}}',
            'Shape': 'RoundRect',
            'ID': 5,
            'Text': {
                'Text': 'test'
            }
        }])
        self.assertFalse(
            any([
                mthd_call[0] == 'addText'
                for mthd_call in self.MockTarget.method_calls
            ]))

    @patch('graffle2svg.geom.out_of_boundingbox')
    def testShapedGraphicWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(
            self, mockBounds):
        self.gi.bounding_box = ((-1, -1), (1, 1))
        mockBounds.return_value = True
        self.gi.iterateGraffleGraphics([{
            'Class': 'ShapedGraphic',
            'Bounds': '{{0, 0}, {756, 553}}',
            'Shape': 'RoundRect',
            'ID': 5
        }])
        self.assertFalse(
            any([
                mthd_call[0] == 'addRect'
                for mthd_call in self.MockTarget.method_calls
            ]))

    @patch('graffle2svg.geom.out_of_boundingbox')
    def testShapedGraphicWithCoordinatesInBoundingBoxShouldAddToTarget(
            self, mockBounds):
        self.gi.bounding_box = ((-1, -1), (1, 1))
        mockBounds.return_value = False
        self.gi.iterateGraffleGraphics([{
            'Class': 'ShapedGraphic',
            'Bounds': '{{0, 0}, {756, 553}}',
            'Shape': 'RoundRect',
            'ID': 5
        }])
        self.assertTrue(
            any([
                mthd_call[0] == 'addRect'
                for mthd_call in self.MockTarget.method_calls
            ]))

    def testShapedGraphicWithNoBoundingBoxShouldAddToTarget(self):
        self.gi.bounding_box = None
        self.gi.iterateGraffleGraphics([{
            'Class': 'ShapedGraphic',
            'Bounds': '{{0, 0}, {756, 553}}',
            'Shape': 'RoundRect',
            'ID': 5
        }])
        self.assertTrue(
            any([
                mthd_call[0] == 'addRect'
                for mthd_call in self.MockTarget.method_calls
            ]))

    @patch('graffle2svg.geom.out_of_boundingbox')
    def testLineGraphicWithCoordinatesOutOfBoundinBoxShouldNotAddToTarget(
            self, mockBounds):
        self.gi.bounding_box = ((-1, -1), (1, 1))
        mockBounds.return_value = True
        self.gi.iterateGraffleGraphics([{
            'Class': 'LineGraphic',
            'Points': ['{0, 0}', '{756, 553}'],
            'ID': 5
        }])
        self.assertFalse(
            any([
                mthd_call[0] == 'addPath'
                for mthd_call in self.MockTarget.method_calls
            ]))

    @patch('graffle2svg.geom.out_of_boundingbox')
    def testLineGraphicWithCoordinatesInBoundingBoxShouldAddToTarget(
            self, mockBounds):
        self.gi.bounding_box = ((-1, -1), (1, 1))
        mockBounds.return_value = False
        self.gi.iterateGraffleGraphics([{
            'Class': 'LineGraphic',
            'Points': ['{0, 0}', '{756, 553}'],
            'ID': 5
        }])
        self.assertTrue(
            any([
                mthd_call[0] == 'addPath'
                for mthd_call in self.MockTarget.method_calls
            ]))

    def testLineGraphicWithNoBoundingBoxShouldAddToTarget(self):
        self.gi.iterateGraffleGraphics([{
            'Class': 'LineGraphic',
            'Points': ['{0, 0}', '{756, 553}'],
            'ID': 5
        }])
        self.assertTrue(
            any([
                mthd_call[0] == 'addPath'
                for mthd_call in self.MockTarget.method_calls
            ]))