Created
June 12, 2018 15:08
-
-
Save tantale/dd4dd2b8191f284b4c4b8b32c4c59cf8 to your computer and use it in GitHub Desktop.
unit test for attrs_encoder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
qronos_doc - test_attrs_encoder | |
========================= | |
:Created on: 2018-06-12 | |
:Author: Laurent LAPORTE <[email protected]> | |
""" | |
import datetime | |
import pprint | |
import unittest | |
from qairos.attrs_encoder import QronosEncoder, State | |
class TestQronosEncoder(unittest.TestCase): | |
def test_encode_attrs(self): | |
attrs = { | |
'APP': 'MyAPP', | |
'ATTRIBUT': 'MyATTRIBUT', | |
'COMMENT': 'Voici un commentaire détaillé', | |
'DATE': datetime.datetime(2018, 6, 12, 16, 7), | |
'DATEL': datetime.date(2018, 6, 12), | |
'DE': 'Process.Module', | |
'DEBUG': 'MyDEBUG', | |
'DELHISTORY': True, | |
'DOC': 'MyDOC', | |
'ETAT': State.PENDING, | |
'FIC': 'path/to/file', | |
'FICHIER': 'path/to/file', | |
'ID': 'MyID', | |
'IMA': 'path/to/rep/images', | |
'M': 'Process.Module', | |
'META': 'Process.Metamodule', | |
'MODE': 'S', | |
'NBJ': 1, | |
'NBP': 12, | |
'NOM': 'Process', | |
'OPE': 'MyOPE', | |
'OPEGEO': 'MyOPEGEO', | |
'PRI': 100, | |
'PROCESS': 'Process', | |
'REP': 'path/to/rep', | |
'REQ': 'MyREQ', | |
'SER': 'MySER', | |
'SORTIE': 'XML', | |
'SYNC': 'PIPE', | |
'TAILLE': 512, | |
'TYPE': 'MyTYPE', | |
'USER': 'MyUSER', | |
'VERS': 'Process.Module'} | |
pprint.pprint(attrs) | |
encoder = QronosEncoder() | |
encoded_attrs = encoder.encode_attrs(attrs) | |
expected = { | |
'APP': 'MyAPP', | |
'ATTRIBUT': 'MyATTRIBUT', | |
'COMMENT': 'Voici+un+commentaire+d%E9taill%E9', | |
'DATE': '12062018160700', | |
'DATEL': '12/06/2018', | |
'DE': 'Process.Module', | |
'DEBUG': 'MyDEBUG', | |
'DELHISTORY': 'O', | |
'DOC': 'MyDOC', | |
'ETAT': 'ATTENTE', | |
'FIC': 'path/to/file', | |
'FICHIER': 'path/to/file', | |
'ID': 'MyID', | |
'IMA': 'path/to/rep/images', | |
'M': 'Process.Module', | |
'META': 'Process.Metamodule', | |
'MODE': 'S', | |
'NBJ': '1', | |
'NBP': '12', | |
'NOM': 'Process', | |
'OPE': 'MyOPE', | |
'OPEGEO': 'MyOPEGEO', | |
'PRI': '100', | |
'PROCESS': 'Process', | |
'REP': 'path/to/rep', | |
'REQ': 'MyREQ', | |
'SER': 'MySER', | |
'SORTIE': 'XML', | |
'SYNC': 'PIPE', | |
'TAILLE': '512', | |
'TYPE': 'MyTYPE', | |
'USER': 'MyUSER', | |
'VERS': 'Process.Module'} | |
self.assertEqual(encoded_attrs, expected) | |
decoded_attrs = encoder.decode_attrs(encoded_attrs) | |
self.assertEqual(decoded_attrs, attrs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment