当前位置: 首页>>代码示例>>Python>>正文


Python Tree.audits方法代码示例

本文整理汇总了Python中treemap.models.Tree.audits方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.audits方法的具体用法?Python Tree.audits怎么用?Python Tree.audits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在treemap.models.Tree的用法示例。


在下文中一共展示了Tree.audits方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_lots_of_trees_and_plots

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import audits [as 别名]
    def test_lots_of_trees_and_plots(self):
        """
        Make 3 plots: 2 pending and 1 approved
        Make 4 trees: 1 on each pending plot, 2 on approved plot
        Approve one pending plot.
        Approve all trees. The one on the (Still) pending plot
        should fail. all else should pass.
        """
        p1 = Point(0, 0)
        p2 = Point(1, 1)
        p3 = Point(2, 2)
        plot1 = Plot(geom=p1, instance=self.instance)
        plot2 = Plot(geom=p2, instance=self.instance)
        plot3 = Plot(geom=p3, instance=self.instance)
        plot1.save_with_user(self.commander_user)
        plot2.save_with_user(self.pending_user)
        plot3.save_with_user(self.pending_user)
        tree1 = Tree(plot=plot1, instance=self.instance)
        tree1.save_with_user(self.pending_user)
        tree2 = Tree(plot=plot1, instance=self.instance)
        tree2.save_with_user(self.pending_user)
        tree3 = Tree(plot=plot2, instance=self.instance)
        tree3.save_with_user(self.pending_user)
        tree4 = Tree(plot=plot3, instance=self.instance)
        tree4.save_with_user(self.pending_user)

        approve_or_reject_audits_and_apply(
            plot2.audits(),
            self.commander_user, True)

        approve_or_reject_audits_and_apply(
            tree1.audits(),
            self.commander_user, True)

        approve_or_reject_audits_and_apply(
            tree2.audits(),
            self.commander_user, True)

        approve_or_reject_audits_and_apply(
            tree3.audits(),
            self.commander_user, True)

        self.assertRaises(ObjectDoesNotExist, Plot.objects.get, pk=plot3.pk)
        self.assertRaises(ObjectDoesNotExist,
                          approve_or_reject_audits_and_apply,
                          tree4.audits(),
                          self.commander_user, True)
开发者ID:mmcfarland,项目名称:OTM2,代码行数:49,代码来源:audit.py

示例2: test_basic_audit

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import audits [as 别名]
    def test_basic_audit(self):
        p = Point(-8515222.0, 4953200.0)
        plot = Plot(geom=p, instance=self.instance)
        plot.save_with_user(self.user1)

        self.assertAuditsEqual([
            self.make_audit(plot.pk, 'id', None, str(plot.pk), model='Plot'),
            self.make_audit(plot.pk, 'readonly', None, 'False',
                            model='Plot'),
            self.make_audit(plot.pk, 'geom', None, str(plot.geom),
                            model='Plot')], plot.audits())

        t = Tree(plot=plot, instance=self.instance, readonly=True)

        t.save_with_user(self.user1)

        expected_audits = [
            self.make_audit(t.pk, 'id', None, str(t.pk)),
            self.make_audit(t.pk, 'readonly', None, True),
            self.make_audit(t.pk, 'plot', None, plot.pk)]

        self.assertAuditsEqual(expected_audits, t.audits())

        t.readonly = False
        t.save_with_user(self.user2)

        expected_audits.insert(
            0, self.make_audit(t.pk, 'readonly', 'True', 'False',
                               action=Audit.Type.Update, user=self.user2))

        self.assertAuditsEqual(expected_audits, t.audits())

        old_pk = t.pk
        t.delete_with_user(self.user1)

        expected_audits.insert(
            0, self.make_audit(old_pk, None, None, None,
                               action=Audit.Type.Delete, user=self.user1))

        self.assertAuditsEqual(
            expected_audits,
            Audit.audits_for_model('Tree', self.instance, old_pk))
开发者ID:mmcfarland,项目名称:OTM2,代码行数:44,代码来源:audit.py

示例3: AuditDetailTagTest

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import audits [as 别名]
class AuditDetailTagTest(OTMTestCase):

    def setUp(self):
        self.p1 = Point(-8515222.0, 4953200.0)

        self.instance = make_instance(point=self.p1)
        self.user = make_commander_user(self.instance)

        self.plot = Plot(geom=self.p1, instance=self.instance)
        self.plot.save_with_user(self.user)

        self.tree = Tree(
            plot=self.plot, instance=self.instance, readonly=False)
        self.tree.save_with_user(self.user)

    def test_tree_link(self):
        audit = self.tree.audits()[0]
        link = audit_detail_link(audit)

        target = reverse('tree_detail',
                         kwargs={'instance_url_name': self.instance.url_name,
                                 'feature_id': self.tree.plot.pk,
                                 'tree_id': self.tree.pk})

        self.assertEqual(link, target)

    def test_plot_link(self):
        audit = self.plot.audits()[0]
        link = audit_detail_link(audit)

        target = reverse('map_feature_detail',
                         kwargs={'instance_url_name': self.instance.url_name,
                                 'feature_id': self.plot.pk})

        self.assertEqual(link, target)

    def test_bad_model_returns_none(self):
        audit = self.plot.audits()[0]
        audit.model = 'invaild'

        self.assertIsNone(audit_detail_link(audit))

    def test_bad_id_returns_none(self):
        audit = self.plot.audits()[0]
        audit.model_id = -1000

        self.assertIsNone(audit_detail_link(audit))
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:49,代码来源:test_audit.py

示例4: test_insert_writes_when_approved

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import audits [as 别名]
    def test_insert_writes_when_approved(self):

        new_plot = Plot(geom=self.p1, instance=self.instance)
        new_plot.save_with_user(self.pending_user)

        new_tree = Tree(plot=new_plot, instance=self.instance)
        new_tree.save_with_user(self.pending_user)

        self.assertEquals(Plot.objects.count(), 0)
        self.assertEquals(Tree.objects.count(), 0)

        approve_or_reject_audits_and_apply(
            list(new_tree.audits()) + list(new_plot.audits()),
            self.commander_user, True)

        self.assertEqual(Plot.objects.all().count(), 1)
        self.assertEqual(Tree.objects.all().count(), 1)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:19,代码来源:test_audit.py


注:本文中的treemap.models.Tree.audits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。