def setUp(self): """Set up the configuration to access the triplestore Use the config file test.virtuoso.ini to not interfere with production data """ self.settings = get_appsettings('configs/tests.ini', name='main') self.settings['askomics.upload_user_data_method'] = 'insert' self.request = testing.DummyRequest() self.config = testing.setUp(request=self.request) self.config.add_route('load_data_into_graph', '/load_data_into_graph') self.config.scan() self.request.session['username'] = '******' self.request.session['blocked'] = False self.request.session['group'] = 'base' self.request.session['graph'] = 'urn:sparql:test_askomics:jdoe' self.request.host_url = 'http://localhost:6543' self.request.json_body = {} SetupTests(self.settings, self.request.session) self.tps = InterfaceTpsDb(self.settings, self.request) self.askview = AskView(self.request) self.askview.settings = self.settings
def test_delete_graph(self): """Test delete_graph method Insert 2 datasets, and test delete_graph on one. Also test if start point return only one datasets """ # empty tps self.tps.clean_up() # load a test timestamp_people = self.tps.load_people( ) # need the timestamp of people to delete it timestamp_instruments = self.tps.load_instruments() # Delete only the people graph self.request.json_body = { 'named_graph': ['urn:sparql:test_askomics:jdoe:people_tsv_' + timestamp_people] } data = self.askview.delete_graph() assert data is None # test if start point return only one entity askview2 = AskView(self.request) askview2.settings = self.settings data = askview2.start_points() assert len(data["nodes"]) == 1 # test if startpoint return only instruments expected_result = { 'nodes': { self.settings['askomics.prefix'] + 'Instruments': { 'public': False, 'label': 'Instruments', 'uri': self.settings['askomics.prefix'] + 'Instruments', 'private': True, 'g': 'urn:sparql:test_askomics:jdoe:instruments_tsv_' + timestamp_instruments, 'endpoint': 'http://localhost:8890/sparql' } }, 'galaxy': False } assert data == expected_result
def test_delete_graph(self): """Test delete_graph method Insert 2 datasets, and test delete_graph on one. Also test if start point return only one datasets """ # empty tps self.tps.clean_up() # load a test timestamp_people = self.tps.load_people() # need the timestamp of people to delete it timestamp_instruments = self.tps.load_instruments() # Delete only the people graph self.request.json_body = { 'named_graph': ['urn:sparql:test_askomics:jdoe:people_tsv_' + timestamp_people] } data = self.askview.delete_graph() assert data is None # test if start point return only one entity askview2 = AskView(self.request) askview2.settings = self.settings data = askview2.start_points() assert len(data["nodes"]) == 1 # test if startpoint return only instruments expected_result = { 'nodes': { 'http://www.semanticweb.org/irisa/ontologies/2016/1/igepp-ontology#Instruments': { 'public': False, 'label': 'Instruments', 'uri': 'http://www.semanticweb.org/irisa/ontologies/2016/1/igepp-ontology#Instruments', 'private': True, 'g': 'urn:sparql:test_askomics:jdoe:instruments_tsv_' + timestamp_instruments } } } assert data == expected_result
def setUp(self): """Set up the configuration to access the triplestore Use the config file test.virtuoso.ini to not interfere with production data """ self.settings = get_appsettings('configs/test.virtuoso.ini', name='main') self.settings['askomics.upload_user_data_method'] = 'insert' self.request = testing.DummyRequest() self.config = testing.setUp(request=self.request) self.config.add_route('load_data_into_graph', '/load_data_into_graph') self.config.scan() self.request.session['username'] = '******' self.request.session['blocked'] = False self.request.session['group'] = 'base' self.request.session['graph'] = 'urn:sparql:test_askomics:jdoe' self.request.host_url = 'http://localhost:6543' self.request.json_body = {} # Create the user dir if not exist self.temp_directory = self.settings['askomics.files_dir'] + '/upload/' + self.request.session['username'] if not os.path.isdir(self.temp_directory): os.makedirs(self.temp_directory) # Set the upload dir self.request.session['upload_directory'] = self.temp_directory # Copy files if directory is empty if not os.listdir(self.temp_directory): files = ['people.tsv', 'instruments.tsv', 'play_instrument.tsv', 'transcript.tsv', 'qtl.tsv', 'small_data.gff3', 'turtle_data.ttl', 'bed_example.bed'] for file in files: src = os.path.join(os.path.dirname(__file__), "..", "test-data") + '/' + file dst = self.request.session['upload_directory'] + '/' + file copyfile(src, dst) self.tps = InterfaceTPS(self.settings, self.request) self.askview = AskView(self.request) self.askview.settings = self.settings em = EndpointManager(self.settings, self.request.session) em.drop()
def setUp(self): self.settings = get_appsettings('configs/development.virtuoso.ini', name='main') self.request = testing.DummyRequest() self.config = testing.setUp(request=self.request) self.config.add_route('load_data_into_graph', '/load_data_into_graph') self.config.scan() self.request.session['upload_directory'] = os.path.join( os.path.dirname(__file__), "..", "test-data") self.temp_directory = tempfile.mkdtemp() self.it = InterfaceTPS(self.settings, self.request) self.askview = AskView(self.request) self.askview.settings = self.settings self.timestamp = str(time.time())
def test_empty_database(self): """Test the empty_database method Insert data and test empty_database. Also test if start point return no results after deletion """ # empty tps self.tps.clean_up() # load a test self.tps.load_people() self.tps.load_instruments() data = self.askview.empty_database() assert data == {} # if success, return an empty dict # test if start point return no data askview2 = AskView(self.request) askview2.settings = self.settings data = askview2.start_points() assert data == {'nodes': {}}