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")
    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')
Beispiel #5
0
def newlawn(request, location):
    """This view creates a new Lawn instance in the database."""
    l = Lawn()
    l.location = location
    l.save()
    return TemplateResponse(request, 'lawn.html', {'lawn': l})
Beispiel #6
0
def newlawn(request, location):
    """This view creates a new Lawn instance in the database."""
    l = Lawn()
    l.location = location
    l.save()
    return TemplateResponse(request, 'lawn.html', {'lawn': l})
Beispiel #7
0
def newlawn(request, location):
    """This view creates a new Lawn instance in the database."""
    lawn = Lawn()
    lawn.location = location
    lawn.save()
    return TemplateResponse(request, "lawn.html", {"lawn": lawn})