示例#1
0
    def test_revise_two_childrens_get(self):
        """
        Tests a get request to revise a part with two children.
        """
        child1 = PartController.create("RefChild1", "Part", "a", self.user,
                                       self.DATA)
        self.controller.add_child(child1, 10, 25, "-")
        child2 = PartController.create("RefChild2", "Part", "a", self.user,
                                       self.DATA)
        self.controller.add_child(child2, 10, 55, "-")

        response = self.get(self.base_url + "revisions/")
        # checks that it is necessary to confirm the revision
        self.assertTrue(response.context["confirmation"])
        formset = response.context["children_formset"]

        self.assertEqual(2, formset.total_form_count())
        form1, form2 = formset.forms
        self.assertTrue(form1.fields["selected"].initial)
        self.assertTrue(form1.initial["link"].child_id in (child1.id,
                                                           child2.id))
        self.assertTrue(form2.fields["selected"].initial)
        self.assertTrue(form2.initial["link"].child_id in (child1.id,
                                                           child2.id))
        self.assertNotEqual(form2.initial["link"], form1.initial["link"])
示例#2
0
文件: navigate.py 项目: amarh/openPLM
 def test_navigate_parents(self):
     """
     Tests a navigate with the "parents" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     parent1 = PartController.create("c1", "Part", "k",
             self.user, data, True, True)
     parent1.add_child(self.controller, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (parent1.object, ))):
         self.get_graph_data({"parents" : True, OSR : osr }, results)
         self.assertCount(2, 1)
         main, parent_node = self.nodes
         self.assertTrue("789" in self.edges[0].text_content())
         self.assertTrue("15" in self.edges[0].text_content())
         self.assertTrue("kg" in self.edges[0].text_content())
         text = parent_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     # add another parent to parent1
     parent2 = PartController.create("c2", "Part", "k",
             self.user, data, True, True)
     parent2.add_child(parent1, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (parent1.object, parent2.object))):
         self.get_graph_data({"parents" : True, OSR : osr }, results)
         self.assertCount(3, 2)
     self.get_graph_data({"parents" : True, OSR : True }, (parent2.object,))
     self.assertCount(1, 0)
     # add the controller to parent2
     parent2.add_child(self.controller, 5, 79, "kg")
     for osr, results in ((False, ()), (True, (parent1.object, parent2.object))):
         self.get_graph_data({"parents" : True, OSR : osr }, results)
         self.assertCount(3, 3)
     for result in (self.cie, self.group, self.user, self.controller.object):
         self.get_graph_data({"parents" : True, OSR : True }, (result,))
         self.assertCount(1, 0)
示例#3
0
 def test_parents(self):
     p1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     p1.add_child(self.controller, 10, 20)
     p2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
     p2.add_child(self.controller, 10, 20)
     response = self.get(self.base_url + "parents/", page="parents")
     self.assertEqual(2, len(list(response.context["parents"])))
示例#4
0
文件: part.py 项目: amarh/openPLM
 def test_parents(self):
     p1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     p1.add_child(self.controller, 10, 20)
     p2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
     p2.add_child(self.controller, 10, 20)
     response = self.get(self.base_url + "parents/", page="parents")
     self.assertEqual(2, len(list(response.context["parents"])))
示例#5
0
文件: part.py 项目: amarh/openPLM
 def test_children(self):
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child1, 10 , 20)
     child2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child2, 10, 20)
     response = self.get(self.base_url + "BOM-child/", page="BOM-child")
     self.assertEqual(2, len(list(response.context["children"])))
     form = response.context["display_form"]
示例#6
0
 def test_children(self):
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child1, 10, 20)
     child2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child2, 10, 20)
     response = self.get(self.base_url + "BOM-child/", page="BOM-child")
     self.assertEqual(2, len(list(response.context["children"])))
     form = response.context["display_form"]
示例#7
0
文件: part.py 项目: amarh/openPLM
 def test_add_child(self):
     response = self.get(self.base_url + "BOM-child/add/", link=True)
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     response = self.client.post(self.base_url + "BOM-child/add/",
             {"type": "Part", "reference":"c1", "revision":"a",
                 "quantity" : 10, "order" : 10, "unit" : "m"})
     self.assertEquals(1, len(self.controller.get_children()))
示例#8
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_child_post_unselected(self):
     """
     Tests a post request to revise a part with child which is not selected.
     """
     child = PartController.create("RefChild", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child, 10, 25, "-")
     link = self.controller.get_children(1)[0].link
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "0",
              "parents-INITIAL_FORMS" : "0",
              "children-TOTAL_FORMS" : "1",
              "children-INITIAL_FORMS" : "1",
              "children-0-selected" : "",
              "children-0-link" : link.id,
              "documents-TOTAL_FORMS" : "0",
              "documents-INITIAL_FORMS" : "0",
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the part is still a child of the old revision
     children = self.controller.get_children(1)
     self.assertEqual([(1, link)], children)
     # ensure the part is not a child of the new revision
     children = PartController(rev, self.user).get_children(1)
     self.assertEqual(0, len(children))
示例#9
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_parent_post_unselected(self):
     """
     Tests a post request to revise a part which has one parent.
     This parent is not selected, and so its bom should not change.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user, self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "1",
              "parents-INITIAL_FORMS" : "1",
              "parents-0-selected" : "",
              "parents-0-link" : link.id,
              "parents-0-new_parent" : parent.id,
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "0",
              "documents-INITIAL_FORMS" : "0",
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertEqual([(1, link)], children)
     self.assertFalse(PartController(rev, self.user).get_parents())
