<s> import django <EOL> import unittest <EOL> from django . core . validators import validate_email , validate_slug , URLValidator <EOL> from django . utils . timezone import utc <EOL> from django . core . files . images import ImageFile <EOL> from django . core . management import call_command <EOL> import string <EOL> import datetime <EOL> import os <EOL> import six <EOL> from sampledatahelper . helper import SampleDataHelper <EOL> from sampledatahelper . model_helper import ModelDataHelper <EOL> from sampledata . mixins import image_mixin <EOL> from sampledata . exceptions import ParameterError , NotChoicesFound <EOL> if django . VERSION >= ( <NUM_LIT:1> , <NUM_LIT:7> ) : <EOL> django . setup ( ) <EOL> call_command ( '<STR_LIT>' , run_syncdb = True , interactive = False ) <EOL> else : <EOL> call_command ( '<STR_LIT>' , interactive = False ) <EOL> from . import models <EOL> class TestNumberHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( datetime . datetime . now ( ) ) <EOL> def test_int ( self ) : <EOL> self . assertEqual ( self . sd . int ( min_value = <NUM_LIT:5> , max_value = <NUM_LIT:5> ) , <NUM_LIT:5> ) <EOL> self . assertTrue ( self . sd . int ( min_value = <NUM_LIT> ) >= <NUM_LIT> ) <EOL> self . assertTrue ( self . sd . int ( max_value = <NUM_LIT:3> ) <= <NUM_LIT:3> ) <EOL> self . assertTrue ( isinstance ( self . sd . int ( ) , int ) ) <EOL> val = self . sd . int ( <NUM_LIT:5> , <NUM_LIT:10> ) <EOL> self . assertTrue ( val <= <NUM_LIT:10> ) <EOL> self . assertTrue ( val >= <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . int ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_number ( self ) : <EOL> self . assertTrue ( len ( str ( self . sd . number ( <NUM_LIT:5> ) ) ) <= <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . number ( <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . number ( - <NUM_LIT:1> ) <EOL> def test_digits ( self ) : <EOL> self . assertEqual ( len ( str ( self . sd . digits ( <NUM_LIT:5> ) ) ) , <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . digits ( <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . digits ( - <NUM_LIT:1> ) <EOL> def test_float ( self ) : <EOL> value = self . sd . float ( <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> self . assertTrue ( isinstance ( value , float ) ) <EOL> self . assertTrue ( value >= <NUM_LIT:1> ) <EOL> self . assertTrue ( value <= <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . float ( <NUM_LIT:0> , <NUM_LIT:0> ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( self . sd . float ( <NUM_LIT:5> , <NUM_LIT:5> ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . float ( - <NUM_LIT:5> , - <NUM_LIT:5> ) , - <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . float ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_number_string ( self ) : <EOL> value = self . sd . number_string ( <NUM_LIT:5> ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . number_string ( <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . number_string ( - <NUM_LIT:1> ) <EOL> class TestTextHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( ) <EOL> def test_char ( self ) : <EOL> value = self . sd . char ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( value in string . ascii_letters ) <EOL> def test_chars ( self ) : <EOL> value = self . sd . chars ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value ) >= <NUM_LIT:1> ) <EOL> self . assertTrue ( len ( value ) <= <NUM_LIT:5> ) <EOL> value = self . sd . chars ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertTrue ( len ( value ) == <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . chars ( <NUM_LIT:0> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . chars ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_word ( self ) : <EOL> value = self . sd . word ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> def test_words ( self ) : <EOL> value = self . sd . words ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value . split ( '<STR_LIT:U+0020>' ) ) >= <NUM_LIT:1> ) <EOL> self . assertTrue ( len ( value . split ( '<STR_LIT:U+0020>' ) ) <= <NUM_LIT:5> ) <EOL> value = self . sd . words ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertTrue ( len ( value . split ( '<STR_LIT:U+0020>' ) ) == <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . words ( <NUM_LIT:0> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . words ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_email ( self ) : <EOL> value = self . sd . email ( ) <EOL> validate_email ( value ) <EOL> def test_url ( self ) : <EOL> value = self . sd . url ( ) <EOL> URLValidator ( ) ( value ) <EOL> def test_sentence ( self ) : <EOL> for x in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> value = self . sd . sentence ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value ) <= <NUM_LIT:255> ) <EOL> def test_short_sentence ( self ) : <EOL> for x in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> value = self . sd . short_sentence ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value ) <= <NUM_LIT:100> ) <EOL> def test_long_sentence ( self ) : <EOL> for x in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> value = self . sd . long_sentence ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value ) >= <NUM_LIT> ) <EOL> def test_paragraph ( self ) : <EOL> value = self . sd . paragraph ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> def test_paragraphs ( self ) : <EOL> for x in range ( <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> value = self . sd . paragraphs ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value . split ( '<STR_LIT>' ) ) >= <NUM_LIT:1> ) <EOL> self . assertTrue ( len ( value . split ( '<STR_LIT>' ) ) <= <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . paragraphs ( <NUM_LIT:5> , <NUM_LIT:1> ) <EOL> def test_slug ( self ) : <EOL> value = self . sd . slug ( ) <EOL> validate_slug ( value ) <EOL> value = self . sd . slug ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT:U+0020>' ) ) , <NUM_LIT:1> ) <EOL> validate_slug ( value ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . slug ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_tags ( self ) : <EOL> value = self . sd . tags ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> value = self . sd . tags ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT:U+002C>' ) ) , <NUM_LIT:5> ) <EOL> value = self . sd . tags ( <NUM_LIT:5> , <NUM_LIT:5> , [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> self . assertTrue ( value . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:0> ] in [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ] ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . tags ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> class TestTimeHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( ) <EOL> def test_date_between ( self ) : <EOL> value = self . sd . date_between ( <EOL> datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> ) <EOL> self . assertTrue ( isinstance ( value , datetime . date ) ) <EOL> self . assertTrue ( value > datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) ) <EOL> self . assertTrue ( value < datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . date_between ( <EOL> datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> datetime . date ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> ) <EOL> def test_future_date ( self ) : <EOL> value = self . sd . future_date ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . date ) ) <EOL> self . assertTrue ( value >= datetime . date . today ( ) ) <EOL> self . assertTrue ( value <= ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT> ) ) ) <EOL> value = self . sd . future_date ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value >= datetime . date . today ( ) ) <EOL> self . assertTrue ( value <= ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . future_date ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . future_date ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> def test_past_date ( self ) : <EOL> value = self . sd . past_date ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . date ) ) <EOL> self . assertTrue ( value <= datetime . date . today ( ) ) <EOL> self . assertTrue ( value >= ( datetime . date . today ( ) - datetime . timedelta ( days = <NUM_LIT> ) ) ) <EOL> value = self . sd . past_date ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value <= datetime . date . today ( ) ) <EOL> self . assertTrue ( value >= ( datetime . date . today ( ) - datetime . timedelta ( days = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . past_date ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . past_date ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> def test_datetime_between ( self ) : <EOL> value = self . sd . datetime_between ( <EOL> datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> ) <EOL> self . assertTrue ( isinstance ( value , datetime . datetime ) ) <EOL> self . assertTrue ( value > datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) ) <EOL> self . assertTrue ( value < datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . datetime_between ( <EOL> datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:1> , day = <NUM_LIT:1> ) , <EOL> ) <EOL> def test_future_datetime ( self ) : <EOL> now = datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) <EOL> value = self . sd . future_datetime ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . datetime ) ) <EOL> self . assertTrue ( value >= now ) <EOL> self . assertTrue ( value <= ( now + datetime . timedelta ( minutes = <NUM_LIT> ) ) ) <EOL> now = datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) <EOL> value = self . sd . future_datetime ( <NUM_LIT:1> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value >= now ) <EOL> self . assertTrue ( value <= ( now + datetime . timedelta ( minutes = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . future_datetime ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . future_datetime ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> def test_past_datetime ( self ) : <EOL> value = self . sd . past_datetime ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . datetime ) ) <EOL> self . assertTrue ( value <= datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) ) <EOL> self . assertTrue ( value >= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) - datetime . timedelta ( minutes = <NUM_LIT> ) ) ) <EOL> value = self . sd . past_datetime ( <NUM_LIT:0> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value <= datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) ) <EOL> self . assertTrue ( value >= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) - datetime . timedelta ( minutes = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . past_datetime ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . past_datetime ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> def test_date ( self ) : <EOL> value = self . sd . date ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . date ) ) <EOL> self . assertTrue ( value >= ( datetime . date . today ( ) - datetime . timedelta ( days = <NUM_LIT> ) ) ) <EOL> self . assertTrue ( value <= ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT> ) ) ) <EOL> value = self . sd . date ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value >= ( datetime . date . today ( ) - datetime . timedelta ( days = <NUM_LIT:10> ) ) ) <EOL> self . assertTrue ( value <= ( datetime . date . today ( ) + datetime . timedelta ( days = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . date ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> def test_datetime ( self ) : <EOL> value = self . sd . datetime ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . datetime ) ) <EOL> self . assertTrue ( value >= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) - datetime . timedelta ( minutes = <NUM_LIT> ) ) ) <EOL> self . assertTrue ( value <= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) + datetime . timedelta ( minutes = <NUM_LIT> ) ) ) <EOL> value = self . sd . datetime ( - <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> self . assertTrue ( value >= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) - datetime . timedelta ( minutes = <NUM_LIT:10> ) ) ) <EOL> self . assertTrue ( value <= ( datetime . datetime . utcnow ( ) . replace ( tzinfo = utc ) + datetime . timedelta ( minutes = <NUM_LIT:10> ) ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . datetime ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> def test_time ( self ) : <EOL> value = self . sd . time ( ) <EOL> self . assertTrue ( isinstance ( value , datetime . time ) ) <EOL> class TestLocalizedHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( ) <EOL> def test_state_code ( self ) : <EOL> value = self . sd . state_code ( '<STR_LIT>' ) <EOL> self . assertTrue ( value in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ] ) <EOL> value = self . sd . state_code ( '<STR_LIT>' ) <EOL> self . assertTrue ( value in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:OK>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , ] ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . state_code ( '<STR_LIT>' ) <EOL> def test_name ( self ) : <EOL> value = self . sd . name ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> value = self . sd . name ( as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . name ( number = <NUM_LIT:3> , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:3> ) <EOL> value = self . sd . name ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . name ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . name ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . name ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . name ( number = <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . name ( number = - <NUM_LIT:1> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . name ( locale = "<STR_LIT>" ) <EOL> def test_surname ( self ) : <EOL> value = self . sd . surname ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> value = self . sd . surname ( as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . surname ( number = <NUM_LIT:3> , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:3> ) <EOL> value = self . sd . surname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:2> ) <EOL> value = self . sd . surname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:2> ) <EOL> value = self . sd . surname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> value = self . sd . surname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:1> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . surname ( number = <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . surname ( number = - <NUM_LIT:1> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . surname ( locale = "<STR_LIT>" ) <EOL> def test_fullname ( self ) : <EOL> value = self . sd . fullname ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> value = self . sd . fullname ( as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:2> ) <EOL> value = self . sd . fullname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:3> ) <EOL> value = self . sd . fullname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:3> ) <EOL> value = self . sd . fullname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:2> ) <EOL> value = self . sd . fullname ( locale = '<STR_LIT>' , as_list = True ) <EOL> self . assertTrue ( isinstance ( value , list ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:2> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . fullname ( locale = "<STR_LIT>" ) <EOL> def test_phone ( self ) : <EOL> value = self . sd . phone ( locale = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:9> ) <EOL> self . assertTrue ( value [ <NUM_LIT:0> ] in [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> value = self . sd . phone ( locale = '<STR_LIT>' , country_code = True ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT> ) <EOL> self . assertTrue ( value [ <NUM_LIT:0> : <NUM_LIT:5> ] in [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . phone ( locale = "<STR_LIT>" ) <EOL> def test_zip_code ( self ) : <EOL> value = self . sd . zip_code ( locale = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . zip_code ( locale = "<STR_LIT>" ) <EOL> def test_id_card ( self ) : <EOL> value = self . sd . id_card ( locale = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value ) , <NUM_LIT:9> ) <EOL> self . assertTrue ( value [ <NUM_LIT:8> ] in "<STR_LIT>" ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . id_card ( locale = "<STR_LIT>" ) <EOL> class TestImageHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( ) <EOL> def test_image_from_directory ( self ) : <EOL> value = self . sd . image_from_directory ( os . path . dirname ( __file__ ) ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . image_from_directory ( '<STR_LIT>' ) <EOL> with self . assertRaises ( NotChoicesFound ) : <EOL> self . sd . image_from_directory ( os . path . dirname ( __file__ ) , [ '<STR_LIT>' ] ) <EOL> def test_image ( self ) : <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( value , ImageFile ) ) <EOL> image_mixin . PIL_INSTALLED = False <EOL> with self . assertRaises ( ImportError ) : <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> image_mixin . PIL_INSTALLED = True <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:100> , typ = "<STR_LIT>" ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . image ( <NUM_LIT:0> , <NUM_LIT:100> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . image ( <NUM_LIT:100> , <NUM_LIT:0> ) <EOL> class TestOtherHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . sd = SampleDataHelper ( ) <EOL> def test_boolean ( self ) : <EOL> self . assertTrue ( isinstance ( self . sd . boolean ( ) , bool ) ) <EOL> def test_ipv4 ( self ) : <EOL> value = self . sd . ipv4 ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT:.>' ) ) , <NUM_LIT:4> ) <EOL> def test_ipv6 ( self ) : <EOL> value = self . sd . ipv6 ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT::>' ) ) , <NUM_LIT:8> ) <EOL> def test_mac_address ( self ) : <EOL> value = self . sd . mac_address ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT::>' ) ) , <NUM_LIT:6> ) <EOL> def test_path ( self ) : <EOL> value = self . sd . path ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> value = self . sd . path ( absolute = False , min_levels = <NUM_LIT:5> , max_levels = <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT:/>' ) ) , <NUM_LIT:5> ) <EOL> value = self . sd . path ( absolute = True , min_levels = <NUM_LIT:5> , max_levels = <NUM_LIT:5> ) <EOL> self . assertEqual ( len ( value . split ( '<STR_LIT:/>' ) ) , <NUM_LIT:6> ) <EOL> value = self . sd . path ( extension = "<STR_LIT>" ) <EOL> self . assertEqual ( value [ - <NUM_LIT:4> : ] , "<STR_LIT>" ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . path ( absolute = True , min_levels = <NUM_LIT:10> , max_levels = <NUM_LIT:5> ) <EOL> def test_hex_chars ( self ) : <EOL> value = self . sd . hex_chars ( ) <EOL> self . assertTrue ( isinstance ( value , six . string_types ) ) <EOL> self . assertTrue ( len ( value ) >= <NUM_LIT:1> ) <EOL> self . assertTrue ( len ( value ) <= <NUM_LIT:5> ) <EOL> value = self . sd . hex_chars ( <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertTrue ( len ( value ) == <NUM_LIT:5> ) <EOL> self . assertEqual ( self . sd . hex_chars ( <NUM_LIT:0> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> value = self . sd . hex_chars ( <NUM_LIT:10> , <NUM_LIT:5> ) <EOL> def test_choice ( self ) : <EOL> self . assertEqual ( self . sd . choice ( [ <NUM_LIT:10> ] ) , <NUM_LIT:10> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . choice ( [ ] ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . choice ( <NUM_LIT:7> ) <EOL> def test_choices_key ( self ) : <EOL> choices = [ <EOL> ( <NUM_LIT:1> , '<STR_LIT:test>' ) <EOL> ] <EOL> self . assertEqual ( self . sd . choices_key ( choices ) , <NUM_LIT:1> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . choices_key ( [ ] ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . choices_key ( <NUM_LIT:7> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . sd . choices_key ( [ <NUM_LIT:10> ] ) <EOL> def test_db_object ( self ) : <EOL> mdh = ModelDataHelper ( ) <EOL> with self . assertRaises ( NotChoicesFound ) : <EOL> self . sd . db_object ( models . TestRelatedModel ) <EOL> mdh . fill_model ( models . TestRelatedModel , <NUM_LIT:1> ) <EOL> self . assertTrue ( isinstance ( <EOL> self . sd . db_object ( models . TestRelatedModel ) , <EOL> models . TestRelatedModel <EOL> ) ) <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> def test_db_object_string ( self ) : <EOL> mdh = ModelDataHelper ( ) <EOL> with self . assertRaises ( NotChoicesFound ) : <EOL> self . sd . db_object ( '<STR_LIT>' ) <EOL> mdh . fill_model ( models . TestRelatedModel , <NUM_LIT:1> ) <EOL> self . assertTrue ( isinstance ( <EOL> self . sd . db_object ( '<STR_LIT>' ) , <EOL> models . TestRelatedModel <EOL> ) ) <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> def test_db_object_from_queryset ( self ) : <EOL> mdh = ModelDataHelper ( ) <EOL> with self . assertRaises ( NotChoicesFound ) : <EOL> self . sd . db_object_from_queryset ( models . TestRelatedModel . objects . all ( ) ) <EOL> mdh . fill_model ( models . TestRelatedModel , <NUM_LIT:10> ) <EOL> self . assertTrue ( isinstance ( <EOL> self . sd . db_object_from_queryset ( models . TestRelatedModel . objects . all ( ) ) , <EOL> models . TestRelatedModel <EOL> ) ) <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> class TestModelDataHelpers ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . mdh = ModelDataHelper ( ) <EOL> cls . mdh . fill_model ( models . TestRelatedModel , <NUM_LIT:10> ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> def test_fill_model_instance ( self ) : <EOL> instance = models . TestModel ( ) <EOL> self . mdh . fill_model_instance ( instance ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . mdh . fill_model_instance ( unittest . TestCase ) <EOL> self . mdh . fill_model_instance ( instance , integer = lambda _ , sd : sd . int ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> self . assertEqual ( instance . integer , <NUM_LIT:5> ) <EOL> self . mdh . fill_model_instance ( instance , integer = <NUM_LIT:15> ) <EOL> self . assertEqual ( instance . integer , <NUM_LIT:15> ) <EOL> def test_fill_model ( self ) : <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:0> ) <EOL> with self . assertRaises ( ParameterError ) : <EOL> self . mdh . fill_model ( unittest . TestCase , <NUM_LIT:5> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , integer = lambda _ , sd : sd . int ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> self . assertEqual ( models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] . integer , <NUM_LIT:5> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , integer = <NUM_LIT:15> ) <EOL> self . assertEqual ( models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] . integer , <NUM_LIT:15> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , integer = lambda instance , _ : instance . small_integer * <NUM_LIT:2> ) <EOL> test_instance = models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( test_instance . integer , test_instance . small_integer * <NUM_LIT:2> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , ( '<STR_LIT>' , lambda _ , sd : sd . int ( <NUM_LIT:5> , <NUM_LIT:5> ) ) ) <EOL> self . assertEqual ( models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] . integer , <NUM_LIT:5> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , ( '<STR_LIT>' , <NUM_LIT:15> ) ) <EOL> self . assertEqual ( models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] . integer , <NUM_LIT:15> ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> self . mdh . fill_model ( models . TestModel , <NUM_LIT:5> , ( '<STR_LIT>' , lambda instance , _ : instance . small_integer * <NUM_LIT:2> ) ) <EOL> test_instance = models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( test_instance . integer , test_instance . small_integer * <NUM_LIT:2> ) <EOL> class TestSampleDataHelperCommand ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> models . TestRelatedModel . objects . all ( ) . delete ( ) <EOL> models . TestModel . objects . all ( ) . delete ( ) <EOL> def test_calling_command ( self ) : <EOL> call_command ( '<STR_LIT>' , interactive = False ) <EOL> self . assertEqual ( models . TestRelatedModel . objects . all ( ) . count ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( models . TestModel . objects . all ( ) . count ( ) , <NUM_LIT:5> ) <EOL> test_instance = models . TestModel . objects . all ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( test_instance . integer , test_instance . small_integer * <NUM_LIT:2> ) <EOL> self . assertEqual ( test_instance . positive_integer , <NUM_LIT:8> ) <EOL> self . assertTrue ( test_instance . small_integer >= <NUM_LIT:1> and test_instance . small_integer <= <NUM_LIT:10> ) </s>
