本文整理汇总了Python中awscli.topictags.TopicTagDB.get_tag_value方法的典型用法代码示例。如果您正苦于以下问题:Python TopicTagDB.get_tag_value方法的具体用法?Python TopicTagDB.get_tag_value怎么用?Python TopicTagDB.get_tag_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类awscli.topictags.TopicTagDB
的用法示例。
在下文中一共展示了TopicTagDB.get_tag_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTopicTagDBGeneral
# 需要导入模块: from awscli.topictags import TopicTagDB [as 别名]
# 或者: from awscli.topictags.TopicTagDB import get_tag_value [as 别名]
class TestTopicTagDBGeneral(TestTopicTagDB):
def test_valid_tags(self):
self.assertCountEqual(
self.topic_tag_db.valid_tags,
['title', 'description', 'category', 'related command',
'related topic']
)
def test_topic_dir(self):
self.topic_tag_db = TopicTagDB(topic_dir='foo')
self.assertEqual(self.topic_tag_db.topic_dir, 'foo')
self.topic_tag_db.topic_dir = 'bar'
self.assertEqual(self.topic_tag_db.topic_dir, 'bar')
def test_index_file(self):
self.topic_tag_db = TopicTagDB(index_file='foo')
self.assertEqual(self.topic_tag_db.index_file, 'foo')
self.topic_tag_db.index_file = 'bar'
self.assertEqual(self.topic_tag_db.index_file, 'bar')
def test_get_all_topic_names(self):
tag_dict = {
'topic-name-1': {
'title': ['My First Topic Title'],
},
'topic-name-2': {
'title': ['My Second Topic Title'],
}
}
reference_topic_list = ['topic-name-1', 'topic-name-2']
self.topic_tag_db = TopicTagDB(tag_dict)
self.assertCountEqual(self.topic_tag_db.get_all_topic_names(),
reference_topic_list)
def test_get_all_topic_source_files(self):
source_files = []
topic_dir = self.file_creator.rootdir
self.topic_tag_db = TopicTagDB(topic_dir=topic_dir)
for i in range(5):
topic_name = 'topic-name-' + str(i)
source_files.append(self.file_creator.create_file(topic_name, ''))
self.assertCountEqual(
self.topic_tag_db.get_all_topic_src_files(),
source_files
)
def test_get_all_topic_source_files_ignore_index(self):
topic_filename = 'mytopic'
index_filename = 'topic-tags.json'
source_files = []
source_files.append(self.file_creator.create_file(topic_filename, ''))
index_file = self.file_creator.create_file(index_filename, '')
topic_dir = self.file_creator.rootdir
self.topic_tag_db = TopicTagDB(index_file=index_file,
topic_dir=topic_dir)
self.assertCountEqual(
self.topic_tag_db.get_all_topic_src_files(),
source_files
)
def test_get_all_topic_source_files_ignore_hidden(self):
topic_filename = 'mytopic'
hidden_filename = '.' + topic_filename
source_files = []
source_files.append(self.file_creator.create_file(topic_filename, ''))
self.file_creator.create_file(hidden_filename, '')
topic_dir = self.file_creator.rootdir
self.topic_tag_db = TopicTagDB(topic_dir=topic_dir)
self.assertCountEqual(
self.topic_tag_db.get_all_topic_src_files(),
source_files
)
def test_get_tag_value_all_tags(self):
topic_name = 'topic-name-1'
tag_dict = {
topic_name: {
'title': ['My First Topic Title'],
'description': ['This describes my first topic'],
'category': ['General Topics'],
'related command': ['aws s3'],
'related topic': ['topic-name-2']
}
}
self.topic_tag_db = TopicTagDB(tag_dict)
# Check the title get tag value
value = self.topic_tag_db.get_tag_value(topic_name, 'title')
self.assertEqual(value, ['My First Topic Title'])
# Check the description get tag value
value = self.topic_tag_db.get_tag_value(topic_name, 'description')
self.assertEqual(value, ['This describes my first topic'])
# Check the category get tag value
value = self.topic_tag_db.get_tag_value(topic_name, 'category')
self.assertEqual(value, ['General Topics'])
# Check the related command get tag value
#.........这里部分代码省略.........