<s> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT:.>" ) <EOL> import unittest <EOL> from PyOpenWorm import ( DataUser , Configureable , BadConf , Configure ) <EOL> import rdflib <EOL> import rdflib as R <EOL> from DataTestTemplate import _DataTest <EOL> class DataUserTest ( _DataTest ) : <EOL> def test_init_no_config ( self ) : <EOL> """<STR_LIT>""" <EOL> c = Configureable . conf <EOL> Configureable . conf = False <EOL> with self . assertRaises ( BadConf ) : <EOL> DataUser ( ) <EOL> Configureable . conf = c <EOL> def test_init_no_config_with_default ( self ) : <EOL> """<STR_LIT>""" <EOL> DataUser ( ) <EOL> def test_init_False_with_default ( self ) : <EOL> """<STR_LIT>""" <EOL> DataUser ( conf = False ) <EOL> def test_init_config_no_Data ( self ) : <EOL> """<STR_LIT>""" <EOL> tmp = Configureable . conf <EOL> Configureable . conf = Configure ( ) <EOL> with self . assertRaises ( BadConf ) : <EOL> DataUser ( ) <EOL> Configureable . conf = tmp <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_add_statements_has_uploader ( self ) : <EOL> """<STR_LIT>""" <EOL> g = R . Graph ( ) <EOL> s = rdflib . URIRef ( "<STR_LIT>" ) <EOL> p = rdflib . URIRef ( "<STR_LIT>" ) <EOL> o = rdflib . URIRef ( "<STR_LIT>" ) <EOL> g . add ( ( s , p , o ) ) <EOL> du = DataUser ( self . config ) <EOL> try : <EOL> du . add_statements ( g ) <EOL> except Exception as e : <EOL> self . fail ( <EOL> "<STR_LIT>" + <EOL> str ( e ) ) <EOL> g0 = du . conf [ '<STR_LIT>' ] <EOL> uploader_n3_uri = du . conf [ '<STR_LIT>' ] [ '<STR_LIT>' ] . n3 ( ) <EOL> upload_date_n3_uri = du . conf [ '<STR_LIT>' ] [ '<STR_LIT>' ] . n3 ( ) <EOL> q = """<STR_LIT>""" + uploader_n3_uri + """<STR_LIT>""" + upload_date_n3_uri + """<STR_LIT>""" <EOL> for x in g0 . query ( q ) : <EOL> self . assertEqual ( du . conf [ '<STR_LIT>' ] , str ( x [ '<STR_LIT:u>' ] ) ) <EOL> def test_add_statements_completes ( self ) : <EOL> """<STR_LIT>""" <EOL> g = rdflib . Graph ( ) <EOL> for i in range ( <NUM_LIT> ) : <EOL> s = rdflib . URIRef ( "<STR_LIT>" % i ) <EOL> p = rdflib . URIRef ( "<STR_LIT>" % i ) <EOL> o = rdflib . URIRef ( "<STR_LIT>" % i ) <EOL> g . add ( ( s , p , o ) ) <EOL> du = DataUser ( conf = self . config ) <EOL> du . add_statements ( g ) </s>
