def test_domain(self): # this one does NOT belong to a domain Counter.increment(name='foo') Counter.increment(name='foo', domain='zzz') Counter.increment(name='foo', domain='zzz') # this one is in the same domain as previous counter Counter.increment(name='bar', domain='zzz') counter1 = Counter.get_or_create(name='foo') counter2 = Counter.get_or_create(name='foo', domain='zzz') self.assertNotEqual(counter1.count, counter2.count) counters = Counter.query(Counter.domain == 'zzz').fetch() self.assertEqual(2, len(counters))
def test_increment_existing(self): Counter.increment(name='foo') Counter.increment(name='foo') self.assertEqual(1, len(Counter.query().fetch())) counter = Counter.get_or_create(name='foo') self.assertEqual(2, counter.count)