예제 #1
0
class TestRectObject(unittest.TestCase):
    def setUp(self):
        self.rect1 = Rect(100, 100, 100, 100, 1)
        self.rect2 = Rect(400, 400, 100, 100, 1)
        self.rect3 = Rect(450, 450, 100, 100, 1)
        self.rect4 = Rect(250, 250, 100, 100, 1)

    def test_area_is_calculated_correctly(self):
        self.assertEqual(10000, self.rect1.area())

    def test_rect_is_rescaled_correctly(self):
        self.rect2.rescale(2)
        self.assertEqual(300, self.rect2.x1)
        self.assertEqual(300, self.rect2.y1)

    def test_other_rect_overlaps(self):
        self.rect2.overlaps(self.rect3)
        self.assertEqual(True, True)
        self.rect2.overlaps(self.rect4)
        self.assertEqual(False, False)

    def test_other_rect_intersection(self):
        self.assertEqual(self.rect2.intersection(self.rect3), 2500)

    def test_other_rect_union(self):
        self.assertEqual(self.rect2.union(self.rect3), 17500)
예제 #2
0
 def test_workflow_exception_when_storage_coordinates_fails(self):
     self.mock_tf_call_service.run.return_value = \
         {(1536, 8192):
          [Rect(562, 954, 665, 111, 0.3364628255367279)]}
     self.mock_coordinate_storage.store.side_effect = Exception()
     self.workflow = WorkFlow(
         self.graph, self.chunk_image, self.mock_tf_call_service,
         self.apply_coordinate_correction, self.filter_merge_boxes,
         self.mock_label_service, self.mock_coordinate_storage,
         self.mock_post_processing, self.provider)
     self.workflow.run()
     self.workflow.provider.acknowledge.assert_not_called()
예제 #3
0
 def test_workflow_exception_when_filter_merge_boxes_fails(self):
     self.mock_tf_call_service.run.return_value = \
         {(1536, 8192):
          [Rect(562, 954, 665, 111, 0.3364628255367279)]}
     self.mock_filter_merge_boxes.run.side_effect = WorkflowException()
     self.workflow = WorkFlow(self.graph, self.chunk_image,
                              self.mock_tf_call_service,
                              self.apply_coordinate_correction,
                              self.mock_filter_merge_boxes,
                              self.mock_label_service, None, None,
                              self.provider)
     self.workflow.run()
     self.workflow.label_service.request_labels.assert_not_called()
예제 #4
0
    def setUp(self):
        self.dict_1_rect_inside_other_rect = [
            Rect(1200, 1050, 400, 300, 0),
            Rect(1200, 1050, 300, 200, 0)
        ]

        self.dict_2_rect_overlapping_less_than_50_percent = \
            [Rect(1200, 1050, 400, 300, 0),
             Rect(1200, 1175, 400, 250, 0)]

        self.dict_2_rect_overlapping_more_than_50_percent = \
            [Rect(1200, 1050, 400, 300, 0),
             Rect(1200, 1125, 400, 350, 0)]

        self.dict_3_rect_overlapping_2_more_than_50_pct = \
            [Rect(1200, 1050, 400, 300, 0),
             Rect(1200, 1125, 400, 350, 0),
             Rect(1250, 1500, 300, 200, 0)]

        self.pano_upload_event = PanoUploadEvent(url="foo",
                                                 container_name='container')
예제 #5
0
 def setUp(self):
     self.rect1 = Rect(100, 100, 100, 100, 1)
     self.rect2 = Rect(400, 400, 100, 100, 1)
     self.rect3 = Rect(450, 450, 100, 100, 1)
     self.rect4 = Rect(250, 250, 100, 100, 1)