def test_set_target_step(self):
     r = self.client.set_target(self.couch_design_step_file)
     self.assertIsNotNone(r, msg="set_target response is not None")
     self.assertEqual(r.status_code, 200, msg="set_target status code")
     response_json = r.json()
     common_test.check_graph_format(self, response_json["data"])
     common_test.check_bounding_box(self, response_json["data"])
     r = self.client.clear()
Example #2
0
 def test_graph_empty(self):
     # Save out the graphs
     r = self.client.graph()
     self.assertIsNotNone(r, msg="graph response is not None")
     self.assertEqual(r.status_code, 200, msg="graph status code")
     response_json = r.json()
     common_test.check_empty_graph_format(self, response_json["data"])
     common_test.check_bounding_box(self, response_json["data"])
Example #3
0
 def test_graph_per_extrude_labels(self):
     # Reconstruct first
     r = self.client.reconstruct(self.couch_design_json_file)
     r = self.client.graph(format="PerExtrude", sequence=False, labels=True)
     self.assertIsNotNone(r, msg="graph response is not None")
     self.assertEqual(r.status_code, 200, msg="graph status code")
     response_json = r.json()
     common_test.check_graph_format(self,
                                    response_json["data"],
                                    mode="PerExtrude",
                                    labels=True)
     common_test.check_bounding_box(self, response_json["data"])
     r = self.client.clear()
Example #4
0
    def test_set_target_add_extrude(self):
        # Set target box
        r = self.client.set_target(self.box_design_smt_file)
        self.assertIsNotNone(r, msg="set_target response is not None")
        self.assertEqual(r.status_code, 200, msg="set_target status code")
        response_json = r.json()
        common_test.check_graph_format(self, response_json["data"])
        common_test.check_bounding_box(self, response_json["data"])

        # Sketch
        r = self.client.add_sketch("XY")
        response_json = r.json()
        sketch_name = response_json["data"]["sketch_name"]
        self.assertIsInstance(sketch_name, str, msg="sketch_name is string")
        pts = [{
            "x": -1,
            "y": 0
        }, {
            "x": 1,
            "y": 0
        }, {
            "x": 1,
            "y": 1
        }, {
            "x": -1,
            "y": 1
        }, {
            "x": -1,
            "y": 0
        }]
        for index in range(4):
            r = self.client.add_line(sketch_name, pts[index], pts[index + 1])
            self.assertEqual(r.status_code, 200, msg="add_line status code")

        response_json = r.json()
        response_data = response_json["data"]
        # Pull out the first profile id
        profile_id = next(iter(response_data["profiles"]))

        # Extrude
        r = self.client.add_extrude(sketch_name, profile_id, 1.0,
                                    "NewBodyFeatureOperation")
        self.assertEqual(r.status_code, 200, msg="add_extrude status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)
        self.assertAlmostEqual(response_data["iou"],
                               0.5,
                               places=2,
                               msg="iou ~= 0.5")
        r = self.client.clear()
 def test_set_target_box(self):
     r = self.client.set_target(self.box_design_smt_file)
     self.assertIsNotNone(r, msg="set_target response is not None")
     self.assertEqual(r.status_code, 200, msg="set_target status code")
     response_json = r.json()
     common_test.check_graph_format(self, response_json["data"])
     common_test.check_bounding_box(self, response_json["data"])
     # Check the bounding box result is correct
     bbox = response_json["data"]["bounding_box"]
     maxp = bbox["max_point"]
     minp = bbox["min_point"]
     x = math.fabs(maxp["x"] - minp["x"])
     y = math.fabs(maxp["y"] - minp["y"])
     z = math.fabs(maxp["z"] - minp["z"])
     self.assertAlmostEqual(x, 1, places=2, msg="bbox x ~= 1")
     self.assertAlmostEqual(y, 1, places=2, msg="bbox y ~= 1")
     self.assertAlmostEqual(z, 1, places=2, msg="bbox z ~= 1")
     r = self.client.clear()