示例#10
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_parent_post_selected(self):
     """
     Tests a post request to revise a part which has one parent.
     This parent is selected, and so its bom must be updated.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user, self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "1",
              "parents-INITIAL_FORMS" : "1",
              "parents-0-selected" : "on",
              "parents-0-link" : link.id,
              "parents-0-new_parent" : parent.id,
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "0",
              "documents-INITIAL_FORMS" : "0",
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertNotEqual([(1, link)], children)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(rev.id, link2.child_id)
     self.assertFalse(self.controller.get_parents())
示例#11
0
文件: api.py 项目: pcon-world/pcon_db
 def test_attached_parts_two_parts(self):
     doc = DocumentController.create("Doc", "Document", "a", self.user,
             self.DATA)
     doc.attach_to_part(self.controller)
     part2 = PartController.create("Part2", "Part", "a", self.user, self.DATA)
     doc.attach_to_part(part2)
     wanted = [
         {
             "id": self.controller.id,
             "reference": self.controller.reference,
             "type": self.controller.type,
             "revision": self.controller.revision,
             "name": self.controller.name,
         },
         {
             "id": part2.id,
             "reference": part2.reference,
             "type": part2.type,
             "revision": part2.revision,
             "name": part2.name,
         },
     ]
     key = lambda x: x["id"]
     url = "/api/object/%d/attached_parts/" % doc.id
     data = self.get(url)
     self.assertEqual(sorted(data["parts"], key=key), sorted(wanted, key=key))
示例#12
0
 def test_revise_one_child_post_unselected(self):
     """
     Tests a post request to revise a part with child which is not selected.
     """
     child = PartController.create("RefChild", "Part", "a", self.user,
                                   self.DATA)
     self.controller.add_child(child, 10, 25, "-")
     link = self.controller.get_children(1)[0].link
     data = {
         "revision": "b",
         "parents-TOTAL_FORMS": "0",
         "parents-INITIAL_FORMS": "0",
         "children-TOTAL_FORMS": "1",
         "children-INITIAL_FORMS": "1",
         "children-0-selected": "",
         "children-0-link": link.id,
         "documents-TOTAL_FORMS": "0",
         "documents-INITIAL_FORMS": "0",
     }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the part is still a child of the old revision
     children = self.controller.get_children(1)
     self.assertEqual([(1, link)], children)
     # ensure the part is not a child of the new revision
     children = PartController(rev, self.user).get_children(1)
     self.assertEqual(0, len(children))
示例#13
0
 def test_revise_one_parent_post_unselected(self):
     """
     Tests a post request to revise a part which has one parent.
     This parent is not selected, and so its bom should not change.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user,
                                    self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     data = {
         "revision": "b",
         "parents-TOTAL_FORMS": "1",
         "parents-INITIAL_FORMS": "1",
         "parents-0-selected": "",
         "parents-0-link": link.id,
         "parents-0-new_parent": parent.id,
         "children-TOTAL_FORMS": "0",
         "children-INITIAL_FORMS": "0",
         "documents-TOTAL_FORMS": "0",
         "documents-INITIAL_FORMS": "0",
     }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertEqual([(1, link)], children)
     self.assertFalse(PartController(rev, self.user).get_parents())
示例#14
0
 def test_navigate_children(self):
     """
     Tests a navigate with the "child" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     child1 = PartController.create("c1", "Part", "k", self.user, data,
                                    True, True)
     self.controller.add_child(child1, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object, ))):
         self.get_graph_data({"child": True, OSR: osr}, results)
         self.assertCount(2, 1)
         main, child_node = self.nodes
         # check the edge
         self.assertTrue("15" in self.edges[0].text_content())
         self.assertTrue("kg" in self.edges[0].text_content())
         text = child_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     # add another child to child1
     child2 = PartController.create("c2", "Part", "k", self.user, data,
                                    True, True)
     child1.add_child(child2, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object,
                                               child2.object))):
         self.get_graph_data({"child": True, OSR: osr}, results)
         self.assertCount(3, 2)
     # empty graph is child1 is not found
     self.get_graph_data({"child": True, OSR: True}, (child2.object, ))
     self.assertCount(1, 0)
     # add child2 to the controller
     # we should have 3 nodes (controller, child1, child2)
     # and 3 edges (controller -> child1, controller -> child2 and
     # child1 -> child2)
     self.controller.add_child(child2, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object,
                                               child2.object))):
         self.get_graph_data({"child": True, OSR: osr}, results)
         self.assertCount(3, 3)
     for result in (self.cie, self.group, self.user,
                    self.controller.object):
         self.get_graph_data({"child": True, OSR: True}, (result, ))
         self.assertCount(1, 0)
示例#15
0
    def test_revise_two_childrens_post(self):
        """
        Tests a post request to revise a part with two children.
        Only one child is selected.
        """
        child1 = PartController.create("RefChild1", "Part", "a", self.user,
                                       self.DATA)
        self.controller.add_child(child1, 10, 25, "-")
        child2 = PartController.create("RefChild2", "Part", "a", self.user,
                                       self.DATA)
        self.controller.add_child(child2, 10, 55, "-")

        link1, link2 = [c.link for c in self.controller.get_children(1)]
        data = {
            "revision": "b",
            "parents-TOTAL_FORMS": "0",
            "parents-INITIAL_FORMS": "0",
            "children-TOTAL_FORMS": "1",
            "children-INITIAL_FORMS": "1",
            "children-0-selected": "on",
            "children-0-link": link1.id,
            "children-1-selected": "",
            "children-1-link": link2.id,
            "documents-TOTAL_FORMS": "0",
            "documents-INITIAL_FORMS": "0",
        }
        response = self.post(self.base_url + "revisions/", data)
        revisions = self.controller.get_next_revisions()
        self.assertEqual(1, len(revisions))
        rev = revisions[0].part
        self.assertEqual("b", rev.revision)
        # ensure the part is still a child of the old revision
        children = self.controller.get_children(1)
        self.assertEqual(set(((1, link1), (1, link2))), set(children))
        children = PartController(rev, self.user).get_children(1)
        self.assertEqual(1, len(children))

        link = children[0].link
        self.assertEqual(link1.child, link.child)
        self.assertEqual(link1.order, link.order)
        self.assertEqual(link1.quantity, link.quantity)
        self.assertEqual(link1.unit, link.unit)
示例#16
0
文件: part.py 项目: amarh/openPLM
    def test_revise_two_childrens_get(self):
        """
        Tests a get request to revise a part with two children.
        """
        child1 = PartController.create("RefChild1", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child1, 10, 25, "-")
        child2 = PartController.create("RefChild2", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child2, 10, 55, "-")

        response = self.get(self.base_url + "revisions/")
        # checks that it is necessary to confirm the revision
        self.assertTrue(response.context["confirmation"])
        formset = response.context["children_formset"]

        self.assertEqual(2, formset.total_form_count())
        form1, form2 = formset.forms
        self.assertTrue(form1.fields["selected"].initial)
        self.assertTrue(form1.initial["link"].child_id in (child1.id, child2.id))
        self.assertTrue(form2.fields["selected"].initial)
        self.assertTrue(form2.initial["link"].child_id in (child1.id, child2.id))
        self.assertNotEqual(form2.initial["link"], form1.initial["link"])
示例#17
0
 def test_revise_one_revised_parent_post2(self):
     """
     Tests a post request to revise a part which has one parent which has been
     revised before the bom was built.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user,
                                    self.DATA)
     parent2 = parent.revise("the game")
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["parents_formset"]
     self.assertEqual(2, formset.total_form_count())
     data = {
         "revision": "b",
         "parents-TOTAL_FORMS": "2",
         "parents-INITIAL_FORMS": "2",
         "parents-0-selected": "",
         "parents-0-link": link.id,
         "parents-0-new_parent": parent.id,
         "parents-1-selected": "on",
         "parents-1-link": link.id,
         "parents-1-new_parent": parent2.id,
         "children-TOTAL_FORMS": "0",
         "children-INITIAL_FORMS": "0",
         "documents-TOTAL_FORMS": "0",
         "documents-INITIAL_FORMS": "0",
     }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(self.controller.id, link2.child_id)
     # ensure the new revisison is a child of the parent
     children = parent2.get_children(1)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent2.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(rev.id, link2.child_id)
