<s> import os <EOL> import uuid <EOL> from django . test import SimpleTestCase <EOL> from django . test . utils import override_settings <EOL> from mock import patch , MagicMock <EOL> from corehq . apps . userreports . tests . utils import domain_lite <EOL> from corehq . util . test_utils import TestFileMixin <EOL> from corehq . apps . userreports . models import StaticDataSourceConfiguration , DataSourceConfiguration <EOL> @ patch ( '<STR_LIT>' , MagicMock ( return_value = [ domain_lite ( '<STR_LIT>' ) ] ) ) <EOL> class TestStaticDataSource ( SimpleTestCase , TestFileMixin ) : <EOL> file_path = ( '<STR_LIT:data>' , '<STR_LIT>' ) <EOL> root = os . path . dirname ( __file__ ) <EOL> def test_wrap ( self ) : <EOL> wrapped = StaticDataSourceConfiguration . wrap ( self . get_json ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( [ "<STR_LIT>" , "<STR_LIT>" ] , wrapped . domains ) <EOL> def test_get_all ( self ) : <EOL> with override_settings ( STATIC_DATA_SOURCES = [ self . get_path ( '<STR_LIT>' , '<STR_LIT>' ) ] ) : <EOL> all = list ( StaticDataSourceConfiguration . all ( ) ) <EOL> self . assertEqual ( <NUM_LIT:2> + <NUM_LIT:3> , len ( all ) ) <EOL> example , dimagi = all [ : <NUM_LIT:2> ] <EOL> self . assertEqual ( '<STR_LIT>' , example . domain ) <EOL> self . assertEqual ( '<STR_LIT>' , dimagi . domain ) <EOL> for config in all [ : <NUM_LIT:2> ] : <EOL> self . assertEqual ( '<STR_LIT>' , config . table_id ) <EOL> for config in all [ <NUM_LIT:3> : ] : <EOL> self . assertEqual ( '<STR_LIT>' , config . domain ) <EOL> def test_is_static_positive ( self ) : <EOL> with override_settings ( STATIC_DATA_SOURCES = [ self . get_path ( '<STR_LIT>' , '<STR_LIT>' ) ] ) : <EOL> example = list ( StaticDataSourceConfiguration . all ( ) ) [ <NUM_LIT:0> ] <EOL> self . assertTrue ( example . is_static ) <EOL> def test_is_static_negative ( self ) : <EOL> self . assertFalse ( DataSourceConfiguration ( ) . is_static ) <EOL> self . assertFalse ( DataSourceConfiguration ( _id = uuid . uuid4 ( ) . hex ) . is_static ) <EOL> def test_deactivate_noop ( self ) : <EOL> with override_settings ( STATIC_DATA_SOURCES = [ self . get_path ( '<STR_LIT>' , '<STR_LIT>' ) ] ) : <EOL> example = list ( StaticDataSourceConfiguration . all ( ) ) [ <NUM_LIT:0> ] <EOL> example . deactivate ( ) <EOL> def test_production_config ( self ) : <EOL> for data_source in StaticDataSourceConfiguration . all ( ) : <EOL> data_source . validate ( ) </s>
