Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 't9_command'

  • Loading branch information...
commit b4cbb5eb66fea48fcc8e8b621e48646287aa4d44 2 parents 9251041 + 49921e4
@andreysobol authored
View
0  testsobol/mainapp/management/__init__.py
No changes.
View
0  testsobol/mainapp/management/commands/__init__.py
No changes.
View
10 testsobol/mainapp/management/commands/printmodels.py
@@ -0,0 +1,10 @@
+from django.core.management.base import NoArgsCommand
+from django.db import models
+import sys
+
+class Command(NoArgsCommand):
+
+ def handle(self, *args, **options):
+ p = unicode([(cls.__name__,cls.objects.count()) for cls in models.get_models()])
+ print p
+ print >> sys.stderr, 'error: ' + p,
View
17 testsobol/mainapp/tests.py
@@ -4,7 +4,9 @@
Replace this with more appropriate tests for your application.
"""
+import os
from datetime import datetime, timedelta
+from subprocess import Popen, PIPE
from django.test import TestCase
from django.forms.models import model_to_dict
@@ -110,3 +112,18 @@ def test(self):
page = self.client.get('/')
self.assertTrue(page.content.find('<a href="/admin/auth/user/1/"') != -1 )
+
+
+class Command(TestCase):
+
+ def test(self):
+ p = Popen("python manage.py printmodels", stdout=PIPE, stderr=PIPE, shell=True).stdout.read()
+ self.assertTrue(p.find('Bio')!=-1)
+ Popen("bash save.bash", stdout=PIPE, stderr=PIPE, shell=True)
+ l = os.listdir(".")
+ for d in l:
+ if d.find('.dat')!=-1:
+ f = open(d,'r')
+ self.assertTrue((f.read()).find('error') != -1)
+ f.close()
+ Popen("rm " + d, stdout=PIPE, stderr=PIPE, shell=True)
View
4 testsobol/save.bash
@@ -0,0 +1,4 @@
+#!/bin/bash
+filename=`date +%Y%m%d`".dat"
+python manage.py printmodels 2>$filename
+
Please sign in to comment.
Something went wrong with that request. Please try again.