示例#18
0
 def test_add_child(self):
     response = self.get(self.base_url + "BOM-child/add/", link=True)
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     response = self.client.post(
         self.base_url + "BOM-child/add/", {
             "type": "Part",
             "reference": "c1",
             "revision": "a",
             "quantity": 10,
             "order": 10,
             "unit": "m"
         })
     self.assertEquals(1, len(self.controller.get_children()))
示例#19
0
文件: navigate.py 项目: amarh/openPLM
 def test_navigate_children(self):
     """
     Tests a navigate with the "child" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     child1 = PartController.create("c1", "Part", "k",
             self.user, data, True, True)
     self.controller.add_child(child1, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object,))):
         self.get_graph_data({"child" : True, OSR : osr }, results)
         self.assertCount(2, 1)
         main, child_node = self.nodes
         # check the edge
         self.assertTrue("15" in self.edges[0].text_content())
         self.assertTrue("kg" in self.edges[0].text_content())
         text = child_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     # add another child to child1
     child2 = PartController.create("c2", "Part", "k",
             self.user, data, True, True)
     child1.add_child(child2, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object, child2.object))):
         self.get_graph_data({"child" : True, OSR : osr }, results)
         self.assertCount(3, 2)
     # empty graph is child1 is not found
     self.get_graph_data({"child" : True, OSR : True }, (child2.object,))
     self.assertCount(1, 0)
     # add child2 to the controller
     # we should have 3 nodes (controller, child1, child2)
     # and 3 edges (controller -> child1, controller -> child2 and
     # child1 -> child2)
     self.controller.add_child(child2, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (child1.object, child2.object))):
         self.get_graph_data({"child" : True, OSR : osr }, results)
         self.assertCount(3, 3)
     for result in (self.cie, self.group, self.user, self.controller.object):
         self.get_graph_data({"child" : True, OSR : True }, (result,))
         self.assertCount(1, 0)
示例#20
0
文件: part.py 项目: amarh/openPLM
    def test_revise_two_childrens_post(self):
        """
        Tests a post request to revise a part with two children.
        Only one child is selected.
        """
        child1 = PartController.create("RefChild1", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child1, 10, 25, "-")
        child2 = PartController.create("RefChild2", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child2, 10, 55, "-")

        link1, link2 = [c.link for c in self.controller.get_children(1)]
        data = { "revision" : "b",
                 "parents-TOTAL_FORMS" : "0",
                 "parents-INITIAL_FORMS" : "0",
                 "children-TOTAL_FORMS" : "1",
                 "children-INITIAL_FORMS" : "1",
                 "children-0-selected" : "on",
                 "children-0-link" : link1.id,
                 "children-1-selected" : "",
                 "children-1-link" : link2.id,
                 "documents-TOTAL_FORMS" : "0",
                 "documents-INITIAL_FORMS" : "0",
                 }
        response = self.post(self.base_url + "revisions/", data)
        revisions = self.controller.get_next_revisions()
        self.assertEqual(1, len(revisions))
        rev = revisions[0].part
        self.assertEqual("b", rev.revision)
        # ensure the part is still a child of the old revision
        children = self.controller.get_children(1)
        self.assertEqual(set(((1, link1), (1, link2))), set(children))
        children = PartController(rev, self.user).get_children(1)
        self.assertEqual(1, len(children))

        link = children[0].link
        self.assertEqual(link1.child, link.child)
        self.assertEqual(link1.order, link.order)
        self.assertEqual(link1.quantity, link.quantity)
        self.assertEqual(link1.unit, link.unit)
示例#21
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_revised_parent_post2(self):
     """
     Tests a post request to revise a part which has one parent which has been
     revised before the bom was built.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user, self.DATA)
     parent2 = parent.revise("the game")
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["parents_formset"]
     self.assertEqual(2, formset.total_form_count())
     data = { "revision" : "b",
              "parents-TOTAL_FORMS" : "2",
              "parents-INITIAL_FORMS" : "2",
              "parents-0-selected" : "",
              "parents-0-link" : link.id,
              "parents-0-new_parent" : parent.id,
              "parents-1-selected" : "on",
              "parents-1-link" : link.id,
              "parents-1-new_parent" : parent2.id,
              "children-TOTAL_FORMS" : "0",
              "children-INITIAL_FORMS" : "0",
              "documents-TOTAL_FORMS" : "0",
              "documents-INITIAL_FORMS" : "0",
              }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(self.controller.id, link2.child_id)
     # ensure the new revisison is a child of the parent
     children = parent2.get_children(1)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent2.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(rev.id, link2.child_id)
