<s> import datetime <EOL> from django . test import TestCase <EOL> from django . core . management import call_command <EOL> from django . core . files . uploadedfile import SimpleUploadedFile <EOL> from bitmapist import YearEvents <EOL> from omaha . tests . utils import temporary_media_root <EOL> from omaha . utils import redis <EOL> from omaha . models import ( <EOL> Application , <EOL> Platform , <EOL> Channel , <EOL> Version , <EOL> Request , <EOL> AppRequest <EOL> ) <EOL> class GenerateFakeDataTest ( TestCase ) : <EOL> @ temporary_media_root ( ) <EOL> def setUp ( self ) : <EOL> redis . flushdb ( ) <EOL> self . app = Application . objects . create ( id = '<STR_LIT>' , name = '<STR_LIT>' ) <EOL> self . channel = Channel . objects . create ( name = '<STR_LIT>' ) <EOL> self . platform = Platform . objects . create ( name = '<STR_LIT>' ) <EOL> self . version1 = Version . objects . create ( <EOL> app = self . app , <EOL> platform = self . platform , <EOL> channel = self . channel , <EOL> version = '<STR_LIT>' , <EOL> file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> self . version2 = Version . objects . create ( <EOL> app = self . app , <EOL> platform = self . platform , <EOL> channel = self . channel , <EOL> version = '<STR_LIT>' , <EOL> file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> def tearDown ( self ) : <EOL> redis . flushdb ( ) <EOL> def test_command ( self ) : <EOL> self . assertEqual ( <NUM_LIT:0> , Request . objects . all ( ) . count ( ) ) <EOL> call_command ( '<STR_LIT>' , self . app . id , count = <NUM_LIT:10> ) <EOL> self . assertEqual ( <NUM_LIT:10> , Request . objects . all ( ) . count ( ) ) <EOL> self . assertEqual ( <NUM_LIT:10> , AppRequest . objects . filter ( appid = self . app . id ) . count ( ) ) <EOL> class GenerateFakeStatisticsTest ( TestCase ) : <EOL> @ temporary_media_root ( ) <EOL> def setUp ( self ) : <EOL> redis . flushdb ( ) <EOL> self . app = Application . objects . create ( id = '<STR_LIT>' , name = '<STR_LIT>' ) <EOL> self . channel = Channel . objects . create ( name = '<STR_LIT>' ) <EOL> self . platform = Platform . objects . create ( name = '<STR_LIT>' ) <EOL> self . version1 = Version . objects . create ( <EOL> app = self . app , <EOL> platform = self . platform , <EOL> channel = self . channel , <EOL> version = '<STR_LIT>' , <EOL> file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> self . version2 = Version . objects . create ( <EOL> app = self . app , <EOL> platform = self . platform , <EOL> channel = self . channel , <EOL> version = '<STR_LIT>' , <EOL> file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> def tearDown ( self ) : <EOL> redis . flushdb ( ) <EOL> def test_command ( self ) : <EOL> now = datetime . datetime . now ( ) <EOL> year = now . year <EOL> self . assertEqual ( <NUM_LIT:0> , len ( YearEvents ( '<STR_LIT>' , year ) ) ) <EOL> call_command ( '<STR_LIT>' , self . app . id , count = <NUM_LIT:10> ) <EOL> self . assertEqual ( <NUM_LIT:10> , len ( YearEvents ( '<STR_LIT>' , year ) ) ) </s>
