示例#1
0
 def setUp(self):
     self.divisions = Division.create_batch(3)
     self.template = factories.Template.create(
         divisions=self.divisions)
示例#2
0
    def setUp(self):
        """
        Creating 2 additional templates:
            1. template_1 which inherits base template
            2. templtae_2 which inherits template_1

        Creating 3 additional, dangling nodes on template_1 and 2 on template_2.
        """

        # create required divisions and entities
        self.division = Division.create()
        self.entities = Entity.create_batch(5, division=self.division)

        # create the blueprint template, and two templates for use by sheets
        self.tmpl_blueprint = factories.Template.create(divisions=[self.division])
        self.tmpl_one = factories.Template.create(blueprint=self.tmpl_blueprint)
        self.tmpl_two = factories.Template.create(blueprint=self.tmpl_blueprint)

        # create the blueprint nodes, and assign them to the blueprint and the
        # "inheriting" templates
        self.rev_nodes = factories.TemplateNode.create_batch(5)

        for node in self.rev_nodes:
            factories.TemplateNodeRelation(node=node, template=self.tmpl_blueprint)
            factories.TemplateNodeRelation(node=node, template=self.tmpl_one)
            factories.TemplateNodeRelation(node=node, template=self.tmpl_two)

        self.rev_nodes[1].parent = self.rev_nodes[0]
        self.rev_nodes[2].parent = self.rev_nodes[0]
        self.rev_nodes[3].parent = self.rev_nodes[1]
        self.rev_nodes[4].parent = self.rev_nodes[2]

        for node in self.rev_nodes:
            node.save()

        self.exp_nodes = factories.TemplateNode.create_batch(5, direction="EXPENDITURE")

        for node in self.exp_nodes:
            factories.TemplateNodeRelation(node=node, template=self.tmpl_blueprint)
            factories.TemplateNodeRelation(node=node, template=self.tmpl_one)
            factories.TemplateNodeRelation(node=node, template=self.tmpl_two)

        self.exp_nodes[1].parent = self.exp_nodes[0]
        self.exp_nodes[2].parent = self.exp_nodes[0]
        self.exp_nodes[3].parent = self.exp_nodes[1]
        self.exp_nodes[4].parent = self.exp_nodes[2]

        for node in self.exp_nodes:
            node.save()

        # some additional nodes for template 1
        self.tmpl_one_extra_nodes = factories.TemplateNode.create_batch(2)

        for node in self.tmpl_one_extra_nodes:
            factories.TemplateNodeRelation(node=node, template=self.tmpl_one)

        self.tmpl_one_extra_nodes[0].direction = "EXPENDITURE"
        self.tmpl_one_extra_nodes[0].parent = self.exp_nodes[4]
        self.tmpl_one_extra_nodes[0].parent = self.rev_nodes[3]

        for node in self.tmpl_one_extra_nodes:
            node.save()

        # some additional nodes for template 2
        self.tmpl_two_extra_nodes = factories.TemplateNode.create_batch(2)

        for node in self.tmpl_two_extra_nodes:
            factories.TemplateNodeRelation(node=node, template=self.tmpl_two)

        self.tmpl_two_extra_nodes[0].direction = "EXPENDITURE"
        self.tmpl_two_extra_nodes[0].parent = self.exp_nodes[1]
        self.tmpl_two_extra_nodes[0].parent = self.rev_nodes[0]

        for node in self.tmpl_two_extra_nodes:
            node.save()

        # some nodes from template 1 also shared by template 2
        factories.TemplateNodeRelation(node=self.tmpl_one_extra_nodes[0], template=self.tmpl_two)