def test_absolute_root_path(self): """ Test using an absolute path to BOWER_COMPONENTS_ROOT Copies the existing bower_components folder to 'bower_components_alt' Sets the absolute path to the new directory as BOWER_COMPONENTS_ROOT Validates that url_for continues to work & tests calling get on the provided URL. """ alt_dir = os.path.abspath(os.path.join(os.path.curdir, 'tests', 'bower_components_alt')) shutil.move(os.path.abspath(os.path.join(os.path.curdir, 'tests', 'bower_components')), alt_dir) self.app.config['BOWER_COMPONENTS_ROOT'] = alt_dir Bower(self.app) with self.app.app_context(): self.assertEqual(bower_url_for('jquery', 'dist/jquery.js'), "http://unit.test/bower/jquery/dist/jquery.min.js?version=2.1.3") url = bower_url_for('jquery', 'dist/jquery.js') client = self.app.test_client() self.assertEqual(client.get(url).status_code, 200) # move files back to leave it clean shutil.move(alt_dir, os.path.abspath(os.path.join(os.path.curdir, 'tests', 'bower_components')))
def test_bower_url_for(self): """ Test of the bower_url_for function """ Bower(self.app) with self.app.app_context(): self.assertEqual(bower_url_for('jquery', 'dist/jquery.js'), "http://unit.test/bower/jquery/dist/jquery.min.js?version=2.1.3")
def test_bower_subdomain(self): """ Test the flask blueprint subdomain configuration """ self.app.config['BOWER_SUBDOMAIN'] = 'static' Bower(self.app) with self.app.app_context(): self.assertEqual(bower_url_for('jquery', 'dist/jquery.js'), "http://static.unit.test/bower/jquery/dist/jquery.min.js?version=2.1.3")
def test_bower_url_for_no_revving(self): """ Test the BOWER_QUERYSTRING_REVVING parameter """ self.app.config['BOWER_QUERYSTRING_REVVING'] = False Bower(self.app) with self.app.app_context(): self.assertEqual(bower_url_for('jquery', 'dist/jquery.js'), "http://unit.test/bower/jquery/dist/jquery.min.js")