當前位置: 首頁>>代碼示例>>Python>>正文


Python audit.ReputationMetric類代碼示例

本文整理匯總了Python中treemap.audit.ReputationMetric的典型用法代碼示例。如果您正苦於以下問題:Python ReputationMetric類的具體用法?Python ReputationMetric怎麽用?Python ReputationMetric使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ReputationMetric類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_reputation_metric_no_adjustment_for_no_rm_record

    def test_reputation_metric_no_adjustment_for_no_rm_record(self):
        audit = Audit(model='Plot', model_id=1,
                      action=Audit.Type.Insert,
                      instance=self.instance, field='readonly',
                      previous_value=None,
                      current_value=True,
                      user=self.privileged_user)

        ReputationMetric.apply_adjustment(audit)

        self.assertEqual(0,
                         self.privileged_user.get_reputation(self.instance))
開發者ID:OpenTreeMap,項目名稱:otm-core,代碼行數:12,代碼來源:test_audit.py

示例2: test_reputation_metric_positive_adjustment_for_rm

    def test_reputation_metric_positive_adjustment_for_rm(self):
        self.assertEqual(0,
                         self.unprivileged_user.get_reputation(self.instance))
        audit = Audit(model='Tree', model_id=1,
                      action=Audit.Type.Insert,
                      instance=self.instance, field='readonly',
                      previous_value=None,
                      current_value=True,
                      user=self.unprivileged_user)

        ReputationMetric.apply_adjustment(audit)

        self.assertEqual(2,
                         self.unprivileged_user.get_reputation(self.instance))
開發者ID:OpenTreeMap,項目名稱:otm-core,代碼行數:14,代碼來源:test_audit.py

示例3: setUp

    def setUp(self):
        self.p1 = Point(-7615441.0, 5953519.0)
        self.instance = make_instance(point=self.p1)

        self.commander = make_commander_user(self.instance)
        self.privileged_user = make_officer_user(self.instance)
        self.unprivileged_user = make_apprentice_user(self.instance)

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

        self.plot.save_with_user(self.commander)

        rm = ReputationMetric(instance=self.instance, model_name='Tree',
                              action=Audit.Type.Insert, direct_write_score=2,
                              approval_score=20, denial_score=5)
        rm.save()
開發者ID:OpenTreeMap,項目名稱:otm-core,代碼行數:16,代碼來源:test_audit.py

示例4: setUp

    def setUp(self):
        self.instance = make_instance(name='Test Instance')

        self.species = Species(instance=self.instance,
                               common_name='Test Common Name',
                               genus='Test Genus',
                               cultivar='Test Cultivar',
                               species='Test Species')
        self.species.save_base()

        self.user = make_user(username='commander', password='pw')

        self.import_event = ImportEvent(imported_by=self.user)
        self.import_event.save_base()

        self.plot = Plot(geom=Point(0, 0), instance=self.instance,
                         address_street="123 Main Street")

        self.plot.save_base()

        self.tree = Tree(plot=self.plot, instance=self.instance)

        self.tree.save_base()

        self.boundary = make_simple_boundary("Test Boundary")

        self.role = make_commander_role(self.instance)
        self.role.name = "Test Role"
        self.role.save()

        self.field_permission = FieldPermission(
            model_name="Tree",
            field_name="readonly",
            permission_level=FieldPermission.READ_ONLY,
            role=self.role,
            instance=self.instance)
        self.field_permission.save_base()

        self.audit = Audit(action=Audit.Type.Update,
                           model="Tree",
                           field="readonly",
                           model_id=1,
                           user=self.user,
                           previous_value=True,
                           current_value=False)
        self.audit.save_base()

        self.reputation_metric = ReputationMetric(instance=self.instance,
                                                  model_name="Tree",
                                                  action="Test Action")
        self.reputation_metric.save_base()
開發者ID:mmcfarland,項目名稱:OTM2,代碼行數:51,代碼來源:models.py

示例5: ModelUnicodeTests

class ModelUnicodeTests(OTMTestCase):

    def setUp(self):
        self.instance = make_instance(name='Test Instance')

        self.species = Species(instance=self.instance,
                               common_name='Test Common Name',
                               genus='Test Genus',
                               cultivar='Test Cultivar',
                               species='Test Species')
        self.species.save_base()

        self.user = make_user(username='commander', password='pw')

        self.plot = Plot(geom=Point(1, 1), instance=self.instance,
                         address_street="123 Main Street")

        self.plot.save_base()

        self.tree = Tree(plot=self.plot, instance=self.instance)

        self.tree.save_base()

        self.boundary = make_simple_boundary("Test Boundary")

        self.role = Role(instance=self.instance, name='Test Role',
                         rep_thresh=2)
        self.role.save()

        self.field_permission = FieldPermission(
            model_name="Tree",
            field_name="readonly",
            permission_level=FieldPermission.READ_ONLY,
            role=self.role,
            instance=self.instance)
        self.field_permission.save_base()

        self.audit = Audit(action=Audit.Type.Update,
                           model="Tree",
                           field="readonly",
                           model_id=1,
                           user=self.user,
                           previous_value=True,
                           current_value=False)
        self.audit.save_base()

        self.reputation_metric = ReputationMetric(instance=self.instance,
                                                  model_name="Tree",
                                                  action="Test Action")
        self.reputation_metric.save_base()

    def test_instance_model(self):
        self.assertEqual(unicode(self.instance), "Test Instance")

    def test_species_model(self):
        self.assertEqual(
            unicode(self.species),
            "Test Common Name [Test Genus Test Species 'Test Cultivar']")

    def test_user_model(self):
        self.assertEqual(unicode(self.user), 'commander')

    def test_plot_model(self):
        self.assertEqual(unicode(self.plot),
                         'Plot (1.0, 1.0) 123 Main Street')

    def test_tree_model(self):
        self.assertEqual(unicode(self.tree), '')

    def test_boundary_model(self):
        self.assertEqual(unicode(self.boundary), 'Test Boundary')

    def test_role_model(self):
        self.assertEqual(unicode(self.role), 'Test Role (%s)' % self.role.pk)

    def test_field_permission_model(self):
        self.assertEqual(unicode(self.field_permission),
                         'Tree.readonly - Test Role (%s) - Read Only'
                         % self.role.pk)

    def test_audit_model(self):
        self.assertEqual(
            unicode(self.audit),
            'pk=%s - action=Update - Tree.readonly:(1) - True => False'
            % self.audit.pk)

    def test_reputation_metric_model(self):
        self.assertEqual(unicode(self.reputation_metric),
                         'Test Instance - Tree - Test Action')
開發者ID:jwalgran,項目名稱:otm-core,代碼行數:89,代碼來源:test_models.py


注:本文中的treemap.audit.ReputationMetric類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。