### Setup for Beets Logging Level Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 4.txt The `setUp` method for `LoggingLevelTest` prepares the environment for testing logging levels within Beets. It dynamically adds a dummy module and plugin to `sys.modules` and `beetsplug`, sets up the basic Beets test environment using `self.setup_beets()`, and loads the dummy plugin using `self.load_plugins()`, making it available for testing. ```python def setUp(self): sys.modules['beetsplug.dummy'] = self.DummyModule beetsplug.dummy = self.DummyModule self.setup_beets() self.load_plugins('dummy') ``` -------------------------------- ### Implement Custom Setuptools Build Static Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Defines a custom setuptools command `BuildStatic` responsible for building client-side static assets. It initializes git submodules, runs `npm install` to fetch frontend dependencies, and then executes the `gulp dist` command to build the assets. ```python class BuildStatic(Command): user_options = [ ('work-path=', 'w', "The working directory for source files. Defaults to ."), ] def initialize_options(self): self.work_path = None def finalize_options(self): if self.work_path is None: self.work_path = ROOT def run(self): work_path = self.work_path log.info("initializing git submodules") check_output(['git', 'submodule', 'init'], cwd=work_path) check_output(['git', 'submodule', 'update'], cwd=work_path) log.info("running [npm install --quiet]") check_output(['npm', 'install', '--quiet'], cwd=work_path) log.info("running [gulp dist]") check_output([os.path.join('node_modules', '.bin', 'gulp'), 'dist'], cwd=work_path) ``` -------------------------------- ### Implement Custom Setuptools Develop Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Defines a custom setuptools command `DevelopWithBuildStatic` that inherits from `setuptools.command.develop`. Its `install_for_development` method is overridden to execute the custom `build_static` command before the standard development installation process. ```python class DevelopWithBuildStatic(develop): def install_for_development(self): self.run_command('build_static') return develop.install_for_development(self) ``` -------------------------------- ### Implement Custom Setuptools Install Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Defines a custom setuptools command `SmartInstall` that inherits from `setuptools.command.install`. It checks if static assets have already been built and runs the `build_static` command if they are missing before proceeding with the standard installation process. ```python class SmartInstall(install): """ Installs Sentry into the Python environment. If the package indicator is missing, this will also force a run of `build_static` which is required for JavaScript assets and other things. """ def _needs_static(self): return not os.path.exists(os.path.join(ROOT, 'sentry-package.json')) def run(self): if self._needs_static(): self.run_command('build_static') install.run(self) ``` -------------------------------- ### Setup File System Art Source Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt Sets up the testing environment for the `FileSystem` art source tests. It creates a temporary directory to simulate an album directory and initializes the `fetchart.FileSystem` source. ```python class FSArtTest(_common.TestCase): def setUp(self): super(FSArtTest, self).setUp() self.dpath = os.path.join(self.temp_dir, 'arttest') os.mkdir(self.dpath) self.source = fetchart.FileSystem(logger) ``` -------------------------------- ### Setup Beets Fetchart Plugin Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt Sets up the testing environment for beets fetchart plugin tests. It initializes the `FetchArtPlugin` instance which is used by subsequent test cases. ```python class UseThePlugin(_common.TestCase): def setUp(self): super(UseThePlugin, self).setUp() self.plugin = fetchart.FetchArtPlugin() ``` -------------------------------- ### Setup for Beets Concurrent Logging Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 4.txt The `setUp` method for `ConcurrentEventsTest` prepares the test environment. It initializes the Beets test framework using `self.setup_beets()`, specifically enabling disk access which might be relevant for certain test configurations, although not directly used in the concurrent logging test itself. ```python def setUp(self): self.setup_beets(disk=True) ``` -------------------------------- ### Define Core Installation Dependencies Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Lists the main set of Python package dependencies (`install_requires`) necessary for the Sentry application to function. This includes core web frameworks (Django, DRF), background task processing (Celery), caching (redis, memcached), and various utility libraries. ```python install_requires = [ 'BeautifulSoup>=3.2.1,<3.3.0', 'celery>=3.1.8,<3.2.0', 'cssutils>=0.9.9,<0.10.0', 'Django>=1.6.0,<1.7', 'django-bitfield>=1.7.0,<1.8.0', 'django-crispy-forms>=1.4.0,<1.5.0', 'django-paging>=0.2.5,<0.3.0', 'django-jsonfield>=0.9.13,<0.10.0', 'django-picklefield>=0.3.0,<0.4.0', 'django-recaptcha>=1.0.0,<1.1.0', 'django-social-auth>=0.7.28,<0.8.0', 'django-statsd-mozilla>=0.3.14.0,<0.3.15.0', 'django-sudo>=1.1.3,<1.2.0', 'django-templatetag-sugar>=0.1.0', 'djangorestframework>=2.3.8,<2.4.0', 'email-reply-parser>=0.2.0,<0.3.0', 'enum34>=0.9.18,<0.10.0', 'exam>=0.5.1', 'gunicorn>=19.2.1,<20.0.0', 'ipaddr>=2.1.11,<2.2.0', 'logan>=0.7.1,<0.8.0', 'lxml>=3.4.1', 'mock>=0.8.0', 'nydus>=0.11.0,<0.12.0', 'markdown>=2.4.1,<2.5.0', 'petname>=1.7,<1.8', 'progressbar>=2.2,<2.4', 'pytest', 'pytest-django', 'python-dateutil>=2.0.0,<3.0.0', 'python-memcached>=1.53,<2.0.0', 'raven>=5.3.0', 'redis>=2.7.0,<2.11.0', 'requests[security]>=2.5.1,<2.6.0', 'simplejson>=3.1.0,<3.4.0', 'six>=1.6.0,<2.0.0', 'setproctitle>=1.1.7,<1.2.0', 'statsd>=3.1.0,<3.2.0', 'South==1.0.1', 'toronado>=0.0.4,<0.1.0', 'ua-parser>=0.3.5', 'urllib3>=1.7.1,<1.8.0', ] ``` -------------------------------- ### Setup Art Importer Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt Sets up the testing environment for tests involving the importer's interaction with art fetching. It mocks the plugin's `art_for_album` method to return a predefined file and sets up a dummy beets library. ```python class ArtImporterTest(UseThePlugin): def setUp(self): super(ArtImporterTest, self).setUp() # Mock the album art fetcher to always return our test file. self.art_file = os.path.join(self.temp_dir, 'tmpcover.jpg') _common.touch(self.art_file) self.old_afa = self.plugin.art_for_album self.afa_response = self.art_file def art_for_album(i, p, local_only=False): return self.afa_response self.plugin.art_for_album = art_for_album # Test library. self.libpath = os.path.join(self.temp_dir, 'tmplib.blb') self.libdir = os.path.join(self.temp_dir, 'tmplib') os.mkdir(self.libdir) ``` -------------------------------- ### Setup Combined Art Source Tests - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt Sets up the testing environment for tests that combine multiple art sources. It creates a temporary directory for filesystem tests and defines URLs/IDs for mocking network requests. ```python class CombinedTest(UseThePlugin): ASIN = 'xxxx' MBID = 'releaseid' AMAZON_URL = 'http://images.amazon.com/images/P/{0}.01.LZZZZZZZ.jpg' \ .format(ASIN) AAO_URL = 'http://www.albumart.org/index_detail.php?asin={0}' \ .format(ASIN) CAA_URL = 'http://coverartarchive.org/release/{0}/front' \ .format(MBID) def setUp(self): super(CombinedTest, self).setUp() self.dpath = os.path.join(self.temp_dir, 'arttest') os.mkdir(self.dpath) ``` -------------------------------- ### Define Development Dependencies Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Defines a list of Python package dependencies (`dev_requires`) specifically needed for development tasks, such as code linting. This list is used in the `extras_require` argument of the `setup()` function. ```python dev_requires = [ 'flake8>=2.0,<2.1', ] ``` -------------------------------- ### Define MySQL Dependencies Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Lists the Python package dependency (`mysql_requires`) needed for connecting Sentry to a MySQL database. This list is intended to be combined with `install_requires` for a full set of dependencies. ```python mysql_requires = [ 'MySQL-python>=1.2.0,<1.3.0', ] ``` -------------------------------- ### Define PyPy PostgreSQL Dependencies Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Lists the Python package dependency (`postgres_pypy_requires`) needed for connecting Sentry to a PostgreSQL database when running on the PyPy interpreter. This uses the CFFI-based driver. ```python postgres_pypy_requires = [ 'psycopg2cffi', ] ``` -------------------------------- ### Implement Custom Setuptools Sdist Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Defines a custom setuptools command `SdistWithBuildStatic` that inherits from `setuptools.command.sdist`. It overrides `make_release_tree` to run the `build_static` command within the temporary source distribution directory and adds a metadata file (`sentry-package.json`) before packaging. ```python class SdistWithBuildStatic(sdist): def make_release_tree(self, *a, **kw): dist_path = self.distribution.get_fullname() sdist.make_release_tree(self, *a, **kw) self.reinitialize_command('build_static', work_path=dist_path) self.run_command('build_static') with open(os.path.join(dist_path, 'sentry-package.json'), 'w') as fp: json.dump({ 'createdAt': datetime.datetime.utcnow().isoformat() + 'Z', }, fp) ``` -------------------------------- ### Define PostgreSQL Dependencies Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt Lists the Python package dependency (`postgres_requires`) needed for connecting Sentry to a PostgreSQL database using the standard C-based driver. This list is intended to be combined with `install_requires` for a full set of dependencies. ```python postgres_requires = [ 'psycopg2>=2.5.0,<2.6.0', ] ``` -------------------------------- ### Configure Sentry Package Setuptools Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 2.txt The main call to the `setuptools.setup` function, configuring the Sentry package. It defines metadata like name, version, author, description, specifies package discovery, lists dependencies (including optional extras), maps custom command classes, and defines console script entry points. ```python setup( name='sentry', version='7.7.0.dev0', author='David Cramer', author_email='dcramer@gmail.com', url='https://www.getsentry.com', description='A realtime logging and aggregation server.', long_description=open('README.rst').read(), package_dir={'': 'src'}, packages=find_packages('src'), zip_safe=False, install_requires=install_requires, extras_require={ 'tests': tests_require, 'dev': dev_requires, 'postgres': install_requires + postgres_requires, 'postgres_pypy': install_requires + postgres_pypy_requires, 'mysql': install_requires + mysql_requires, }, cmdclass={ 'build_static': BuildStatic, 'develop': DevelopWithBuildStatic, 'sdist': SdistWithBuildStatic, 'install': SmartInstall, }, license='BSD', include_package_data=True, entry_points={ 'console_scripts': [ 'sentry = sentry.utils.runner:main', ], }, classifiers=[ 'Framework :: Django', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Operating System :: OS Independent', 'Topic :: Software Development' ], ) ``` -------------------------------- ### Implementing Agility.js Persist load() Method - JavaScript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Adds a `load` method to objects using the `persist` plugin. It sends a `GET` request using the model's ID to the configured adapter to fetch data. It requires the model to have an ID, triggers `persist:start`/`stop` based on open requests, updates the model on success, and triggers `persist:load:success`/`persist:error`/`persist:load:error` events. ```javascript this.load = function(){ var self = this; if (this.model.get(id) === undefined) throw 'agility.js: load() needs model id'; if (this._data.persist.openRequests === 0) { this.trigger('persist:start'); } this._data.persist.openRequests++; this._data.persist.adapter.call(this, { type: 'GET', id: this.model.get(id), complete: function(){ self._data.persist.openRequests--; if (self._data.persist.openRequests === 0) { self.trigger('persist:stop'); } }, success: function(data, textStatus, jqXHR){ self.model.set(data); self.trigger('persist:load:success'); }, error: function(){ self.trigger('persist:error'); self.trigger('persist:load:error'); } }); return this; // for chainable calls }; // load() ``` -------------------------------- ### Initializing Handbook Dependencies JavaScript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 5.txt This snippet initializes the necessary Node.js built-in modules (`path`, `fs`), external libraries (`natural` for NLP, `lunr` for search), defines a word tokenizer, sets the base directory for content files, and establishes regular expressions used for scraping metadata from the Markdown content. ```JavaScript 'use strict'; var path = require('path'), fs = require('fs'), natural = require('natural'), lunr = require('lunr'), tokenizer = new natural.WordTokenizer(), loc = path.resolve(__dirname, 'content'), scraper = { title: /\[meta:title\]:\s<>\s\((.+?)\)(?!\))/ , description: /\[meta:description\]:\s<>\s\((.+?)\)(?!\))/ , firstlines: /^((.*\n){2}){1,3}/ }; ``` -------------------------------- ### Get Container Size Shortcut - Javascript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Provides a shortcut method to get the size of the object's container element(s). It applies the arguments to the container's `size` method and returns its result. ```javascript size: function(){ return this._container.size.apply(this, arguments); }, ``` -------------------------------- ### Setting Up Art Importer Test Environment (Python) Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt This snippet sets up the environment for testing the album art importer. It creates the necessary directory structure, copies a test audio file, initializes the library and importer session/task, and prepares a mock album information object and match. ```python os.mkdir(os.path.join(self.libdir, 'album')) itempath = os.path.join(self.libdir, 'album', 'test.mp3') shutil.copyfile(os.path.join(_common.RSRC, 'full.mp3'), itempath) self.lib = library.Library(self.libpath) self.i = _common.item() self.i.path = itempath self.album = self.lib.add_album([self.i]) self.lib._connection().commit() # The import configuration. self.session = _common.import_session(self.lib) # Import task for the coroutine. self.task = importer.ImportTask(None, None, [self.i]) self.task.is_album = True self.task.album = self.album info = AlbumInfo( album='some album', album_id='albumid', artist='some artist', artist_id='artistid', tracks=[], ) self.task.set_choice(AlbumMatch(0, info, {}, set(), set())) ``` -------------------------------- ### Retina Image Handling for Gilding Examples CSS Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/css/new 8.txt Uses a media query to provide higher resolution background images for the gilding examples (userpage, comment, using creddits) on retina displays. ```css @media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){.gold-page.gilding .example figure.userpage-gild{background:url('../gold/userpage-gild-x2.png') no-repeat center center;background-size:339px 227px}.gold-page.gilding .example figure.comment-gild{background:url('../gold/comment-gild-x2.png') no-repeat top left;background-size:339px 160px}.gold-page.gilding .example figure.using-creddits{background:url('../gold/using-creddits-x2.png') no-repeat top left;background-size:339px 90px}} ``` -------------------------------- ### Setting Up Art For Album Test Environment (Python) Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt This snippet sets up the environment for testing the `art_for_album` method specifically, focusing on size/ratio constraints. It mocks helper methods (`fs_source.get`, `_fetch_image`, `_source_urls`) to control the image file path returned. ```python super(ArtForAlbumTest, self).setUp() self.old_fs_source_get = self.plugin.fs_source.get self.old_fetch_img = self.plugin._fetch_image self.old_source_urls = self.plugin._source_urls def fs_source_get(*_): return self.image_file def source_urls(_): return [''] def fetch_img(_): return self.image_file self.plugin.fs_source.get = fs_source_get self.plugin._source_urls = source_urls self.plugin._fetch_image = fetch_img ``` -------------------------------- ### Get Parent Object - Javascript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Provides a shortcut to access the parent object in the hierarchy. It returns the object stored in the internal `_parent` property. ```javascript parent: function(){ return this._parent; }, ``` -------------------------------- ### Constructing Handbook Instance JavaScript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 5.txt The constructor function for the `Handbook` class. Upon instantiation, it synchronously walks the configured content directory (`loc`) using `walkSync` to build the table of contents (`toc`) and a cache of all documents (`cache`). It also initializes a `lunr` search index (`idx`) and populates it with the title and body content of all documents. ```JavaScript // // ### function Handbook() // Constructor for easy access to Handbook content. On constructuing handbook // synchronously prepare the search index. Listening to a search index ready // event is not required thus easing the flow. // function Handbook() { var toc = this.index = walkSync(loc), cache = this.cache = {}, idx = this.idx = lunr(function setupLunr() { this.field('title', { boost: 10 }); this.field('body'); }); Object.keys(toc).forEach(function loopSections(section) { Object.keys(toc[section]).forEach(function loopPages(page) { var document = read((section !== 'index' ? section + '/' : '') + page) , id = section + '/' + page; idx.add({ id: id, title: document.title, body: document.content }); // // Keep cached reference of all documents, for quick external access. // cache[id] = document; }); }); } ``` -------------------------------- ### Getting Model Size in Agility.js Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Returns the number of properties or attributes currently present in the model data object. It uses a utility function `util.size` to calculate the size. ```javascript size: function(){ return util.size(this.model._data); }, ``` -------------------------------- ### Test Thread-Local Logging Levels in Concurrent Events - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 4.txt This test validates that logger levels are thread-local for Beets loggers (`blog.BeetsLogger`) when handling concurrent events. It starts two threads, each running a dummy event listener configured via `verbose` to expect different logging levels (INFO and DEBUG). Using locks, the test controls thread execution to change the global `verbose` level *between* the threads starting and asserting their initial level. It verifies that each thread maintains its expected logger level, demonstrating thread-local behavior, and then releases locks to allow threads to complete. ```python def test_concurrent_events(self): dp = self.DummyPlugin(self) def check_dp_exc(): if dp.exc_info: raise dp.exc_info[1], None, dp.exc_info[2] try: dp.lock1.acquire() dp.lock2.acquire() self.assertEqual(dp._log.level, log.NOTSET) self.config['verbose'] = 1 t1 = threading.Thread(target=dp.listeners['dummy_event1'][0]) t1.start() # blocked. t1 tested its log level while dp.t1_step != 1: check_dp_exc() self.assertTrue(t1.is_alive()) self.assertEqual(dp._log.level, log.NOTSET) self.config['verbose'] = 2 t2 = threading.Thread(target=dp.listeners['dummy_event2'][0]) t2.start() # blocked. t2 tested its log level while dp.t2_step != 1: check_dp_exc() self.assertTrue(t2.is_alive()) self.assertEqual(dp._log.level, log.NOTSET) dp.lock1.release() # dummy_event1 tests its log level + finishes while dp.t1_step != 2: check_dp_exc() t1.join(.1) self.assertFalse(t1.is_alive()) self.assertTrue(t2.is_alive()) self.assertEqual(dp._log.level, log.NOTSET) dp.lock2.release() # dummy_event2 tests its log level + finishes while dp.t2_step != 2: check_dp_exc() t2.join(.1) self.assertFalse(t2.is_alive()) except: print("Alive threads:", threading.enumerate()) if dp.lock1.locked(): print("Releasing lock1 after exception in test") dp.lock1.release() if dp.lock2.locked(): print("Releasing lock2 after exception in test") dp.lock2.release() print("Alive threads:", threading.enumerate()) raise ``` -------------------------------- ### Running Unit Tests Main Entry Point (Python) Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt This is the standard Python entry point (`if __name__ == '__main__':`) for running unit tests directly from the script. It calls `unittest.main`, specifying the 'suite' function to load tests. ```python if __name__ == b'__main__': unittest.main(defaultTest='suite') ``` -------------------------------- ### Bootstrapping Agility.js Object Initialization - JavaScript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Performs post-parsing setup for the Agility.js object. This includes saving the model's initial state for later reset, proxying methods to ensure `this` refers to the object instance, and rendering the view to initialize the DOM representation (`$root`). Requires jQuery for `$.extend` and Agility.js utility functions like `util.proxyAll`. ```javascript // Save model's initial state (so it can be .reset() later) object.model._initData = $.extend({}, object.model._data); // object.* will have their 'this' === object. This should come before call to object.* below. util.proxyAll(object, object); // Initialize $root, needed for DOM events binding below object.view.render(); ``` -------------------------------- ### Defining UpServer Constructor JavaScript Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 3.txt Defines the main constructor function for `UpServer`. It initializes instance properties based on provided options and defaults, sets up the inheritance from `Distributor`, and immediately begins spawning the configured number of workers. ```JavaScript function UpServer (server, file, options) { if (this == global) return new UpServer(server, file, options); Distributor.call(this, server); var self = this; options = options || {}; this.file = file; this.numWorkers = eq(options.numWorkers || numWorkers, { cpus: cpus }); this.workerTimeout = ms(null != options.workerTimeout ? options.workerTimeout : workerTimeout); this.requires = options.requires || []; this.assumeReady = options.assumeReady === undefined ? true : !!options.assumeReady; this.keepAlive = options.keepAlive || false; this.minExpectedLifetime = ms(options.minExpectedLifetime != null ? options.minExpectedLifetime : minExpectedLifetime); if (false !== options.workerPingInterval) { this.workerPingInterval = ms(options.workerPingInterval || '1m'); } this.workers = []; this.spawning = []; this.lastIndex = -1; if (options.title) { this.title = options.title; process.title = this.title + ' master'; } // setup workers this.spawnWorkers(this.numWorkers); }; ``` -------------------------------- ### Getting Model Attributes in Agility.js Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/javascript/new 2.txt Retrieves model attributes. If no argument is provided, it returns the entire model data object. If a string argument is provided, it returns the value of the corresponding model attribute. Throws an error for unknown argument types. ```javascript get: function(arg){ // Full model getter if (arg === undefined) { return this.model._data; } // Attribute getter if (typeof arg === 'string') { return this.model._data[arg]; } throw 'agility.js: unknown argument for getter'; }, ``` -------------------------------- ### Test Combined Source Prioritizes File System Art - Python Source: https://github.com/kbiakov/codeview-android/blob/master/codeview/src/main/assets/training-set/python/new 3.txt Tests that the `art_for_album` method checks the file system source before online sources when a path is provided. It creates a file system art file and mocks an Amazon response, asserting that the file system path is returned. ```python class CombinedTest(UseThePlugin): # ... setUp method ... # ... mock_response method ... # ... run method ... def test_main_interface_gives_precedence_to_fs_art(self): _common.touch(os.path.join(self.dpath, 'art.jpg')) self.mock_response(self.AMAZON_URL) album = _common.Bag(asin=self.ASIN) artpath = self.plugin.art_for_album(album, [self.dpath]) self.assertEqual(artpath, os.path.join(self.dpath, 'art.jpg')) ```