def test_building_file_path(self, get_file_content_mock): get_file_content_mock.return_value = """ document.write('Hello world!'); """ fingerprinter = AssetFingerprinter() fingerprinter.get_url('javascripts/application.js') fingerprinter.get_asset_file_contents.assert_called_with( 'app/static/javascripts/application.js')
def test_hashes_are_consistent(self, get_file_content_mock): get_file_content_mock.return_value = """ body { font-family: nta; } """ asset_fingerprinter = AssetFingerprinter() assert (asset_fingerprinter.get_asset_fingerprint('application.css') == asset_fingerprinter.get_asset_fingerprint('same_contents.css'))
class Config(object): VERSION = get_version_label( os.path.abspath(os.path.dirname(__file__)) ) DEBUG = True WTF_CSRF_ENABLED = True SESSION_COOKIE_NAME = 'dm_admin_session' SESSION_COOKIE_PATH = '/admin' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True DM_S3_DOCUMENT_BUCKET = None DM_DOCUMENTS_URL = 'https://assets.dev.digitalmarketplace.service.gov.uk' DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None SECRET_KEY = None DM_AGREEMENTS_BUCKET = None DM_COMMUNICATIONS_BUCKET = None DM_ASSETS_URL = None STATIC_URL_PATH = '/admin/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Logging DM_LOG_LEVEL = 'DEBUG' DM_APP_NAME = 'admin-frontend' DM_LOG_PATH = '/var/log/digitalmarketplace/application.log' DM_DOWNSTREAM_REQUEST_ID_HEADER = 'X-Amz-Cf-Id' # Feature Flags RAISE_ERROR_ON_MISSING_FEATURES = True SHARED_EMAIL_KEY = None INVITE_EMAIL_SALT = 'InviteEmailSalt' DM_MANDRILL_API_KEY = None INVITE_EMAIL_NAME = 'Digital Marketplace Admin' INVITE_EMAIL_FROM = '*****@*****.**' INVITE_EMAIL_SUBJECT = 'Your Digital Marketplace invitation' CREATE_USER_PATH = 'suppliers/create-user' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) template_folders = [ os.path.join(repo_root, 'app/templates') ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader
class Config(object): VERSION = get_version_label( os.path.abspath(os.path.dirname(__file__)) ) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True PERMANENT_SESSION_LIFETIME = 4 * 3600 WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_MANDRILL_API_KEY = None DEBUG = False CLARIFICATION_EMAIL_NAME = 'Digital Marketplace Admin' CLARIFICATION_EMAIL_FROM = '*****@*****.**' SECRET_KEY = None STATIC_URL_PATH = '/suppliers/opportunities/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Feature Flags RAISE_ERROR_ON_MISSING_FEATURES = True FEATURE_FLAGS_NEW_SUPPLIER_FLOW = False # Logging DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'brief-responses-frontend' DM_DOWNSTREAM_REQUEST_ID_HEADER = 'X-Amz-Cf-Id' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) template_folders = [ os.path.join(repo_root, 'app/templates') ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader
def test_hash_gets_cached(self, get_file_content_mock): get_file_content_mock.return_value = """ body { font-family: nta; } """ fingerprinter = AssetFingerprinter() assert (fingerprinter.get_url('application.css') == '/static/application.css?418e6f4a6cdf1142e45c072ed3e1c90a') fingerprinter._cache['application.css'] = 'a1a1a1' assert (fingerprinter.get_url('application.css') == 'a1a1a1') fingerprinter.get_asset_file_contents.assert_called_once_with( 'app/static/application.css')
def test_hashes_are_different_for_different_files(self, get_file_content_mock): asset_fingerprinter = AssetFingerprinter() get_file_content_mock.return_value = """ body { font-family: nta; } """ css_hash = asset_fingerprinter.get_asset_fingerprint('application.css') get_file_content_mock.return_value = """ document.write('Hello world!'); """ js_hash = asset_fingerprinter.get_asset_fingerprint('application.js') assert (js_hash != css_hash)
def test_url_format(self, get_file_content_mock): get_file_content_mock.return_value = """ body { font-family: nta; } """ asset_fingerprinter = AssetFingerprinter( asset_root='/suppliers/static/') assert ( asset_fingerprinter.get_url('application.css') == '/suppliers/static/application.css?418e6f4a6cdf1142e45c072ed3e1c90a' # noqa ) assert ( asset_fingerprinter.get_url('application-ie6.css') == '/suppliers/static/application-ie6.css?418e6f4a6cdf1142e45c072ed3e1c90a' # noqa )
class Config(object): VERSION = get_version_label(os.path.abspath(os.path.dirname(__file__))) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_NOTIFY_API_KEY = None DM_REDIS_SERVICE_NAME = None DM_CLARIFICATION_QUESTION_EMAIL = '*****@*****.**' DM_FRAMEWORK_AGREEMENTS_EMAIL = '*****@*****.**' DM_COMPANY_DETAILS_CHANGE_EMAIL = '*****@*****.**' SUPPORT_EMAIL_ADDRESS = "*****@*****.**" NOTIFY_TEMPLATES = { "confirmation_of_clarification_question": "1a8a3408-49ef-486f-a6c9-8557d1a0dc63", "create_user_account": "84f5d812-df9d-4ab8-804a-06f64f5abd30", "invite_contributor": "5eefe42d-1694-4388-8908-991cdfba0a71", "framework_agreement_signature_page": "08929c93-f9e7-4b40-b75f-418659308324", 'framework-application-started': '9c8237fa-d854-4388-babb-14a0f252d133', 'framework-clarification-question': "8574484f-9907-44c0-b9d5-1120beb64ef0", 'framework-application-question': '6681d4a1-6e30-407f-9e8b-3f6633d73546', 'sign_framework_agreement_confirmation': 'bbc77101-4585-4d1e-80c4-43045ea9550f' } E_SIGNATURE_FRAMEWORKS = [ 'g-cloud-12', 'digital-outcomes-and-specialists-5' ] DM_AGREEMENTS_BUCKET = None DM_COMMUNICATIONS_BUCKET = None DM_DOCUMENTS_BUCKET = None DM_SUBMISSIONS_BUCKET = None DM_ASSETS_URL = None DM_MAILCHIMP_USERNAME = None DM_MAILCHIMP_API_KEY = None DM_MAILCHIMP_OPEN_FRAMEWORK_NOTIFICATION_MAILING_LIST_ID = None DM_DNB_API_USERNAME = None DM_DNB_API_PASSWORD = None DEBUG = False INVITE_EMAIL_NAME = 'Digital Marketplace Admin' INVITE_EMAIL_FROM = '*****@*****.**' INVITE_EMAIL_SUBJECT = 'Your Digital Marketplace invitation' CLARIFICATION_EMAIL_NAME = 'Digital Marketplace Admin' DM_FOLLOW_UP_EMAIL_TO = '*****@*****.**' FRAMEWORK_AGREEMENT_RETURNED_NAME = 'Digital Marketplace Admin' DM_ENQUIRIES_EMAIL_ADDRESS = '*****@*****.**' DM_ENQUIRIES_EMAIL_ADDRESS_UUID = '24908180-b64e-513d-ab48-fdca677cec52' SECRET_KEY = None SHARED_EMAIL_KEY = None RESET_PASSWORD_TOKEN_NS = 'ResetPasswordSalt' INVITE_EMAIL_TOKEN_NS = 'InviteEmailSalt' STATIC_URL_PATH = '/suppliers/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Logging DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'supplier-frontend' DM_G12_RECOVERY_SUPPLIER_IDS = None @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join( repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, "app", "templates"), os.path.join(digitalmarketplace_govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"), ] jinja_loader = jinja2.ChoiceLoader([ jinja2.FileSystemLoader(template_folders), jinja2.PrefixLoader( {'govuk': jinja2.FileSystemLoader(govuk_frontend)}) ]) app.jinja_loader = jinja_loader
class Config(object): VERSION = get_version_label(os.path.abspath(os.path.dirname(__file__))) DEBUG = True WTF_CSRF_ENABLED = True SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True DM_S3_DOCUMENT_BUCKET = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None SECRET_KEY = None DM_AGREEMENTS_BUCKET = None DM_COMMUNICATIONS_BUCKET = None DM_REPORTS_BUCKET = None DM_ASSETS_URL = None DM_REDIS_SERVICE_NAME = None STATIC_URL_PATH = '/admin/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Logging DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_APP_NAME = 'admin-frontend' SHARED_EMAIL_KEY = None INVITE_EMAIL_TOKEN_NS = 'InviteEmailSalt' DM_NOTIFY_API_KEY = None NOTIFY_TEMPLATES = { "invite_contributor": "5eefe42d-1694-4388-8908-991cdfba0a71", } # a mapping of framework slug to identifier on performance platform containing signup stats PERFORMANCE_PLATFORM_ID_MAPPING = { "g-cloud-9": "g-cloud-9-supplier-applications", "g-cloud-10": "g-cloud-10-supplier-applications", "g-cloud-11": "g-cloud-11-supplier-applications", "digital-outcomes-and-specialists-3": "digital-outcomes-specialists-3", "digital-outcomes-and-specialists-4": "digital-outcomes-specialists-4", } PERFORMANCE_PLATFORM_BASE_URL = "https://www.gov.uk/performance/" @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join( repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, "app", "templates"), os.path.join(digitalmarketplace_govuk_frontend), # digitalmarketplace/templates is needed for digitalmarketplace-utils error templates os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"), ] jinja_loader = jinja2.ChoiceLoader([ jinja2.FileSystemLoader(template_folders), jinja2.PrefixLoader( {"govuk": jinja2.FileSystemLoader(govuk_frontend)}), ]) app.jinja_loader = jinja_loader
class Config(object): VERSION = get_version_label( os.path.abspath(os.path.dirname(__file__)) ) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_NOTIFY_API_KEY = None DM_REDIS_SERVICE_NAME = None NOTIFY_TEMPLATES = { "reset_password": "******", "change_password_alert": "1c4c0562-44aa-4ae4-ba61-e17c544df535", "reset_password_inactive": "6c522c78-e4d2-488f-aa5f-6f42401ef2c5", } SUPPORT_EMAIL_ADDRESS = "*****@*****.**" DEBUG = False SECRET_KEY = None SHARED_EMAIL_KEY = None RESET_PASSWORD_TOKEN_NS = 'ResetPasswordSalt' INVITE_EMAIL_TOKEN_NS = 'InviteEmailSalt' STATIC_URL_PATH = '/user/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # LOGGING DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'user-frontend' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join(repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, 'app', 'templates'), os.path.join(digitalmarketplace_govuk_frontend), os.path.join(govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend, 'digitalmarketplace', 'templates'), ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader
def test_can_read_self(self): 'Ralph’s apostrophe' AssetFingerprinter( filesystem_path='tests/').get_url('test_asset_fingerprint.py')
class Config(object): VERSION = get_version_label(os.path.abspath(os.path.dirname(__file__))) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_NOTIFY_API_KEY = None DM_REDIS_SERVICE_NAME = None NOTIFY_TEMPLATES = { "create_user_account": "84f5d812-df9d-4ab8-804a-06f64f5abd30", } SUPPORT_EMAIL_ADDRESS = "*****@*****.**" # This is just a placeholder ES_ENABLED = True DEBUG = False SECRET_KEY = None SHARED_EMAIL_KEY = None INVITE_EMAIL_SALT = 'InviteEmailSalt' STATIC_URL_PATH = '/buyers/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # LOGGING DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'briefs-frontend' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join( repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, 'app', 'templates'), os.path.join(govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"), ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader # Set the govuk_frontend_version to account for version-based quirks (eg: v3 Error Summary links to radios) with open( os.path.join(repo_root, "node_modules", "govuk-frontend", "package.json")) as package_json_file: package_json = json.load(package_json_file) dmcontent.govuk_frontend.govuk_frontend_version = list( map(int, package_json["version"].split(".")))
class Config(object): VERSION = get_version_label(os.path.abspath(os.path.dirname(__file__))) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_SEARCH_API_URL = None DM_SEARCH_API_AUTH_TOKEN = None DM_MANDRILL_API_KEY = None DM_REDIS_SERVICE_NAME = None # Used for generating absolute URLs from relative URLs when necessary DM_PATCH_FRONTEND_URL = 'http://localhost/' # matches api(s) DM_SEARCH_PAGE_SIZE = 100 # This is just a placeholder ES_ENABLED = True DEBUG = False RESET_PASSWORD_EMAIL_NAME = 'Digital Marketplace Admin' RESET_PASSWORD_EMAIL_FROM = '*****@*****.**' RESET_PASSWORD_EMAIL_SUBJECT = 'Reset your Digital Marketplace password' CREATE_USER_SUBJECT = 'Create your Digital Marketplace account' SECRET_KEY = None SHARED_EMAIL_KEY = None RESET_PASSWORD_SALT = 'ResetPasswordSalt' INVITE_EMAIL_SALT = 'InviteEmailSalt' ASSET_PATH = '/static/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # LOGGING DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'buyer-frontend' #: For some frameworks (represented by the keys in this map), we store no framework content. But #: they work just like some other framework (represented by the values in the map) for which we do #: have content available. The map uses slugs to identify the framework pairs, so that we can still #: find the framework data we need (and so that we can avoid trying to load up framework data that #: isn't actually available). DM_FRAMEWORK_CONTENT_MAP = { 'g-cloud-4': 'g-cloud-6', 'g-cloud-5': 'g-cloud-6', } DM_FEEDBACK_FORM = { 'uri': 'https://docs.google.com/a/digital.cabinet-office.gov.uk/forms/d/e/1FAIpQLSc-uXv-4VqGBipDwPhJFDpET5UrHnJpsJ5FFTn4-MBAfKeOPg/formResponse', # noqa 'fields': { 'uri': 'entry.1048271701', 'what_doing': 'entry.1348335665', 'what_happened': 'entry.869819225', } } GOOGLE_SITE_VERIFICATION = None @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join( repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, "app", "templates"), os.path.join(govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"), ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader # Set the govuk_frontend_version to account for version-based quirks (eg: v3 Error Summary links to radios) with open( os.path.join(repo_root, "node_modules", "govuk-frontend", "package.json")) as package_json_file: package_json = json.load(package_json_file) dmcontent.govuk_frontend.govuk_frontend_version = list( map(int, package_json["version"].split(".")))
def test_can_read_self(self): string_with_unicode_character = 'Ralph’s apostrophe' AssetFingerprinter( filesystem_path='tests/').get_url('test_asset_fingerprint.py')
class Config(object): VERSION = get_version_label( os.path.abspath(os.path.dirname(__file__)) ) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = "Lax" PERMANENT_SESSION_LIFETIME = 3600 # 1 hour DM_COOKIE_PROBE_EXPECT_PRESENT = True WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_NOTIFY_API_KEY = None DM_REDIS_SERVICE_NAME = None DEBUG = False NOTIFY_TEMPLATES = { "clarification_question": "520e0623-119e-41ac-990b-b9cdb0e9c30d", "clarification_question_confirmation": "d74a8a05-eae6-49cb-bc08-63d95b92b4d3", } SECRET_KEY = None STATIC_URL_PATH = '/suppliers/opportunities/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Logging DM_LOG_LEVEL = 'DEBUG' DM_PLAIN_TEXT_LOGS = False DM_LOG_PATH = None DM_APP_NAME = 'brief-responses-frontend' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) digitalmarketplace_govuk_frontend = os.path.join(repo_root, "node_modules", "digitalmarketplace-govuk-frontend") govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend") template_folders = [ os.path.join(repo_root, "app", "templates"), os.path.join(govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend), os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"), ] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader # Set the govuk_frontend_version to account for version-based quirks (eg: v3 Error Summary links to radios) with open(os.path.join(repo_root, "node_modules", "govuk-frontend", "package.json")) as package_json_file: package_json = json.load(package_json_file) dmcontent.govuk_frontend.govuk_frontend_version = list(map(int, package_json["version"].split(".")))
class Config(object): VERSION = get_version_label(os.path.abspath(os.path.dirname(__file__))) SESSION_COOKIE_NAME = 'dm_session' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True PERMANENT_SESSION_LIFETIME = 4 * 3600 WTF_CSRF_ENABLED = True WTF_CSRF_TIME_LIMIT = None DM_DATA_API_URL = None DM_DATA_API_AUTH_TOKEN = None DM_MANDRILL_API_KEY = None DM_CLARIFICATION_QUESTION_EMAIL = '*****@*****.**' DM_FRAMEWORK_AGREEMENTS_EMAIL = '*****@*****.**' DM_AGREEMENTS_BUCKET = None DM_COMMUNICATIONS_BUCKET = None DM_DOCUMENTS_BUCKET = None DM_SUBMISSIONS_BUCKET = None DM_ASSETS_URL = None DEBUG = False RESET_PASSWORD_EMAIL_NAME = 'Digital Marketplace Admin' RESET_PASSWORD_EMAIL_FROM = '*****@*****.**' RESET_PASSWORD_EMAIL_SUBJECT = 'Reset your Digital Marketplace password' INVITE_EMAIL_NAME = 'Digital Marketplace Admin' INVITE_EMAIL_FROM = '*****@*****.**' INVITE_EMAIL_SUBJECT = 'Your Digital Marketplace invitation' CLARIFICATION_EMAIL_NAME = 'Digital Marketplace Admin' CLARIFICATION_EMAIL_FROM = '*****@*****.**' CLARIFICATION_EMAIL_SUBJECT = 'Thanks for your clarification question' DM_FOLLOW_UP_EMAIL_TO = '*****@*****.**' FRAMEWORK_AGREEMENT_RETURNED_NAME = 'Digital Marketplace Admin' DM_GENERIC_NOREPLY_EMAIL = '*****@*****.**' CREATE_USER_SUBJECT = 'Create your Digital Marketplace account' SECRET_KEY = None SHARED_EMAIL_KEY = None RESET_PASSWORD_SALT = 'ResetPasswordSalt' INVITE_EMAIL_SALT = 'InviteEmailSalt' STATIC_URL_PATH = '/suppliers/static' ASSET_PATH = STATIC_URL_PATH + '/' BASE_TEMPLATE_DATA = { 'header_class': 'with-proposition', 'asset_path': ASSET_PATH, 'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH) } # Feature Flags RAISE_ERROR_ON_MISSING_FEATURES = True FEATURE_FLAGS_EDIT_SECTIONS = False FEATURE_FLAGS_CONTRACT_VARIATION = False # Logging DM_LOG_LEVEL = 'DEBUG' DM_LOG_PATH = None DM_APP_NAME = 'supplier-frontend' DM_DOWNSTREAM_REQUEST_ID_HEADER = 'X-Amz-Cf-Id' @staticmethod def init_app(app): repo_root = os.path.abspath(os.path.dirname(__file__)) template_folders = [os.path.join(repo_root, 'app/templates')] jinja_loader = jinja2.FileSystemLoader(template_folders) app.jinja_loader = jinja_loader
def test_can_read_self(self): """This string must contain Ralph’s apostrophe. We then try to load this file with the asset fingerprinter.""" AssetFingerprinter( filesystem_path='tests/').get_url('test_asset_fingerprint.py')