<s> from rest_framework . test import APITestCase <EOL> from tests . testapp . models import TimeSeries <EOL> from wq . io import load_file <EOL> class ExcelTestCase ( APITestCase ) : <EOL> def setUp ( self ) : <EOL> data = ( <EOL> ( '<STR_LIT>' , <NUM_LIT:0.5> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0.1> ) , <EOL> ) <EOL> for date , value in data : <EOL> TimeSeries . objects . create ( date = date , value = value ) <EOL> def test_xls ( self ) : <EOL> response = self . client . get ( "<STR_LIT>" ) <EOL> xlfile = open ( '<STR_LIT>' , '<STR_LIT:wb>' ) <EOL> xlfile . write ( response . content ) <EOL> xlfile . close ( ) <EOL> data = load_file ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] . date . year , <NUM_LIT> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] . value , <NUM_LIT:0.5> ) <EOL> def test_xlsx ( self ) : <EOL> response = self . client . get ( "<STR_LIT>" ) <EOL> xlfile = open ( '<STR_LIT>' , '<STR_LIT:wb>' ) <EOL> xlfile . write ( response . content ) <EOL> xlfile . close ( ) <EOL> data = load_file ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] . date . year , <NUM_LIT> ) <EOL> self . assertEqual ( data [ <NUM_LIT:0> ] . value , <NUM_LIT:0.5> ) </s>
