From 982546961346ef89f310aa9e634ce369d934fc16 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 24 Dec 2020 15:19:46 +0000 Subject: [PATCH] Make language attributes abstract properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make it impossible to create a new client without at least having to define these properties. Which should get someone thinking about language support… --- app/clients/cbc_proxy.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/clients/cbc_proxy.py b/app/clients/cbc_proxy.py index eb329b270..8500e57c4 100644 --- a/app/clients/cbc_proxy.py +++ b/app/clients/cbc_proxy.py @@ -1,4 +1,5 @@ import json +from abc import ABC, abstractmethod import boto3 from flask import current_app @@ -49,11 +50,18 @@ class CBCProxyClient: return proxy_classes[provider](self._lambda_client) -class CBCProxyClientBase: +class CBCProxyClientBase(ABC): lambda_name = None - LANGUAGE_ENGLISH = 'en-GB' - LANGUAGE_WELSH = 'cy-GB' + @property + @abstractmethod + def LANGUAGE_ENGLISH(self): + pass + + @property + @abstractmethod + def LANGUAGE_WELSH(self): + pass def __init__(self, lambda_client): self._lambda_client = lambda_client @@ -128,6 +136,9 @@ class CBCProxyCanary(CBCProxyClientBase): """ lambda_name = 'canary' + LANGUAGE_ENGLISH = None + LANGUAGE_WELSH = None + def send_canary( self, identifier, @@ -138,6 +149,9 @@ class CBCProxyCanary(CBCProxyClientBase): class CBCProxyEE(CBCProxyClientBase): lambda_name = 'bt-ee-1-proxy' + LANGUAGE_ENGLISH = 'en-GB' + LANGUAGE_WELSH = 'cy-GB' + def send_link_test( self, identifier,