@@ 29-52 (lines=24) @@ | ||
26 | from omaha.tests.utils import temporary_media_root |
|
27 | ||
28 | ||
29 | class VersionManagerTest(TestCase): |
|
30 | @temporary_media_root() |
|
31 | def test_filter_by_enabled(self): |
|
32 | version = VersionFactory.create( |
|
33 | version='37.0.2062.125', |
|
34 | file=SimpleUploadedFile('./chrome_installer.exe', False)) |
|
35 | version_disabled = VersionFactory.create( |
|
36 | app=version.app, |
|
37 | platform=version.platform, |
|
38 | channel=version.channel, |
|
39 | is_enabled=False, |
|
40 | version='38.0.2062.125', |
|
41 | file=SimpleUploadedFile('./chrome_installer2.exe', False)) |
|
42 | ||
43 | self.assertEqual(Version.objects.all().count(), 2) |
|
44 | self.assertEqual(Version.objects.filter_by_enabled().count(), 1) |
|
45 | self.assertIn(version, Version.objects.filter_by_enabled()) |
|
46 | self.assertNotIn(version_disabled, Version.objects.filter_by_enabled()) |
|
47 | ||
48 | def test_get_size(self): |
|
49 | file_size = 42 |
|
50 | VersionFactory.create_batch(10, file_size=file_size) |
|
51 | size = Version.objects.get_size() |
|
52 | self.assertEqual(size, file_size*10) |
|
53 |
@@ 29-51 (lines=23) @@ | ||
26 | from omaha.tests.utils import temporary_media_root |
|
27 | ||
28 | ||
29 | class VersionManagerTest(TestCase): |
|
30 | @temporary_media_root() |
|
31 | def test_filter_by_enabled(self): |
|
32 | version = SparkleVersionFactory.create( |
|
33 | version='2062.125', |
|
34 | file=SimpleUploadedFile('./chrome_installer.exe', False)) |
|
35 | version_disabled = SparkleVersionFactory.create( |
|
36 | app=version.app, |
|
37 | channel=version.channel, |
|
38 | is_enabled=False, |
|
39 | version='2062.126', |
|
40 | file=SimpleUploadedFile('./chrome_installer2.exe', False)) |
|
41 | ||
42 | self.assertEqual(SparkleVersion.objects.all().count(), 2) |
|
43 | self.assertEqual(SparkleVersion.objects.filter_by_enabled().count(), 1) |
|
44 | self.assertIn(version, SparkleVersion.objects.filter_by_enabled()) |
|
45 | self.assertNotIn(version_disabled, SparkleVersion.objects.filter_by_enabled()) |
|
46 | ||
47 | def test_get_size(self): |
|
48 | file_size = 42 |
|
49 | SparkleVersionFactory.create_batch(10, file_size=file_size) |
|
50 | size = SparkleVersion.objects.get_size() |
|
51 | self.assertEqual(size, file_size*10) |
|
52 |