示例#22
0
 def test_navigate_parents(self):
     """
     Tests a navigate with the "parents" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     parent1 = PartController.create("c1", "Part", "k", self.user, data,
                                     True, True)
     parent1.add_child(self.controller, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (parent1.object, ))):
         self.get_graph_data({"parents": True, OSR: osr}, results)
         self.assertCount(2, 1)
         main, parent_node = self.nodes
         self.assertTrue("789" in self.edges[0].text_content())
         self.assertTrue("15" in self.edges[0].text_content())
         self.assertTrue("kg" in self.edges[0].text_content())
         text = parent_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     # add another parent to parent1
     parent2 = PartController.create("c2", "Part", "k", self.user, data,
                                     True, True)
     parent2.add_child(parent1, 15, 789, "kg")
     for osr, results in ((False, ()), (True, (parent1.object,
                                               parent2.object))):
         self.get_graph_data({"parents": True, OSR: osr}, results)
         self.assertCount(3, 2)
     self.get_graph_data({"parents": True, OSR: True}, (parent2.object, ))
     self.assertCount(1, 0)
     # add the controller to parent2
     parent2.add_child(self.controller, 5, 79, "kg")
     for osr, results in ((False, ()), (True, (parent1.object,
                                               parent2.object))):
         self.get_graph_data({"parents": True, OSR: osr}, results)
         self.assertCount(3, 3)
     for result in (self.cie, self.group, self.user,
                    self.controller.object):
         self.get_graph_data({"parents": True, OSR: True}, (result, ))
         self.assertCount(1, 0)
示例#23
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_child_get(self):
     """
     Tests a get request to revise a part which has one child.
     This child must be suggested when the user revises the part.
     """
     child = PartController.create("RefChild", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child, 10, 25, "-")
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["children_formset"]
     self.assertEqual(1, formset.total_form_count())
     form = formset.forms[0]
     self.assertTrue(form.fields["selected"].initial)
     self.assertEqual(child.id, form.initial["link"].child_id)
示例#24
0
文件: group.py 项目: amarh/openPLM
 def test_plmobjects(self):
     response = self.get(self.group_url + "objects/", page="objects")
     objects = response.context["objects"]
     self.assertEqual([self.part_controller.plmobject_ptr], list(objects.object_list))
     # create a new group
     group = m.GroupInfo(name="grp2", owner=self.user, creator=self.user,
             description="grp")
     group.save()
     self.user.groups.add(group)
     # create another part which bellows to another group
     p2 = PartController.create("Part2", "Part", "a", self.user,
             dict(group=group))
     response = self.get(self.group_url + "objects/", page="objects")
     objects = response.context["objects"]
     self.assertEqual([self.part_controller.plmobject_ptr], list(objects.object_list))
示例#25
0
 def test_revise_one_child_get(self):
     """
     Tests a get request to revise a part which has one child.
     This child must be suggested when the user revises the part.
     """
     child = PartController.create("RefChild", "Part", "a", self.user,
                                   self.DATA)
     self.controller.add_child(child, 10, 25, "-")
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["children_formset"]
     self.assertEqual(1, formset.total_form_count())
     form = formset.forms[0]
     self.assertTrue(form.fields["selected"].initial)
     self.assertEqual(child.id, form.initial["link"].child_id)
示例#26
0
文件: partdoc.py 项目: smewp/openPLM
    def setUp(self):
        super(PartDocControllerTestCase, self).setUp()
        self.other_owner = self.get_contributor("Otherowner")
        self.other_owner.groups.add(self.group)
        self.other_owner.save()

        lcl = LifecycleList("dpop", "official", "draft", "proposed", "official", "deprecated")
        lc = models.Lifecycle.from_lifecyclelist(lcl)
        self.states = dict((s, models.State.objects.get(name=s)) for s in lcl)
        self.states["cancelled"] = models.get_cancelled_state()
        self.lifecycles = dict.fromkeys(lcl, lc)
        self.lifecycles["cancelled"] = models.get_cancelled_lifecycle()
        data = self.DATA.copy()
        data["lifecycle"] = lc
        self.part = PartController.create("p1", "Part", "a", self.user, data, True, True)
        self.doc = DocumentController.create("d1", "Document", "a", self.user, data, True, True)
示例#27
0
文件: navigate.py 项目: amarh/openPLM
 def test_navigate_documents2(self):
     """
     Tests a navigate with the "doc" and "child" options set, both
     parts are attached to the same document.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     child1 = PartController.create("c1", "Part", "k",
             self.user, data, True, True)
     self.controller.add_child(child1, 4, 8, "m")
     doc = DocumentController.create("doc", "Document", "d",
             self.user, data, True, True)
     self.controller.attach_to_document(doc)
     child1.attach_to_document(doc)
     for osr, results in ((False, ()), (True, (doc.object, child1.object))):
         self.get_graph_data({"doc" : True, "child" : True})
         self.assertCount(3, 3)
