from django.test import TestCase

# Create your tests here.

@@ -31,30 +31,1885 @@
 se%0A%0A
-# Create your tests here.
+from .models import CrashCount%0A%0Afrom crashsubmit.models import Version, Product%0A%0Aimport datetime%0Afrom django.utils import timezone%0A%0Adef get_date_n_days_ago(num_days):%0A    return datetime.date.fromordinal(datetime.date.today().toordinal() - num_days)%0A%0Aclass CrashCountManagerTest(TestCase):%0A%0A    def setUp(self):%0A        self.product = Product.objects.create(product_name=%22Product%22)%0A        self.version1 = Version.objects.create(product=self.product,%0A                major_version=1, minor_version=2, micro_version=3, patch_version=4)%0A        self.version2 = Version.objects.create(product=self.product,%0A                major_version=2, minor_version=2, micro_version=3, patch_version=4)%0A%0A        yesterday = get_date_n_days_ago(1)%0A        CrashCount.objects.create(version=self.version1, date=yesterday, count=3)%0A%0A        three_days_ago = get_date_n_days_ago(3)%0A        CrashCount.objects.create(version=self.version1, date=three_days_ago, count=3)%0A%0A%0A    def test_get_crash_count_no_param(self):%0A        res = CrashCount.objects.get_crash_count()%0A        self.assertEqual(len(res), 2)%0A%0A    def test_get_crash_count_versions(self):%0A        res = CrashCount.objects.get_crash_count(versions=%5Bself.version1%5D)%0A        self.assertEqual(len(res), 2)%0A%0A        res = CrashCount.objects.get_crash_count(versions=%5Bself.version2%5D)%0A        self.assertEqual(len(res), 0)%0A%0A    def test_get_crash_count_time(self):%0A        res = CrashCount.objects.get_crash_count(time=1)%0A        self.assertEqual(len(res), 1)%0A%0A        res = CrashCount.objects.get_crash_count(time=3)%0A        self.assertEqual(len(res), 2)%0A%0A    def test_get_crash_count_complete(self):%0A        res = CrashCount.objects.get_crash_count(time=2, versions=%5Bself.version1%5D)%0A        self.assertEqual(len(res), 1)%0A%0A        res = CrashCount.objects.get_crash_count(time=5, versions=%5Bself.version2%5D)%0A        self.assertEqual(len(res), 0)
 %0A

add initial CrashCountManager tests