<s> import json <EOL> import mock <EOL> from awscli . testutils import unittest , FileCreator <EOL> from awscli . topictags import TopicTagDB <EOL> class TestTopicTagDB ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . topic_tag_db = TopicTagDB ( ) <EOL> self . file_creator = FileCreator ( ) <EOL> def tearDown ( self ) : <EOL> self . file_creator . remove_all ( ) <EOL> class TestTopicTagDBGeneral ( TestTopicTagDB ) : <EOL> def test_valid_tags ( self ) : <EOL> self . assertCountEqual ( <EOL> self . topic_tag_db . valid_tags , <EOL> [ '<STR_LIT:title>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> ) <EOL> def test_topic_dir ( self ) : <EOL> self . topic_tag_db = TopicTagDB ( topic_dir = '<STR_LIT:foo>' ) <EOL> self . assertEqual ( self . topic_tag_db . topic_dir , '<STR_LIT:foo>' ) <EOL> self . topic_tag_db . topic_dir = '<STR_LIT:bar>' <EOL> self . assertEqual ( self . topic_tag_db . topic_dir , '<STR_LIT:bar>' ) <EOL> def test_index_file ( self ) : <EOL> self . topic_tag_db = TopicTagDB ( index_file = '<STR_LIT:foo>' ) <EOL> self . assertEqual ( self . topic_tag_db . index_file , '<STR_LIT:foo>' ) <EOL> self . topic_tag_db . index_file = '<STR_LIT:bar>' <EOL> self . assertEqual ( self . topic_tag_db . index_file , '<STR_LIT:bar>' ) <EOL> def test_get_all_topic_names ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> reference_topic_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> self . assertCountEqual ( self . topic_tag_db . get_all_topic_names ( ) , <EOL> reference_topic_list ) <EOL> def test_get_all_topic_source_files ( self ) : <EOL> source_files = [ ] <EOL> topic_dir = self . file_creator . rootdir <EOL> self . topic_tag_db = TopicTagDB ( topic_dir = topic_dir ) <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> topic_name = '<STR_LIT>' + str ( i ) <EOL> source_files . append ( self . file_creator . create_file ( topic_name , '<STR_LIT>' ) ) <EOL> self . assertCountEqual ( <EOL> self . topic_tag_db . get_all_topic_src_files ( ) , <EOL> source_files <EOL> ) <EOL> def test_get_all_topic_source_files_ignore_index ( self ) : <EOL> topic_filename = '<STR_LIT>' <EOL> index_filename = '<STR_LIT>' <EOL> source_files = [ ] <EOL> source_files . append ( self . file_creator . create_file ( topic_filename , '<STR_LIT>' ) ) <EOL> index_file = self . file_creator . create_file ( index_filename , '<STR_LIT>' ) <EOL> topic_dir = self . file_creator . rootdir <EOL> self . topic_tag_db = TopicTagDB ( index_file = index_file , <EOL> topic_dir = topic_dir ) <EOL> self . assertCountEqual ( <EOL> self . topic_tag_db . get_all_topic_src_files ( ) , <EOL> source_files <EOL> ) <EOL> def test_get_all_topic_source_files_ignore_hidden ( self ) : <EOL> topic_filename = '<STR_LIT>' <EOL> hidden_filename = '<STR_LIT:.>' + topic_filename <EOL> source_files = [ ] <EOL> source_files . append ( self . file_creator . create_file ( topic_filename , '<STR_LIT>' ) ) <EOL> self . file_creator . create_file ( hidden_filename , '<STR_LIT>' ) <EOL> topic_dir = self . file_creator . rootdir <EOL> self . topic_tag_db = TopicTagDB ( topic_dir = topic_dir ) <EOL> self . assertCountEqual ( <EOL> self . topic_tag_db . get_all_topic_src_files ( ) , <EOL> source_files <EOL> ) <EOL> def test_get_tag_value_all_tags ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT:title>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT>' ] ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT:description>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT>' ] ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT>' ] ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT>' ] ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT>' ] ) <EOL> def test_get_tag_multi_value ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT>' ) <EOL> self . assertEqual ( value , [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) <EOL> def test_get_tag_topic_no_exists ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_value ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( value , None ) <EOL> def test_get_tag_no_exist_tag ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_value ( topic_name , '<STR_LIT>' ) <EOL> self . assertEqual ( value , None ) <EOL> def test_get_tag_no_exist_use_default ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_value ( '<STR_LIT>' , '<STR_LIT>' , [ ] ) <EOL> self . assertEqual ( value , [ ] ) <EOL> def test_get_tag_single_value ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_single_value ( '<STR_LIT>' , '<STR_LIT:title>' ) <EOL> self . assertEqual ( value , '<STR_LIT:foo>' ) <EOL> def test_get_tag_single_value_exception ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> with self . assertRaises ( ValueError ) : <EOL> self . topic_tag_db . get_tag_single_value ( '<STR_LIT>' , '<STR_LIT:title>' ) <EOL> def test_get_tag_single_value_no_exists ( self ) : <EOL> topic_name = '<STR_LIT>' <EOL> tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> value = self . topic_tag_db . get_tag_single_value ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( value , None ) <EOL> def test_load_and_save_json_index ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> json_index = self . file_creator . create_file ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> tag_json = json . dumps ( tag_dict , indent = <NUM_LIT:4> , sort_keys = True ) <EOL> with open ( json_index , '<STR_LIT:w>' ) as f : <EOL> f . write ( tag_json ) <EOL> self . topic_tag_db = TopicTagDB ( index_file = json_index ) <EOL> self . topic_tag_db . load_json_index ( ) <EOL> saved_json_index = self . file_creator . create_file ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . topic_tag_db . index_file = saved_json_index <EOL> self . topic_tag_db . save_to_json_index ( ) <EOL> with open ( saved_json_index , '<STR_LIT:r>' ) as f : <EOL> self . assertEqual ( f . read ( ) , tag_json ) <EOL> class TestTopicTagDBQuery ( TestTopicTagDB ) : <EOL> def test_query_all_tags_single_topic ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT:title>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT:description>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> def test_query_tag_multi_values ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , '<STR_LIT:bar>' : [ '<STR_LIT>' ] } ) <EOL> def test_query_tag_multi_values ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , '<STR_LIT:bar>' : [ '<STR_LIT>' ] } ) <EOL> def test_query_multiple_topics ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:bar>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , '<STR_LIT:bar>' : [ '<STR_LIT>' ] } ) <EOL> def test_query_multiple_topics_with_multi_values ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , <EOL> { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , '<STR_LIT:bar>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] } ) <EOL> def test_query_multiple_topics_with_overlap_values ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:bar>' , '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertCountEqual ( <EOL> query_dict , { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:bar>' : [ '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> def test_query_with_limit_single_value ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:bar>' , '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' , [ '<STR_LIT:bar>' ] ) <EOL> self . assertCountEqual ( query_dict , <EOL> { '<STR_LIT:bar>' : [ '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> def test_query_with_limit_multi_value ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:bar>' , '<STR_LIT>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' , [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] ) <EOL> self . assertCountEqual ( query_dict , <EOL> { '<STR_LIT:foo>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:bar>' : [ '<STR_LIT>' , '<STR_LIT>' ] } ) <EOL> def topic_query_with_non_existant_tag ( self ) : <EOL> tag_dict = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : [ '<STR_LIT:foo>' ] <EOL> } <EOL> } <EOL> self . topic_tag_db = TopicTagDB ( tag_dict ) <EOL> query_dict = self . topic_tag_db . query ( '<STR_LIT>' ) <EOL> self . assertEqual ( query_dict , { } ) <EOL> class TestTopicDBScan ( TestTopicTagDB ) : <EOL> def create_topic_src_file ( self , topic_name , tags ) : <EOL> """<STR_LIT>""" <EOL> content = '<STR_LIT:\n>' . join ( tags ) <EOL> topic_name = topic_name + '<STR_LIT>' <EOL> topic_filepath = self . file_creator . create_file ( topic_name , content ) <EOL> return topic_filepath <EOL> def assert_json_index ( self , file_paths , reference_tag_dict ) : <EOL> """<STR_LIT>""" <EOL> json_index = self . file_creator . create_file ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . topic_tag_db = TopicTagDB ( index_file = json_index ) <EOL> self . topic_tag_db . scan ( file_paths ) <EOL> self . topic_tag_db . save_to_json_index ( ) <EOL> with open ( json_index , '<STR_LIT:r>' ) as f : <EOL> saved_index = json . loads ( f . read ( ) ) <EOL> self . assertEqual ( saved_index , reference_tag_dict ) <EOL> def test_scan_all_valid_tags ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_invalid_tag ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> with self . assertRaises ( ValueError ) : <EOL> self . topic_tag_db . scan ( [ topic_filepath ] ) <EOL> def test_scan_no_tags ( self ) : <EOL> tags = [ ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_multi_values ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_single_and_multi_values ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_multi_duplicate_values ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_multi_values_extra_space ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_multi_values_no_space ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_tags_with_multi_preserve_space ( self ) : <EOL> tags = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> topic_name = '<STR_LIT>' <EOL> reference_tag_dict = { <EOL> topic_name : { <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } <EOL> } <EOL> topic_filepath = self . create_topic_src_file ( topic_name , tags ) <EOL> self . assert_json_index ( [ topic_filepath ] , reference_tag_dict ) <EOL> def test_scan_multiple_files ( self ) : <EOL> topic_base = '<STR_LIT>' <EOL> reference_tag_dict = { } <EOL> topic_files = [ ] <EOL> for i in range ( <NUM_LIT:5> ) : <EOL> topic_name = topic_base + '<STR_LIT:->' + str ( i ) <EOL> tags = [ <EOL> '<STR_LIT>' % topic_name , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> reference_tag_dict [ topic_name ] = { <EOL> '<STR_LIT:description>' : [ '<STR_LIT>' % topic_name ] , <EOL> '<STR_LIT:title>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> topic_files . append ( self . create_topic_src_file ( topic_name , tags ) ) <EOL> self . assert_json_index ( topic_files , reference_tag_dict ) </s>
