Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added first test of register

  • Loading branch information...
commit d3790185ec30e20e843718b276af9169cb9a1960 1 parent 50fa792
Nikolaj Baer authored
Showing with 40 additions and 16 deletions.
  1. +39 −15 reportengine/tests.py
  2. +1 −1  tests/runtests.py
View
54 reportengine/tests.py
@@ -1,23 +1,47 @@
"""
-This file demonstrates two different styles of tests (one doctest and one
-unittest). These will both pass when you run "manage.py test".
-
-Replace these with more appropriate tests for your application.
+Report Engine Tests.
"""
-
+from base import Report
+from filtercontrols import FilterControl
from django.test import TestCase
+from django import forms
+import reportengine
+
+class BasicTestReport(Report):
+ """Test Report. set the rows an aggregate to test"""
+ slug="test"
+ namespace="testing"
+ verbose_name="Basic Test Report"
+
+ def __init__(self,
+ rows=[ [1,2,3] ],
+ labels=["col1","col2","col3"],
+ aggregate = (('total',1),),
+ filterform = forms.Form() ):
+ self.rows=rows
+ self.labels=labels
+ self.aggregate=aggregate
+ self.filterform=filterform
-class SimpleTest(TestCase):
- def test_basic_addition(self):
+ def get_rows(self,filters={},order_by=None):
+ return self.rows,self.aggregate
+
+ def get_filter_form(self,request):
+ return self.filterform
+
+class BasicReportTest(TestCase):
+ def test_report_register(self):
"""
- Tests that 1 + 1 always equals 2.
+ Tests registering a report, and verifies report is now accessible
"""
- self.failUnlessEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
+ r=BasicTestReport()
+ reportengine.register(r)
+ assert(reportengine.get_report("testing","test") == r)
+ found=False
+ for rep in reportengine.all_reports():
+ if rep[0] == (r.namespace,r.slug):
+ assert(rep[1] == r)
+ found=True
+ assert(found)
->>> 1 + 1 == 2
-True
-"""}
View
2  tests/runtests.py
@@ -3,7 +3,7 @@
test_dir = os.path.dirname(__file__)
sys.path.insert(0, test_dir)
sys.path.insert(0, os.path.join(os.path.split(test_dir)[0],"example"))
-
+sys.path.insert(0, os.path.join(os.path.split(test_dir)[0]))
from django.test.simple import run_tests as django_test_runner
from django.conf import settings
Please sign in to comment.
Something went wrong with that request. Please try again.