<s> from __future__ import division <EOL> from vistrails . db . domain import DBPluginData <EOL> import unittest <EOL> import copy <EOL> import random <EOL> from vistrails . db . domain import IdScope <EOL> import vistrails . core <EOL> class PluginData ( DBPluginData ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> DBPluginData . __init__ ( self , * args , ** kwargs ) <EOL> if self . id is None : <EOL> self . id = - <NUM_LIT:1> <EOL> def __copy__ ( self ) : <EOL> return PluginData . do_copy ( self ) <EOL> def do_copy ( self , new_ids = False , id_scope = None , id_remap = None ) : <EOL> cp = DBPluginData . do_copy ( self , new_ids , id_scope , id_remap ) <EOL> cp . __class__ = PluginData <EOL> return cp <EOL> @ staticmethod <EOL> def convert ( _plugin_data ) : <EOL> _plugin_data . __class__ = PluginData <EOL> id = DBPluginData . db_id <EOL> data = DBPluginData . db_data <EOL> def __eq__ ( self , other ) : <EOL> if type ( other ) != type ( self ) : <EOL> return False <EOL> return self . data == other . data <EOL> class TestPluginData ( unittest . TestCase ) : <EOL> def create_data ( self , id = <NUM_LIT:1> , data = "<STR_LIT>" ) : <EOL> return PluginData ( id = id , data = data ) <EOL> def test_create ( self ) : <EOL> self . create_data ( <NUM_LIT:2> , "<STR_LIT>" ) <EOL> def test_serialization ( self ) : <EOL> import vistrails . core . db . io <EOL> p_data1 = self . create_data ( ) <EOL> xml_str = vistrails . core . db . io . serialize ( p_data1 ) <EOL> p_data2 = vistrails . core . db . io . unserialize ( xml_str , PluginData ) <EOL> self . assertEquals ( p_data1 , p_data2 ) <EOL> self . assertEquals ( p_data1 . id , p_data2 . id ) </s>
