def test_settings_can_write_to_file(self): s = Settings() s['testkey1'] = "testvalue1" s['testkey2'] = "testvalue2" savepath = "./assetman/tests/test_settings" s.save(path=savepath) try: with open(savepath, 'r') as saved_file: assert saved_file, "file not found, save failed" settings_dict = json.loads(saved_file.read()) for k, v in settings_dict.items(): assert s[k] == v except Exception, ex: self.fail(str(ex))
def _create_settings(options): return Settings(compiled_asset_root=options.output_dir, static_dir=options.static_dir, static_url_prefix=options.static_url_path, tornado_template_dirs=options.tornado_template_dirs, django_template_dirs=options.django_template_dirs, template_extension=options.template_ext, test_needs_compile=options.test_needs_compile, skip_s3_upload=options.skip_s3_upload, force_s3_upload=False, force_recompile=options.force_recompile, skip_inline_images=options.skip_inline_images, aws_username=options.aws_username, aws_access_key=options.aws_access_key, aws_secret_key=options.aws_secret_key, verbose=False, s3_assets_bucket=options.s3_assets_bucket)
def test_settings_can_load_from_file(self): settings_stub = { 'testkey1': "testvalue1", 'testkey2': "testvalue2", "lessc_path" : "asdf", "sass_compiler": "asdf", "minify_compressor_path": "asdf", "closure_compiler": "asdf" } savepath = "./assetman/tests/test_settings" with open(savepath, 'w') as saved_file: saved_file.write(json.dumps(settings_stub)) s = Settings.load(savepath) assert s is not None for k, v in s.items(): assert settings_stub[k] == v
def test_settings_can_load_from_file(self): settings_stub = { 'testkey1': "testvalue1", 'testkey2': "testvalue2", "lessc_path" : "asdf", "sass_compiler": "asdf", "yui_compressor_path": "asdf", "closure_compiler": "asdf" } savepath = "./assetman/tests/test_settings" with open(savepath, 'w') as saved_file: saved_file.write(json.dumps(settings_stub)) s = Settings.load(savepath) assert s is not None for k, v in s.items(): assert settings_stub[k] == v
def get_settings(**opts): logging.info('temp dir %s', COMPILED_ASSET_DIR) assetman_settings = Settings( compiled_asset_root=COMPILED_ASSET_DIR, static_dir='static_dir', static_url_prefix='/static/', tornado_template_dirs=['tornado_templates'], django_template_dirs=[], # django_template_dirs=['django_templates'], template_extension="html", test_needs_compile=opts.get('test_needs_compile', True), skip_s3_upload=True, force_recompile=False, skip_inline_images=True, closure_compiler=opts.get('closure_compiler', '/bitly/local/bin/closure-compiler.jar'), minify_compressor_path=opts.get('minify_compressor_path', '/bitly/local/bin/minify'), sass_compiler=opts.get('sass_compiler', '/bitly/local/bin/sass'), lessc_path=opts.get('lessc_path', '/bitly/local/bin/lessc'), aws_username=None, ) return assetman_settings
def __init__(self, settings=None): self.settings = settings or Settings() self._manifest = self.make_empty_manifest()
def test_get_parser_returns_tornado_template_parser(self): settings = Settings(static_dir="assetman/tests/") parser = assetman.tools.get_parser(self.TEST_TEMPLATE_PATH, 'tornado_template', settings) assert parser is not None
def __init__(self, template_path, settings=None, **kwargs): self.settings = settings or Settings() self.template_path = template_path self.load_template(template_path)
def test_can_load_manifest_from_settings(self): settings = Settings(compiled_asset_root=self.TEST_MANIFEST_PATH) manifest = Manifest(settings).load() assert manifest assert manifest.blocks.keys()
def test_can_open_manifest_path_from_settings(self): settings = Settings(compiled_asset_root=self.TEST_MANIFEST_PATH) manifest = Manifest(settings) path = manifest.get_path() assert "tests/manifest.json" in path