def create(self): """Create new content.""" self._logger.debug('creating new: %s', self._category) collection = Config.get_collection() collection = self._storage.create(collection) self.collection.migrate(collection)
def test_config_create_001(mock_utcnow): """Create new snippet. Test default values when only mandatory arguments are used. """ mock_utcnow.return_value = '2018-02-17 13:23:43' Config.init(None) Config.load(Cli(['snippy', 'import'])) assert isinstance(Config.content_category, Const.TEXT_TYPE) assert isinstance(Config.content_data, tuple) assert isinstance(Config.content_brief, Const.TEXT_TYPE) assert isinstance(Config.content_description, Const.TEXT_TYPE) assert isinstance(Config.content_groups, tuple) assert isinstance(Config.content_tags, tuple) assert isinstance(Config.content_links, tuple) assert isinstance(Config.content_name, Const.TEXT_TYPE) assert isinstance(Config.content_filename, Const.TEXT_TYPE) assert isinstance(Config.content_versions, tuple) assert isinstance(Config.content_source, Const.TEXT_TYPE) assert isinstance(Config.operation_digest, type(None)) assert isinstance(Config.search_cat_kws, tuple) assert isinstance(Config.search_all_kws, tuple) assert isinstance(Config.search_tag_kws, tuple) assert isinstance(Config.search_grp_kws, tuple) assert Config.search_filter is None assert Config.search_limit == 99 assert Config.search_offset == 0 assert Config.remove_fields == () assert Config.sort_fields == OrderedDict([('brief', 'ASC')]) assert isinstance(Config.get_operation_file(), Const.TEXT_TYPE) assert not Config.get_resource(None) assert not Config.get_collection() assert not Config.is_operation_create assert not Config.is_operation_search assert not Config.is_operation_update assert not Config.is_operation_delete assert not Config.is_operation_export assert Config.is_operation_import assert Config.is_category_snippet assert not Config.is_category_solution assert not Config.is_category_reference assert not Config.is_multi_category assert Config.content_category == Const.SNIPPET assert not Config.content_data assert not Config.content_brief assert Config.content_groups == Const.DEFAULT_GROUPS assert not Config.content_tags assert not Config.content_links assert not Config.search_all_kws assert not Config.search_tag_kws assert not Config.search_grp_kws assert Config.operation_digest is None assert not Config.search_filter assert not Config.content_filename assert not Config.editor assert Config.get_operation_file() == './snippets.mkdn' assert Config.is_operation_file_mkdn assert not Config.is_operation_file_json assert not Config.is_operation_file_yaml assert not Config.is_operation_file_text assert Config.use_ansi