Permalink
Browse files

ticket10: pep8

  • Loading branch information...
andreysobol committed Mar 11, 2012
1 parent 92a6ef5 commit 996fb38ca2f71e9d4584f94ab7506ea2baecd7c5
Showing with 17 additions and 13 deletions.
  1. +8 −4 testsobol/mainapp/models.py
  2. +9 −9 testsobol/mainapp/tests.py
@@ -19,24 +19,28 @@ class Request(models.Model):
url = models.CharField(max_length=250)
ip = models.CharField(max_length=250)
+
class Log(models.Model):
date = models.DateTimeField(auto_now_add=True)
model = models.CharField(max_length=250)
signal = models.CharField(max_length=250)
+
def save(sender, **kwargs):
if sender != Log:
if kwargs['created']:
- signal='create'
+ signal = 'create'
else:
- signal='update'
+ signal = 'update'
- log = Log(model = sender.__name__, signal = signal)
+ log = Log(model=sender.__name__, signal=signal)
log.save()
+
def delete(sender, **kwargs):
- log = Log(model = sender.__name__, signal = 'delete')
+ log = Log(model=sender.__name__, signal='delete')
log.save()
+
post_save.connect(save)
post_delete.connect(delete)
View
@@ -158,25 +158,25 @@ def test(self):
class Signal(TestCase):
-
+
def test(self):
b = Bio(bio="Noooooooooooooo", surname="Sobol",
name="Andrey", other="pigeon post - white pigeon only",
birth="1990-09-18", skype="andreysobol",
jabber="pisecs@gmail.com", email="asobol@mail.ua",
img="img/1.jpg")
b.save()
- self.assertEqual(Log.objects.order_by('-id')[0].model,'Bio')
- self.assertEqual(Log.objects.order_by('-id')[0].signal,'create')
-
- b.bio="sfsf"
+ self.assertEqual(Log.objects.order_by('-id')[0].model, 'Bio')
+ self.assertEqual(Log.objects.order_by('-id')[0].signal, 'create')
+
+ b.bio = "sfsf"
b.save()
- self.assertEqual(Log.objects.order_by('-id')[0].model,'Bio')
- self.assertEqual(Log.objects.order_by('-id')[0].signal,'update')
+ self.assertEqual(Log.objects.order_by('-id')[0].model, 'Bio')
+ self.assertEqual(Log.objects.order_by('-id')[0].signal, 'update')
b.delete()
- self.assertEqual(Log.objects.order_by('-id')[0].model,'Bio')
- self.assertEqual(Log.objects.order_by('-id')[0].signal,'delete')
+ self.assertEqual(Log.objects.order_by('-id')[0].model, 'Bio')
+ self.assertEqual(Log.objects.order_by('-id')[0].signal, 'delete')
class ManyRequestTest(TestCase):

0 comments on commit 996fb38

Please sign in to comment.