示例#28
0
 def test_navigate_documents2(self):
     """
     Tests a navigate with the "doc" and "child" options set, both
     parts are attached to the same document.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     child1 = PartController.create("c1", "Part", "k", self.user, data,
                                    True, True)
     self.controller.add_child(child1, 4, 8, "m")
     doc = DocumentController.create("doc", "Document", "d", self.user,
                                     data, True, True)
     self.controller.attach_to_document(doc)
     child1.attach_to_document(doc)
     for osr, results in ((False, ()), (True, (doc.object, child1.object))):
         self.get_graph_data({"doc": True, "child": True})
         self.assertCount(3, 3)
示例#29
0
文件: part.py 项目: amarh/openPLM
 def test_revise_one_revised_parent_get(self):
     """
     Tests a get request to revise a part which has one parent which has been
     revised.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user, self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     parent2 = parent.revise("the game")
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["parents_formset"]
     self.assertEqual(1, formset.total_form_count())
     form = formset.forms[0]
     self.assertFalse(form.fields["selected"].initial)
     self.assertEqual(parent2.id, form.initial["link"].parent_id)
     self.assertEqual(parent2.id, form.initial["new_parent"].id)
示例#30
0
 def test_revise_one_revised_parent_get(self):
     """
     Tests a get request to revise a part which has one parent which has been
     revised.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user,
                                    self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     parent2 = parent.revise("the game")
     response = self.get(self.base_url + "revisions/")
     # checks that it is necessary to confirm the revision
     self.assertTrue(response.context["confirmation"])
     formset = response.context["parents_formset"]
     self.assertEqual(1, formset.total_form_count())
     form = formset.forms[0]
     self.assertFalse(form.fields["selected"].initial)
     self.assertEqual(parent2.id, form.initial["link"].parent_id)
     self.assertEqual(parent2.id, form.initial["new_parent"].id)
示例#31
0
文件: navigate.py 项目: amarh/openPLM
 def test_navigate_part(self):
     """
     Tests a navigate with the "doc" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     part = PartController.create("part", "Part", "d",
             self.user, data, True, True)
     self.controller.attach_to_part(part)
     for osr, results in ((False, ()), (True, (part.object,))):
         self.get_graph_data({"part" : True, OSR: osr}, results)
         self.assertCount(2, 1)
         main, part_node = self.nodes
         text = part_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     for result in (self.cie, self.group, self.user, self.controller.object):
         self.get_graph_data({"part" : True, OSR : True }, (result,))
         self.assertCount(1, 0)
示例#32
0
    def setUp(self):
        super(PartDocControllerTestCase, self).setUp()
        self.other_owner = self.get_contributor("Otherowner")
        self.other_owner.groups.add(self.group)
        self.other_owner.save()

        lcl = LifecycleList("dpop", "official", "draft", "proposed",
                            "official", "deprecated")
        lc = models.Lifecycle.from_lifecyclelist(lcl)
        self.states = dict((s, models.State.objects.get(name=s)) for s in lcl)
        self.states["cancelled"] = models.get_cancelled_state()
        self.lifecycles = dict.fromkeys(lcl, lc)
        self.lifecycles["cancelled"] = models.get_cancelled_lifecycle()
        data = self.DATA.copy()
        data["lifecycle"] = lc
        self.part = PartController.create("p1", "Part", "a", self.user, data,
                                          True, True)
        self.doc = DocumentController.create("d1", "Document", "a", self.user,
                                             data, True, True)
示例#33
0
 def test_select_pdf_chidlren_part_pdf(self):
     child = PartController.create("Child", "Part", "f",
             self.user, self.DATA, True, True)
     self.doc.attach_to_part(child)
     self.controller.add_child(child, 1, 1, 'm')
     df = self.doc.add_file(self.get_file("hello.pdf", data=PDF))
     prefix = "pdf_%d_%d" % (self.controller.get_children()[0].link.id,
             self.doc.id)
     data = {
             "Download" : "download",
             prefix + '-TOTAL_FORMS': '1',
             prefix + '-INITIAL_FORMS': '1',
             prefix + '-0-id' : df.id,
             prefix + '-0-document' : self.doc.id,
             prefix + '-0-selected' : 'on',
             }
     response = self.client.get(self.base_url + "pdf/", data=data)
     content = self.check_pdf(response, 2)
     self.assertTrue("world" in content)
示例#34
0
 def test_navigate_part(self):
     """
     Tests a navigate with the "doc" option set.
     """
     data = self.DATA.copy()
     data["name"] = "Coffee"
     part = PartController.create("part", "Part", "d", self.user, data,
                                  True, True)
     self.controller.attach_to_part(part)
     for osr, results in ((False, ()), (True, (part.object, ))):
         self.get_graph_data({"part": True, OSR: osr}, results)
         self.assertCount(2, 1)
         main, part_node = self.nodes
         text = part_node.text_content().strip()
         self.assertTrue(data["name"] in text)
     for result in (self.cie, self.group, self.user,
                    self.controller.object):
         self.get_graph_data({"part": True, OSR: True}, (result, ))
         self.assertCount(1, 0)
