<s> from . import collection <EOL> from . import locales <EOL> from . import pods <EOL> from . import storage <EOL> from grow . testing import testing <EOL> import unittest <EOL> class CollectionsTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> dir_path = testing . create_test_pod_dir ( ) <EOL> self . pod = pods . Pod ( dir_path , storage = storage . FileStorage ) <EOL> def test_get ( self ) : <EOL> col = self . pod . get_collection ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , col . collection_path ) <EOL> col2 = self . pod . get_collection ( '<STR_LIT>' ) <EOL> docs = col2 . list_docs ( ) <EOL> self . assertEqual ( col , col2 ) <EOL> self . assertEqual ( col , docs [ <NUM_LIT:0> ] . collection ) <EOL> def test_list ( self ) : <EOL> collection . Collection . list ( self . pod ) <EOL> def test_list_docs ( self ) : <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> documents = collection . list_docs ( locale = '<STR_LIT>' ) <EOL> for doc in documents : <EOL> self . assertEqual ( '<STR_LIT>' , doc . locale ) <EOL> documents = collection . list_docs ( ) <EOL> for doc in documents : <EOL> self . assertFalse ( doc . hidden ) <EOL> documents = collection . list_docs ( include_hidden = True ) <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> documents = collection . list_docs ( order_by = '<STR_LIT>' , reverse = True ) <EOL> expected = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . assertListEqual ( expected , [ doc . base for doc in documents ] ) <EOL> def test_list_locales ( self ) : <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> found_locales = collection . list_locales ( ) <EOL> expected = locales . Locale . parse_codes ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> self . assertListEqual ( expected , found_locales ) <EOL> def test_list_servable_documents ( self ) : <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> collection . list_servable_documents ( ) <EOL> def test_format ( self ) : <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> doc = collection . get_doc ( '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , doc . body ) <EOL> self . assertEqual ( '<STR_LIT>' , doc . html ) <EOL> def test_empty_front_matter ( self ) : <EOL> collection = self . pod . get_collection ( '<STR_LIT>' ) <EOL> docs = collection . list_docs ( ) <EOL> path = '<STR_LIT>' <EOL> expected_doc = self . pod . get_doc ( path ) <EOL> self . assertEqual ( expected_doc , docs [ <NUM_LIT:0> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
