<s> import json <EOL> import tempfile <EOL> import pytest <EOL> from oic . utils . client_management import CDB <EOL> @ pytest . fixture <EOL> def cdb ( ) : <EOL> file = tempfile . NamedTemporaryFile ( ) <EOL> file . close ( ) <EOL> return CDB ( file . name ) <EOL> class TestCDB ( object ) : <EOL> def test_create ( self , cdb ) : <EOL> info = self . _create_new ( cdb ) <EOL> assert info == cdb [ info [ "<STR_LIT>" ] ] <EOL> def test_dump ( self , cdb ) : <EOL> info = self . _create_new ( cdb ) <EOL> file = tempfile . NamedTemporaryFile ( delete = False ) <EOL> file . close ( ) <EOL> cdb . dump ( file . name ) <EOL> with open ( file . name ) as f : <EOL> from_file = json . load ( f ) <EOL> assert from_file [ <NUM_LIT:0> ] == info <EOL> client_id = info [ "<STR_LIT>" ] <EOL> del cdb [ client_id ] <EOL> with pytest . raises ( KeyError ) : <EOL> cdb [ client_id ] <EOL> cdb . load ( file . name ) <EOL> assert cdb [ client_id ] == info <EOL> def _create_new ( self , client_db ) : <EOL> info = client_db . create ( [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> return info </s>