示例#35
0
 def _add_part(self, doc, name):
     data = {
         "lifecycle": self.controller.lifecycle,
         "group": self.controller.group,
         "name": name,
     }
     ref = get_new_reference(self.controller._user, Part,
                             len(self.created_parts), self._inbulk_cache)
     part = PartController.create(ref, "Part", "a", self.controller._user, data,
             not self._send_mails, True)
     self._parts[name] = part
     self._parts[part.id] = part
     doc.attach_to_part(part)
     doc.object.PartDecompose = part.object
     doc.object.save()
     self.created_parts.append(part)
     if self._send_mails:
         part.block_mails()
     return part
示例#36
0
 def test_plmobjects(self):
     response = self.get(self.group_url + "objects/", page="objects")
     objects = response.context["objects"]
     self.assertEqual([self.part_controller.plmobject_ptr],
                      list(objects.object_list))
     # create a new group
     group = m.GroupInfo(name="grp2",
                         owner=self.user,
                         creator=self.user,
                         description="grp")
     group.save()
     self.user.groups.add(group)
     # create another part which bellows to another group
     p2 = PartController.create("Part2", "Part", "a", self.user,
                                dict(group=group))
     response = self.get(self.group_url + "objects/", page="objects")
     objects = response.context["objects"]
     self.assertEqual([self.part_controller.plmobject_ptr],
                      list(objects.object_list))
示例#37
0
    def test_children_last_level(self):
        """
        Tests the children view, shows only the last level.

        self
         -> c1
             -> c4
                 -> c6
             -> c5
         -> c2
         -> c3
             -> c7
             -> c8

        last level: (c4 -> c6), (c1 -> c5), (self -> c2), (c3 -> c7), (c3 -> c8)
        """
        child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
        ls1 = self.controller.add_child(child1, 10, 20)
        child2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
        ls2 = self.controller.add_child(child2, 10, 21)
        child3 = PartController.create("c3", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child3, 10, 22)
        child4 = PartController.create("c4", "Part", "a", self.user, self.DATA)
        l14 = child1.add_child(child4, 10, 23)
        child5 = PartController.create("c5", "Part", "a", self.user, self.DATA)
        l15 = child1.add_child(child5, 10, 24)
        child6 = PartController.create("c6", "Part", "a", self.user, self.DATA)
        l46 = child4.add_child(child6, 10, 25)
        child7 = PartController.create("c7", "Part", "a", self.user, self.DATA)
        l37 = child3.add_child(child7, 10, 26)
        child8 = PartController.create("c8", "Part", "a", self.user, self.DATA)
        l38 = child3.add_child(child8, 10, 27)
        response = self.get(self.base_url + "BOM-child/", {
            "level": "last",
            "state": "all"
        },
                            page="BOM-child")
        children = response.context["children"]
        self.assertEqual(5, len(children))
        self.assertEqual([l46, l15, ls2, l37, l38], [c.link for c in children])
示例#38
0
文件: part.py 项目: amarh/openPLM
    def test_children_last_level(self):
        """
        Tests the children view, shows only the last level.

        self
         -> c1
             -> c4
                 -> c6
             -> c5
         -> c2
         -> c3
             -> c7
             -> c8

        last level: (c4 -> c6), (c1 -> c5), (self -> c2), (c3 -> c7), (c3 -> c8)
        """
        child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
        ls1 = self.controller.add_child(child1, 10 , 20)
        child2 = PartController.create("c2", "Part", "a", self.user, self.DATA)
        ls2 = self.controller.add_child(child2, 10, 21)
        child3 = PartController.create("c3", "Part", "a", self.user, self.DATA)
        self.controller.add_child(child3, 10, 22)
        child4 = PartController.create("c4", "Part", "a", self.user, self.DATA)
        l14 = child1.add_child(child4, 10, 23)
        child5 = PartController.create("c5", "Part", "a", self.user, self.DATA)
        l15 = child1.add_child(child5, 10, 24)
        child6 = PartController.create("c6", "Part", "a", self.user, self.DATA)
        l46 = child4.add_child(child6, 10, 25)
        child7 = PartController.create("c7", "Part", "a", self.user, self.DATA)
        l37 = child3.add_child(child7, 10, 26)
        child8 = PartController.create("c8", "Part", "a", self.user, self.DATA)
        l38 = child3.add_child(child8, 10, 27)
        response = self.get(self.base_url + "BOM-child/",
                {"level":"last", "state" : "all"},
                page="BOM-child")
        children = response.context["children"]
        self.assertEqual(5, len(children))
        self.assertEqual([l46, l15, ls2, l37, l38], [c.link for c in children])
示例#39
0
文件: views.py 项目: esimorre/openplm
 def test_edit_children(self):
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child1, 10, 20)
     response = self.get(self.base_url + "BOM-child/edit/")
     formset = response.context["children_formset"]
     data = {
         "form-TOTAL_FORMS": u"1",
         "form-INITIAL_FORMS": u"1",
         "form-MAX_NUM_FORMS": u"",
         "form-0-child": child1.id,
         "form-0-id": self.controller.get_children()[0].link.id,
         "form-0-order": 45,
         "form-0-parent": self.controller.id,
         "form-0-quantity": "45.0",
         "form-0-unit": "cm",
     }
     response = self.post(self.base_url + "BOM-child/edit/", data)
     link = self.controller.get_children()[0].link
     self.assertEquals(45, link.order)
     self.assertEquals(45.0, link.quantity)
     self.assertEquals("cm", link.unit)
示例#40
0
文件: part.py 项目: amarh/openPLM
 def test_edit_children(self):
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child1, 10 , 20)
     response = self.get(self.base_url + "BOM-child/edit/")
     formset = response.context["children_formset"]
     data = {
         'form-TOTAL_FORMS': u'1',
         'form-INITIAL_FORMS': u'1',
         'form-MAX_NUM_FORMS': u'',
         'form-0-child' :   child1.id,
         'form-0-id'  : self.controller.get_children()[0].link.id,
         'form-0-order'  :  45,
         'form-0-parent' :  self.controller.id,
         'form-0-quantity' :  '45.0',
         'form-0-unit' :  'cm',
     }
     response = self.post(self.base_url + "BOM-child/edit/", data)
     link = self.controller.get_children()[0].link
     self.assertEquals(45, link.order)
     self.assertEquals(45.0, link.quantity)
     self.assertEquals('cm', link.unit)
