3 �}:aV7 � @ s� d Z ddlZddlZddlmZ ddlmZmZmZmZ ej d�Z ejd�ZG dd� dej �ZG d d � d ej �ZG dd� dej �ZG d d� dej �ZG dd� dej �Zedkr�ej� dS )zTests for josepy.json_util.� N)�mock)�errors� interfaces� test_util�utilzcert.pemzcsr.pemc @ sH e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dS )� FieldTestz!Tests for josepy.json_util.Field.c C sV ddl m} xDtjddgddgddg�D ]&\}}}| j|d||d�j|�d� q(W d S )Nr )�FieldTF�foo)�default� omitempty)�josepy.json_utilr � itertools�product�assertIsZomit)�selfr r r �value� r �$/usr/lib/python3.6/json_util_test.py�test_no_omit_boolean s zFieldTest.test_no_omit_booleanc C sz t j� }dd� }dd� }ddlm} |d�}|j|�}| jd|j|�� |j|�}| jd|j|�� | jd |j|�� d S ) Nc S s dS )N�dr )�unused_valuer r r �decoder s z+FieldTest.test_descriptors.<locals>.decoderc S s dS )N�er )r r r r �encoder s z+FieldTest.test_descriptors.<locals>.encoderr )r r r r ) r � MagicMockr r r �assertEqual�encoder �decode)r � mock_valuer r r �fieldr r r �test_descriptors s zFieldTest.test_descriptorsc C sL G dd� dt j�}|� }ddlm} | j|j|�|� | jd|j|�� d S )Nc @ s e Zd Zdd� Zedd� �ZdS )z<FieldTest.test_default_encoder_is_partial.<locals>.MockFieldc S s dS )Nr r )r r r r �to_partial_json. s zLFieldTest.test_default_encoder_is_partial.<locals>.MockField.to_partial_jsonc S s d S )Nr )�cls�jobjr r r � from_json1 s zFFieldTest.test_default_encoder_is_partial.<locals>.MockField.from_jsonN)�__name__� __module__�__qualname__r! �classmethodr$ r r r r � MockField, s r) r )r r )r ZJSONDeSerializabler r r �default_encoderZassertNotEqual)r r) Z mock_fieldr r r r �test_default_encoder_is_partial+ s z)FieldTest.test_default_encoder_is_partialc C s* t j� }ddlm} | j|j|�|� d S )Nr )r )r r r r r r* )r r r r r r � test_default_encoder_passthrough; s z*FieldTest.test_default_encoder_passthroughc C s( ddl m} | jd|jdddg�� d S )Nr )r � � � )r- r. r/ )r r r �default_decoder)r r r r r �"test_default_decoder_list_to_tuple@ s z,FieldTest.test_default_decoder_list_to_tuplec C s@ ddl m} |jddi�}| j|tj� | j|tjdd�� d S )Nr )r �xr. )r2 )r r r0 �assertIsInstancer Z frozendictr )r r �objr r r �'test_default_decoder_dict_to_frozendictD s z1FieldTest.test_default_decoder_dict_to_frozendictc C s* t j� }ddlm} | j|j|�|� d S )Nr )r )r r r r r r0 )r r r r r r � test_default_decoder_passthroughJ s z*FieldTest.test_default_decoder_passthroughN)r% r&