Exemple #1
0
def test___repr__(_proof, _generation):
    assert _proof.__repr__(
    ) == '\n    ----------------------------------- PROOF ------------------------------------\
                \n\
                \n    uuid        : %s\
                \n\
                \n    generation  : %s\
                \n    timestamp   : %d (%s)\
                \n    provider    : %s\
                \n\
                \n    hash-type   : SHA-256\
                \n    encoding    : UTF-8\
                \n    security    : ACTIVATED\
                \n\
                \n    proof-index : %d\
                \n    proof-path  :\
                \n    %s\
                \n\
                \n    status      : UNVALIDATED\
                \n\
                \n    -------------------------------- END OF PROOF --------------------------------\
                \n' % (
        _proof.header['uuid'],
        'SUCCESS' if _generation else 'FAILURE',
        _proof.header['timestamp'],
        _proof.header['creation_moment'],
        provider,
        5 if _generation else -1,
        stringify_path(proof_path, 'utf_8') if _generation else '',
    )
Exemple #2
0
def test___repr__(proof, generation):
    assert proof.__repr__() == '\n    ----------------------------------- PROOF ------------------------------------\
                \n\
                \n    uuid        : %s\
                \n\
                \n    timestamp   : %d (%s)\
                \n    provider    : %s\
                \n\
                \n    hash-type   : SHA-256\
                \n    encoding    : UTF-8\
                \n    raw_bytes   : TRUE\
                \n    security    : ACTIVATED\
                \n\
                \n    proof-index : %d\
                \n    proof-path  :\
                \n    %s\
                \n\
                \n    commitment  : %s\
                \n\
                \n    status      : UNVALIDATED\
                \n\
                \n    -------------------------------- END OF PROOF --------------------------------\
                \n' % (
                    proof.header['uuid'],
                    proof.header['timestamp'],
                    proof.header['creation_moment'],
                    provider,
                    5 if generation else -1,
                    stringify_path(proof_path, 'utf_8') if generation else '',
                    proof.header['commitment'],
                )
Exemple #3
0
def test_stringify_string_path():
    assert utils.stringify_path(
        ((+1,
          '3f824b56e7de850906e053efa4e9ed2762a15b9171824241c77b20e0eb44e3b8'),
         (+1,
          '4d8ced510cab21d23a5fd527dd122d7a3c12df33bc90a937c0a6b91fb6ea0992'),
         (+1,
          '35f75fd1cfef0437bc7a4cae7387998f909fab1dfe6ced53d449c16090d8aa52'),
         (-1,
          '73c027eac67a7b43af1a13427b2ad455451e4edfcaced8c2350b5d34adaa8020'),
         (+1,
          'cbd441af056bf79c65a2154bc04ac2e0e40d7a2c0e77b80c27125f47d3d7cba3'),
         (+1,
          '4e467bd5f3fc6767f12f4ffb918359da84f2a4de9ca44074488b8acf1e10262e'),
         (-1,
          'db7f4ee8be8025dbffee11b434f179b3b0d0f3a1d7693a441f19653a65662ad3'),
         (-1,
          'f235a9eb55315c9a197d069db9c75a01d99da934c5f80f9f175307fb6ac4d8fe'),
         (+1,
          'e003d116f27c877f6de213cf4d03cce17b94aece7b2ec2f2b19367abf914bcc8'),
         (-1,
          '6a59026cd21a32aaee21fe6522778b398464c6ea742ccd52285aa727c367d8f2'),
         (-1,
          '2dca521da60bf0628caa3491065e32afc9da712feb38ff3886d1c8dda31193f8')),
        'utf_8'
    ) == '\n       [0]   +1  3f824b56e7de850906e053efa4e9ed2762a15b9171824241c77b20e0eb44e3b8\n\
Exemple #4
0
    def __repr__(self):
        """
        Overrides the default implementation.

        Sole purpose of this function is to display info
        about a proof by just invoking it at console

        .. warning:: Contrary to convention, the output of this implementation
            is not insertible into the *eval()* builtin Python function
        """
        header = self.header
        body = self.body
        encoding = header['encoding']

        return '\n    ----------------------------------- PROOF ------------------------------------\
                \n\
                \n    uuid        : {uuid}\
                \n\
                \n    timestamp   : {timestamp} ({creation_moment})\
                \n    provider    : {provider}\
                \n\
                \n    hash-type   : {hash_type}\
                \n    encoding    : {encoding}\
                \n    raw_bytes   : {raw_bytes}\
                \n    security    : {security}\
                \n\
                \n    proof-index : {proof_index}\
                \n    proof-path  :\
                \n    {proof_path}\
                \n\
                \n    commitment  : {commitment}\
                \n\
                \n    status      : {status}\
                \n\
                \n    -------------------------------- END OF PROOF --------------------------------\
                \n'                   .format(
                    uuid=header['uuid'],
                    timestamp=header['timestamp'],
                    creation_moment=header['creation_moment'],
                    provider=header['provider'],
                    hash_type=header['hash_type'].upper().replace('_', '-'),
                    encoding=header['encoding'].upper().replace('_', '-'),
                    raw_bytes='TRUE' if header['raw_bytes'] else 'FALSE',
                    security='ACTIVATED' if header['security'] else 'DEACTIVATED',
                    commitment=header['commitment'].decode() \
                    if header['commitment'] else None,
                    proof_index=body['proof_index'],
                    proof_path=stringify_path(body['proof_path'], header['encoding']),
                    status='UNVALIDATED' if header['status'] is None \
                    else 'VALID' if header['status'] is True else 'NON VALID')
Exemple #5
0
def test_stringify_empty_path():
    assert utils.stringify_path((), 'utf_8') == ''