示例#41
0
 def test_edit_children(self):
     child1 = PartController.create("c1", "Part", "a", self.user, self.DATA)
     self.controller.add_child(child1, 10, 20)
     response = self.get(self.base_url + "BOM-child/edit/")
     formset = response.context["children_formset"]
     data = {
         'form-TOTAL_FORMS': u'1',
         'form-INITIAL_FORMS': u'1',
         'form-MAX_NUM_FORMS': u'',
         'form-0-child': child1.id,
         'form-0-id': self.controller.get_children()[0].link.id,
         'form-0-order': 45,
         'form-0-parent': self.controller.id,
         'form-0-quantity': '45.0',
         'form-0-unit': 'cm',
     }
     response = self.post(self.base_url + "BOM-child/edit/", data)
     link = self.controller.get_children()[0].link
     self.assertEquals(45, link.order)
     self.assertEquals(45.0, link.quantity)
     self.assertEquals('cm', link.unit)
示例#42
0
 def test_revise_one_parent_post_selected(self):
     """
     Tests a post request to revise a part which has one parent.
     This parent is selected, and so its bom must be updated.
     """
     parent = PartController.create("RefParent", "Part", "a", self.user,
                                    self.DATA)
     parent.add_child(self.controller, 10, 25, "-")
     link = parent.get_children(1)[0].link
     data = {
         "revision": "b",
         "parents-TOTAL_FORMS": "1",
         "parents-INITIAL_FORMS": "1",
         "parents-0-selected": "on",
         "parents-0-link": link.id,
         "parents-0-new_parent": parent.id,
         "children-TOTAL_FORMS": "0",
         "children-INITIAL_FORMS": "0",
         "documents-TOTAL_FORMS": "0",
         "documents-INITIAL_FORMS": "0",
     }
     response = self.post(self.base_url + "revisions/", data)
     revisions = self.controller.get_next_revisions()
     self.assertEqual(1, len(revisions))
     rev = revisions[0].part
     self.assertEqual("b", rev.revision)
     # ensure the old revision is still a child of the parent
     children = parent.get_children(1)
     self.assertNotEqual([(1, link)], children)
     self.assertEqual(1, len(children))
     level, link2 = children[0]
     self.assertEqual(parent.id, link2.parent_id)
     self.assertEqual(link.order, link2.order)
     self.assertEqual(link.quantity, link2.quantity)
     self.assertEqual(link.unit, link2.unit)
     self.assertEqual(rev.id, link2.child_id)
     self.assertFalse(self.controller.get_parents())
示例#43
0
文件: views.py 项目: esimorre/openplm
    def test_related_parts_get(self):
        part = PartController.create("RefPart", "Part", "a", self.user, self.DATA)
        self.controller.attach_to_part(part)

        response = self.get(self.base_url + "parts/", page="parts")
        self.assertEqual([part.id], [p.part.id for p in response.context["object_rel_part"]])
示例#44
0
文件: views.py 项目: esimorre/openplm
 def test_add_related_part_post(self):
     part = PartController.create("RefPart", "Part", "a", self.user, self.DATA)
     data = {"reference": part.reference, "type": part.type, "revision": part.revision}
     response = self.post(self.base_url + "parts/add/", data)
     self.assertEqual([part.id], [p.part.id for p in self.controller.get_attached_parts()])
示例#45
0
    def test_update_add_existing_rod(self):
        rod = self.create("rod", "Document3D")
        rod.name = "ROD"
        rod.save()
        rod_step = rod.add_file(get_steps("rod.step")[0])
        rod_native = rod.add_file(get_natives("ROD.native")[0])
        rod_part = PartController.create("rod", "Part", "a", self.user, {
            "group": self.group,
            "lifecycle": rod.lifecycle,
            "name": rod.name
        })
        rod.attach_to_part(rod_part)
        rod.PartDecompose = rod_part.object
        rod.save()

        ctrl = self.create("d1", "Document3D")
        natives = get_natives("test.native_asm", "NBA_ASM.native_asm",
                              "NUT.native", "BOLT.native", "L-BRACKET.native",
                              "ROD.native")
        steps = get_steps("bolt.step", "l-bracket.step", "nut.step",
                          "rod.step")
        builder = AssemblyBuilder(ctrl)
        builder.build_assembly(_ASSEMBLY1, natives, steps, False)

        tree = copy.deepcopy(_UPDATED_ASSEMBLY1)
        tree["children"].append({
            u'children': [],
            u'local_matrix':
            [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0],
            u'local_name':
            u'ROD',
            u'native': {
                "id": rod_native.id
            },
            u'part': {
                "id": rod_part.id
            },
            u'document': {
                "id": rod.id,
                "checkin": True
            },
            u'step': {
                "id": rod_step.id
            },
        })
        natives = get_natives("test.native_asm", "NBA_ASM.native_asm",
                              "NUT.native", "BOLT.native", "L-BRACKET.native",
                              "ROD.native")
        steps = get_steps("bolt.step", "l-bracket.step", "nut.step",
                          "rod.step")
        builder = AssemblyBuilder(ctrl)
        builder.update_assembly(tree, natives, steps)
        self.assertEqual(6, models.Part.objects.all().count())
        self.assertEqual(6, models.Document.objects.all().count())
        # root
        root = PartController(ctrl.PartDecompose, self.user)
        self.assertDoc(root.object, "test.step", "test.native_asm")
        self.assertEqual("test", root.name)
        children = root.get_children(-1)
        self.assertEqual(5, len(children))
        # l-bracket
        pcl = children[0].link
        child = pcl.child
        self.assertLink(pcl, "L-BRACKET", root.object, 1, 1)
        self.assertDoc(child, u"l-bracket.step", u"L-BRACKET.native")
        # nba_asm
        pcl = children[1].link
        child = nba_asm = pcl.child
        self.assertLink(pcl, "NBA_ASM", root.object, 2, 3)
        self.assertDoc(child, u"NBA_ASM.step", u"NBA_ASM.native_asm")
        # bolt
        pcl = children[2].link
        child = pcl.child
        self.assertLink(pcl, "BOLT", nba_asm, 1, 2)
        self.assertDoc(child, u"bolt.step", u"BOLT.native")
        # nut
        pcl = children[3].link
        child = pcl.child
        self.assertLink(pcl, "NUT", nba_asm, 2, 1)
        self.assertDoc(child, u"nut.step", u"NUT.native")
        # rod
        pcl = children[4].link
        child = pcl.child
        self.assertEqual(child.id, rod_part.id)
        self.assertLink(pcl, "ROD", root.object, 3, 1)
        self.assertDoc(child, u"rod.step", u"ROD.native")

        # minor revisions of document files
        for doc in models.Document.objects.all():
            for f in doc.files:
                self.assertEqual(2, f.revision)
        # check product is valid
        self.assertProduct(ctrl)
