<s> from . import pods <EOL> from . import static <EOL> from . import storage <EOL> from . . import preprocessors <EOL> from grow . common import utils <EOL> from grow . testing import testing <EOL> import jinja2 <EOL> import mock <EOL> import os <EOL> import unittest <EOL> class PodTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . dir_path = testing . create_test_pod_dir ( ) <EOL> self . pod = pods . Pod ( self . dir_path , storage = storage . FileStorage ) <EOL> def test_eq ( self ) : <EOL> pod = pods . Pod ( self . dir_path , storage = storage . FileStorage ) <EOL> self . assertEqual ( self . pod , pod ) <EOL> def test_list_dir ( self ) : <EOL> dirpath = os . path . join ( self . dir_path , '<STR_LIT:content>' ) <EOL> num_files = <NUM_LIT:0> <EOL> for root , dirs , files in os . walk ( dirpath ) : <EOL> for filename in files : <EOL> num_files += <NUM_LIT:1> <EOL> actual = self . pod . list_dir ( '<STR_LIT>' ) <EOL> self . assertEqual ( len ( actual ) , num_files ) <EOL> def test_read_file ( self ) : <EOL> content = self . pod . read_file ( '<STR_LIT>' ) <EOL> path = os . path . join ( self . dir_path , '<STR_LIT>' ) <EOL> expected_content = open ( path ) . read ( ) <EOL> self . assertEqual ( expected_content , content ) <EOL> def test_write_file ( self ) : <EOL> path = '<STR_LIT>' <EOL> self . pod . write_file ( path , '<STR_LIT:foo>' ) <EOL> content = self . pod . read_file ( path ) <EOL> self . assertEqual ( '<STR_LIT:foo>' , content ) <EOL> self . pod . write_file ( path , '<STR_LIT:bar>' ) <EOL> content = self . pod . read_file ( path ) <EOL> self . assertEqual ( '<STR_LIT:bar>' , content ) <EOL> def test_list_collections ( self ) : <EOL> self . pod . list_collections ( ) <EOL> def test_export ( self ) : <EOL> self . pod . export ( ) <EOL> def test_dump ( self ) : <EOL> paths = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> result = self . pod . dump ( ) <EOL> self . assertItemsEqual ( paths , result ) <EOL> def test_to_message ( self ) : <EOL> self . pod . to_message ( ) <EOL> def test_list_deployments ( self ) : <EOL> self . pod . list_deployments ( ) <EOL> def test_get_home_doc ( self ) : <EOL> home_doc = self . pod . get_home_doc ( ) <EOL> doc = self . pod . get_doc ( '<STR_LIT>' ) <EOL> self . assertEqual ( home_doc , doc ) <EOL> def test_get_static ( self ) : <EOL> static_file = self . pod . get_static ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT:file>' , static_file . base ) <EOL> self . assertTrue ( static_file . exists ) <EOL> self . assertRaises ( <EOL> static . BadStaticFileError , self . pod . get_static , <EOL> '<STR_LIT>' ) <EOL> def test_list_statics ( self ) : <EOL> items = self . pod . list_statics ( '<STR_LIT>' ) <EOL> expected = [ <EOL> self . pod . get_static ( '<STR_LIT>' ) , <EOL> self . pod . get_static ( '<STR_LIT>' ) , <EOL> self . pod . get_static ( '<STR_LIT>' ) , <EOL> self . pod . get_static ( '<STR_LIT>' ) , <EOL> ] <EOL> for item in items : <EOL> self . assertIn ( item , expected ) <EOL> def test_list_jinja_extensions ( self ) : <EOL> items = self . pod . list_jinja_extensions ( ) <EOL> self . assertEqual ( len ( items ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( items [ <NUM_LIT:0> ] . __name__ , '<STR_LIT>' ) <EOL> self . assertTrue ( issubclass ( items [ <NUM_LIT:0> ] , jinja2 . ext . Extension ) ) <EOL> def test_invalid_jinja_extension ( self ) : <EOL> with mock . patch . dict ( self . pod . yaml , { '<STR_LIT>' : { '<STR_LIT>' : [ '<STR_LIT>' ] } } ) : <EOL> with self . assertRaises ( pods . PodSpecParseError ) : <EOL> self . pod . list_jinja_extensions ( ) <EOL> def test_list_preprocessors ( self ) : <EOL> items = self . pod . list_preprocessors ( ) <EOL> self . assertEqual ( len ( items ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( items [ <NUM_LIT:0> ] . __class__ . __name__ , '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( items [ <NUM_LIT:0> ] , preprocessors . base . BasePreprocessor ) ) <EOL> self . assertEqual ( len ( self . pod . list_preprocessors ( ) ) , <NUM_LIT:1> ) <EOL> def test_custom_preprocessor ( self ) : <EOL> self . pod . preprocess ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( self . pod . _custom_preprocessor_value , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
