def setup_content_paths(context, db): """ Creaters available content items and adds their urls to the context object. :param context: A behave context, to which the attributes "available_content_path" and "unavailable_content_path" will be added. :return: None """ # These paths are "magic" -- the success or failure of actually visiting the content items in the browser # depends on these specific values. context.unavailable_content_path, context.available_content_path = ( "khan/foo/bar/unavail", "khan/math/arithmetic/addition-subtraction/basic_addition/addition_1/", ) # This function uses 'iterator_content_items' function to return a list of path, update dict pairs # It then updates the items with these paths with their update dicts, and then propagates # availability changes up the topic tree - this means that we can alter the availability of one item # and make all its parent topics available so that it is navigable to in integration tests. def iterator_content_items(ids=None, channel="khan", language="en"): return [(context.available_content_path, {"available": True})] annotate_content_models(db=db, iterator_content_items=iterator_content_items) with Using(db, [Item], with_transaction=False): context._unavailable_item = Item.create( title="Unavailable item", description="baz", available=False, kind="Video", id="3", slug="unavail", path=context.unavailable_content_path )
def setup_content_paths(context, db): """ Creaters available content items and adds their urls to the context object. :param context: A behave context, to which the attributes "available_content_path" and "unavailable_content_path" will be added. :return: None """ # These paths are "magic" -- the success or failure of actually visiting the content items in the browser # depends on these specific values. context.unavailable_content_path, context.available_content_path = ( "khan/foo/bar/unavail", "khan/math/arithmetic/addition-subtraction/basic_addition/addition_1/", ) # This function uses 'iterator_content_items' function to return a list of path, update dict pairs # It then updates the items with these paths with their update dicts, and then propagates # availability changes up the topic tree - this means that we can alter the availability of one item # and make all its parent topics available so that it is navigable to in integration tests. def iterator_content_items(ids=None, channel="khan", language="en"): return [(context.available_content_path, {"available": True})] annotate_content_models(db=db, iterator_content_items=iterator_content_items) with Using(db, [Item], with_transaction=False): context._unavailable_item = Item.create( title="Unavailable item", description="baz", available=False, kind="Video", id="3", slug="unavail", path=context.unavailable_content_path)
def handle(self, *args, **kwargs): language = kwargs["language"] channel = kwargs["channel"] # temporarily swap out the database path for the desired target database_path = kwargs["database_path"] or CONTENT_DATABASE_PATH.format(channel=channel, language=language) logging.info("Annotating content for language: {language}, channel: {channel}".format( language=language, channel=channel)) annotate_content_models(database_path=database_path, channel=channel, language=language) logging.info("Annotation complete for language: {language}, channel: {channel}".format( language=language, channel=channel))
def handle(self, *args, **kwargs): language = kwargs["language"] channel = kwargs["channel"] # temporarily swap out the database path for the desired target database_path = kwargs[ "database_path"] or CONTENT_DATABASE_PATH.format(channel=channel, language=language) logging.info( "Annotating content for language: {language}, channel: {channel}". format(language=language, channel=channel)) annotate_content_models(database_path=database_path, channel=channel, language=language) logging.info( "Annotation complete for language: {language}, channel: {channel}". format(language=language, channel=channel))
def handle(self, *args, **kwargs): language = kwargs["language"] channel = kwargs["channel"] # temporarily swap out the database path for the desired target database_path = kwargs[ "database_path"] or CONTENT_DATABASE_PATH.format(channel=channel, language=language) logging.info(( "Annotating content for language: {language}, channel: {channel}\n\n" "This may take several minutes depending on system resources..." ).format(language=language, channel=channel)) annotate_content_models(database_path=database_path, channel=channel, language=language) logging.info( "Annotation complete for language: {language}, channel: {channel}". format(language=language, channel=channel))
def handle(self, *args, **kwargs): language = kwargs["language"] channel = kwargs["channel"] # temporarily swap out the database path for the desired target database_path = kwargs["database_path"] or CONTENT_DATABASE_PATH.format(channel=channel, language=language) logging.info( ( "Annotating content for language: {language}, channel: {channel}\n\n" "This may take several minutes depending on system resources..." ).format( language=language, channel=channel ) ) annotate_content_models(database_path=database_path, channel=channel, language=language) logging.info("Annotation complete for language: {language}, channel: {channel}".format( language=language, channel=channel))