示例#46
0
文件: assembly.py 项目: amarh/openPLM
    def test_update_add_existing_rod(self):
        rod = self.create("rod", "Document3D")
        rod.name = "ROD"
        rod.save()
        rod_step = rod.add_file(get_steps("rod.step")[0])
        rod_native = rod.add_file(get_natives("ROD.native")[0])
        rod_part = PartController.create("rod", "Part", "a", self.user,
            {"group": self.group, "lifecycle": rod.lifecycle, "name": rod.name})
        rod.attach_to_part(rod_part)
        rod.PartDecompose = rod_part.object
        rod.save()

        ctrl = self.create("d1", "Document3D")
        natives = get_natives("test.native_asm", "NBA_ASM.native_asm",
                "NUT.native", "BOLT.native", "L-BRACKET.native", "ROD.native")
        steps = get_steps("bolt.step", "l-bracket.step", "nut.step", "rod.step")
        builder = AssemblyBuilder(ctrl)
        builder.build_assembly(_ASSEMBLY1, natives, steps, False)

        tree = copy.deepcopy(_UPDATED_ASSEMBLY1)
        tree["children"].append(
            {
                u'children': [],
                u'local_matrix': [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0],
                u'local_name': u'ROD',
                u'native': {"id": rod_native.id},
                u'part': {"id": rod_part.id},
                u'document': {"id": rod.id, "checkin": True},
                u'step': {"id": rod_step.id},
            }
        )
        natives = get_natives("test.native_asm", "NBA_ASM.native_asm",
                "NUT.native", "BOLT.native", "L-BRACKET.native", "ROD.native")
        steps = get_steps("bolt.step", "l-bracket.step", "nut.step", "rod.step")
        builder = AssemblyBuilder(ctrl)
        builder.update_assembly(tree, natives, steps)
        self.assertEqual(6, models.Part.objects.all().count())
        self.assertEqual(6, models.Document.objects.all().count())
        # root
        root = PartController(ctrl.PartDecompose, self.user)
        self.assertDoc(root.object, "test.step", "test.native_asm")
        self.assertEqual("test", root.name)
        children = root.get_children(-1)
        self.assertEqual(5, len(children))
        # l-bracket
        pcl = children[0].link
        child = pcl.child
        self.assertLink(pcl, "L-BRACKET", root.object, 1, 1)
        self.assertDoc(child, u"l-bracket.step", u"L-BRACKET.native")
        # nba_asm
        pcl = children[1].link
        child = nba_asm = pcl.child
        self.assertLink(pcl, "NBA_ASM", root.object, 2, 3)
        self.assertDoc(child, u"NBA_ASM.step", u"NBA_ASM.native_asm")
        # bolt
        pcl = children[2].link
        child = pcl.child
        self.assertLink(pcl, "BOLT", nba_asm, 1, 2)
        self.assertDoc(child, u"bolt.step", u"BOLT.native")
        # nut
        pcl = children[3].link
        child = pcl.child
        self.assertLink(pcl, "NUT", nba_asm, 2, 1)
        self.assertDoc(child, u"nut.step", u"NUT.native")
        # rod
        pcl = children[4].link
        child = pcl.child
        self.assertEqual(child.id, rod_part.id)
        self.assertLink(pcl, "ROD", root.object, 3, 1)
        self.assertDoc(child, u"rod.step", u"ROD.native")

        # minor revisions of document files
        for doc in models.Document.objects.all():
            for f in doc.files:
                self.assertEqual(2, f.revision)
        # check product is valid
        self.assertProduct(ctrl)
示例#47
0
文件: document.py 项目: amarh/openPLM
 def get_part(self):
     return PartController.create("mpart", "Part", "a", self.user,
             self.DATA, True, True)
示例#48
0
 def get_part(self):
     return PartController.create("mpart", "Part", "a", self.user,
                                  self.DATA, True, True)
示例#49
0
 def get_part(self, ref="P1"):
     return PartController.create(ref, "Part", "a", self.user, self.DATA,
                                  True, True)
示例#50
0
文件: document.py 项目: amarh/openPLM
 def get_part(self, ref="P1"):
     return PartController.create(ref, "Part", "a", self.user,
            self.DATA, True, True)