diff --git a/apps/cic-ussd/cic_ussd/account.py b/apps/cic-ussd/cic_ussd/account.py index 91fac0c3..647ca861 100644 --- a/apps/cic-ussd/cic_ussd/account.py +++ b/apps/cic-ussd/cic_ussd/account.py @@ -20,7 +20,7 @@ def define_account_tx_metadata(user: Account): ) key = generate_metadata_pointer( identifier=identifier, - cic_type='cic.person' + cic_type=':cic.person' ) account_metadata = get_cached_data(key=key) diff --git a/apps/cic-ussd/cic_ussd/balance.py b/apps/cic-ussd/cic_ussd/balance.py index 6d682471..99297a8e 100644 --- a/apps/cic-ussd/cic_ussd/balance.py +++ b/apps/cic-ussd/cic_ussd/balance.py @@ -80,7 +80,7 @@ def get_cached_operational_balance(blockchain_address: str): """ key = create_cached_data_key( identifier=bytes.fromhex(blockchain_address[2:]), - salt='cic.balances_data' + salt=':cic.balances_data' ) cached_balance = get_cached_data(key=key) if cached_balance: diff --git a/apps/cic-ussd/cic_ussd/metadata/base.py b/apps/cic-ussd/cic_ussd/metadata/base.py index 6f2d1ffc..e646d8aa 100644 --- a/apps/cic-ussd/cic_ussd/metadata/base.py +++ b/apps/cic-ussd/cic_ussd/metadata/base.py @@ -118,7 +118,7 @@ class MetadataRequestsHandler(Metadata): metadata_http_error_handler(result=result) response_data = result.content data = json.loads(response_data.decode('utf-8')) - if result.status_code == 200 and self.cic_type == 'cic.person': + if result.status_code == 200 and self.cic_type == ':cic.person': person = Person() deserialized_person = person.deserialize(person_data=json.loads(data)) data = json.dumps(deserialized_person.serialize()) diff --git a/apps/cic-ussd/cic_ussd/metadata/person.py b/apps/cic-ussd/cic_ussd/metadata/person.py index 57dec98c..63501f4c 100644 --- a/apps/cic-ussd/cic_ussd/metadata/person.py +++ b/apps/cic-ussd/cic_ussd/metadata/person.py @@ -9,4 +9,4 @@ from .base import MetadataRequestsHandler class PersonMetadata(MetadataRequestsHandler): def __init__(self, identifier: bytes): - super().__init__(cic_type='cic.person', identifier=identifier) + super().__init__(cic_type=':cic.person', identifier=identifier) diff --git a/apps/cic-ussd/cic_ussd/metadata/phone.py b/apps/cic-ussd/cic_ussd/metadata/phone.py index 46d508cb..d1de6c52 100644 --- a/apps/cic-ussd/cic_ussd/metadata/phone.py +++ b/apps/cic-ussd/cic_ussd/metadata/phone.py @@ -10,4 +10,4 @@ from .base import MetadataRequestsHandler class PhonePointerMetadata(MetadataRequestsHandler): def __init__(self, identifier: bytes): - super().__init__(cic_type='cic.msisdn', identifier=identifier) + super().__init__(cic_type=':cic.phone', identifier=identifier) diff --git a/apps/cic-ussd/cic_ussd/processor.py b/apps/cic-ussd/cic_ussd/processor.py index a2bf3638..195343af 100644 --- a/apps/cic-ussd/cic_ussd/processor.py +++ b/apps/cic-ussd/cic_ussd/processor.py @@ -219,7 +219,6 @@ def format_transactions(transactions: list, preferred_language: str, token_symbo formatted_transactions = '' if len(transactions) > 0: for transaction in transactions: - recipient_phone_number = transaction.get('recipient_phone_number') sender_phone_number = transaction.get('sender_phone_number') value = transaction.get('to_value') @@ -250,7 +249,7 @@ def process_display_user_metadata(user: Account, display_key: str): """ key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) user_metadata = get_cached_data(key) if user_metadata: @@ -287,7 +286,7 @@ def process_account_statement(user: Account, display_key: str, ussd_session: dic """ # retrieve cached statement identifier = blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address) - key = create_cached_data_key(identifier=identifier, salt='cic.statement') + key = create_cached_data_key(identifier=identifier, salt=':cic.statement') transactions = get_cached_data(key=key) token_symbol = retrieve_token_symbol() @@ -365,7 +364,7 @@ def process_start_menu(display_key: str, user: Account): key = create_cached_data_key( identifier=bytes.fromhex(blockchain_address[2:]), - salt='cic.balances_data' + salt=':cic.balances_data' ) cache_data(key=key, data=json.dumps(balances_data)) @@ -417,7 +416,7 @@ def process_request(user_input: str, user: Account, ussd_session: Optional[dict] # retrieve metadata before any transition key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) person_metadata = get_cached_data(key=key) diff --git a/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py b/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py index ff563272..eee2c7df 100644 --- a/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py +++ b/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py @@ -64,7 +64,7 @@ def has_sufficient_balance(state_machine_data: Tuple[str, dict, Account]) -> boo # get cached balance key = create_cached_data_key( identifier=bytes.fromhex(user.blockchain_address[2:]), - salt='cic.balances_data' + salt=':cic.balances_data' ) cached_balance = get_cached_data(key=key) operational_balance = compute_operational_balance(balances=json.loads(cached_balance)) diff --git a/apps/cic-ussd/cic_ussd/state_machine/logic/user.py b/apps/cic-ussd/cic_ussd/state_machine/logic/user.py index e8b8e44e..da8a87db 100644 --- a/apps/cic-ussd/cic_ussd/state_machine/logic/user.py +++ b/apps/cic-ussd/cic_ussd/state_machine/logic/user.py @@ -176,7 +176,7 @@ def edit_user_metadata_attribute(state_machine_data: Tuple[str, dict, Account]): blockchain_address = user.blockchain_address key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) user_metadata = get_cached_data(key=key) diff --git a/apps/cic-ussd/cic_ussd/state_machine/logic/validator.py b/apps/cic-ussd/cic_ussd/state_machine/logic/validator.py index 36cce59f..2f6203d4 100644 --- a/apps/cic-ussd/cic_ussd/state_machine/logic/validator.py +++ b/apps/cic-ussd/cic_ussd/state_machine/logic/validator.py @@ -23,7 +23,7 @@ def has_cached_user_metadata(state_machine_data: Tuple[str, dict, Account]): # check for user metadata in cache key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) user_metadata = get_cached_data(key=key) return user_metadata is not None diff --git a/apps/cic-ussd/cic_ussd/tasks/callback_handler.py b/apps/cic-ussd/cic_ussd/tasks/callback_handler.py index 1766565a..ab860b94 100644 --- a/apps/cic-ussd/cic_ussd/tasks/callback_handler.py +++ b/apps/cic-ussd/cic_ussd/tasks/callback_handler.py @@ -136,7 +136,7 @@ def process_balances_callback(result: list, param: str, status_code: int): blockchain_address = balances_data.get('address') key = create_cached_data_key( identifier=bytes.fromhex(blockchain_address[2:]), - salt='cic.balances_data' + salt=':cic.balances_data' ) cache_data(key=key, data=json.dumps(balances_data)) else: @@ -226,7 +226,7 @@ def process_statement_callback(result, param: str, status_code: int): # cache account statement identifier = bytes.fromhex(param[2:]) - key = create_cached_data_key(identifier=identifier, salt='cic.statement') + key = create_cached_data_key(identifier=identifier, salt=':cic.statement') data = json.dumps(processed_transactions) # cache statement data diff --git a/apps/cic-ussd/tests/cic_ussd/metadata/test_user_metadata.py b/apps/cic-ussd/tests/cic_ussd/metadata/test_user_metadata.py index 6c932ce0..1338f78d 100644 --- a/apps/cic-ussd/tests/cic_ussd/metadata/test_user_metadata.py +++ b/apps/cic-ussd/tests/cic_ussd/metadata/test_user_metadata.py @@ -105,7 +105,7 @@ def test_get_user_metadata(caplog, assert 'Get latest data status: 200' in caplog.text key = generate_metadata_pointer( identifier=identifier, - cic_type='cic.person' + cic_type=':cic.person' ) cached_user_metadata = get_cached_data(key=key) assert cached_user_metadata diff --git a/apps/cic-ussd/tests/cic_ussd/state_machine/logic/test_validator_logic.py b/apps/cic-ussd/tests/cic_ussd/state_machine/logic/test_validator_logic.py index 639598fd..8e91d37d 100644 --- a/apps/cic-ussd/tests/cic_ussd/state_machine/logic/test_validator_logic.py +++ b/apps/cic-ussd/tests/cic_ussd/state_machine/logic/test_validator_logic.py @@ -36,7 +36,7 @@ def test_has_cached_user_metadata(create_in_db_ussd_session, user = create_activated_user key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) cache_data(key=key, data=json.dumps(person_metadata)) result = has_cached_user_metadata(state_machine_data=state_machine_data) diff --git a/apps/cic-ussd/tests/fixtures/user.py b/apps/cic-ussd/tests/fixtures/user.py index 20dfbc28..0add085e 100644 --- a/apps/cic-ussd/tests/fixtures/user.py +++ b/apps/cic-ussd/tests/fixtures/user.py @@ -115,6 +115,6 @@ def cached_user_metadata(create_activated_user, init_redis_cache, person_metadat user_metadata = json.dumps(person_metadata) key = generate_metadata_pointer( identifier=blockchain_address_to_metadata_pointer(blockchain_address=create_activated_user.blockchain_address), - cic_type='cic.person' + cic_type=':cic.person' ) cache_data(key=key, data=user_metadata)