def test_counters(self):
        cool = Dog()
        cool.name = "Cool"
        cool.save()
        self.assertMetricEquals(1, M("inserts_total"), model="dog")

        elysees = Lawn()
        elysees.location = "Champs Elysees, Paris"
        elysees.save()
        self.assertMetricEquals(1, M("inserts_total"), model="lawn")
        self.assertMetricEquals(1, M("inserts_total"), model="dog")

        galli = Dog()
        galli.name = "Galli"
        galli.save()
        self.assertMetricEquals(2, M("inserts_total"), model="dog")

        cool.breed = "Wolfhound"
        self.assertMetricEquals(2, M("inserts_total"), model="dog")

        cool.save()
        self.assertMetricEquals(2, M("inserts_total"), model="dog")
        self.assertMetricEquals(1, M("updates_total"), model="dog")

        cool.age = 9
        cool.save()
        self.assertMetricEquals(2, M("updates_total"), model="dog")

        cool.delete()  # :(
        self.assertMetricEquals(2, M("inserts_total"), model="dog")
        self.assertMetricEquals(2, M("updates_total"), model="dog")
        self.assertMetricEquals(1, M("deletes_total"), model="dog")
    def test_counters(self):
        r = self.saveRegistry()
        cool = Dog()
        cool.name = 'Cool'
        cool.save()
        self.assertMetricDiff(
            r, 1, M('inserts_total'), model='dog')

        elysees = Lawn()
        elysees.location = 'Champs Elysees, Paris'
        elysees.save()
        self.assertMetricDiff(
            r, 1, M('inserts_total'), model='lawn')
        self.assertMetricDiff(
            r, 1, M('inserts_total'), model='dog')

        galli = Dog()
        galli.name = 'Galli'
        galli.save()
        self.assertMetricDiff(
            r, 2, M('inserts_total'), model='dog')

        cool.breed = 'Wolfhound'
        self.assertMetricDiff(
            r, 2, M('inserts_total'), model='dog')

        cool.save()
        self.assertMetricDiff(
            r, 2, M('inserts_total'), model='dog')
        self.assertMetricDiff(
            r, 1, M('updates_total'), model='dog')

        cool.age = 9
        cool.save()
        self.assertMetricDiff(
            r, 2, M('updates_total'), model='dog')

        cool.delete()  # :(
        self.assertMetricDiff(
            r, 2, M('inserts_total'), model='dog')
        self.assertMetricDiff(
            r, 2, M('updates_total'), model='dog')
        self.assertMetricDiff(
            r, 1, M('deletes_total'), model='dog')
    def test_counters(self):
        r = self.saveRegistry()
        cool = Dog()
        cool.name = "Cool"
        cool.save()
        self.assertMetricDiff(r, 1, M("inserts_total"), model="dog")

        elysees = Lawn()
        elysees.location = "Champs Elysees, Paris"
        elysees.save()
        self.assertMetricDiff(r, 1, M("inserts_total"), model="lawn")
        self.assertMetricDiff(r, 1, M("inserts_total"), model="dog")

        galli = Dog()
        galli.name = "Galli"
        galli.save()
        self.assertMetricDiff(r, 2, M("inserts_total"), model="dog")

        cool.breed = "Wolfhound"
        self.assertMetricDiff(r, 2, M("inserts_total"), model="dog")

        cool.save()
        self.assertMetricDiff(r, 2, M("inserts_total"), model="dog")
        self.assertMetricDiff(r, 1, M("updates_total"), model="dog")

        cool.age = 9
        cool.save()
        self.assertMetricDiff(r, 2, M("updates_total"), model="dog")

        cool.delete()  # :(
        self.assertMetricDiff(r, 2, M("inserts_total"), model="dog")
        self.assertMetricDiff(r, 2, M("updates_total"), model="dog")
        self.assertMetricDiff(r, 1, M("deletes_total"), model="dog")
    def test_counters(self):
        cool = Dog()
        cool.name = 'Cool'
        cool.save()
        self.assertMetricEquals(
            1, M('inserts_total'), model='dog')

        elysees = Lawn()
        elysees.location = 'Champs Elysees, Paris'
        elysees.save()
        self.assertMetricEquals(
            1, M('inserts_total'), model='lawn')
        self.assertMetricEquals(
            1, M('inserts_total'), model='dog')

        galli = Dog()
        galli.name = 'Galli'
        galli.save()
        self.assertMetricEquals(
            2, M('inserts_total'), model='dog')

        cool.breed = 'Wolfhound'
        self.assertMetricEquals(
            2, M('inserts_total'), model='dog')

        cool.save()
        self.assertMetricEquals(
            2, M('inserts_total'), model='dog')
        self.assertMetricEquals(
            1, M('updates_total'), model='dog')

        cool.age = 9
        cool.save()
        self.assertMetricEquals(
            2, M('updates_total'), model='dog')

        cool.delete()  # :(
        self.assertMetricEquals(
            2, M('inserts_total'), model='dog')
        self.assertMetricEquals(
            2, M('updates_total'), model='dog')
        self.assertMetricEquals(
            1, M('deletes_total'), model='dog')