def test_add_task_concept(self): self.assertTrue( self.client.login(username=self.user.username, password=self.password)) task = Task() concept = Concept() contrast = Contrast() tsk = task.create('test_add_task_concept', {'prop': 'prop'}) con = concept.create('test_add_task_concept', {'prop': 'prop'}) cont = contrast.create('test_add_task_concept', {'prop': 'prop'}) concept.link(con.properties['id'], cont.properties['id'], "HASCONTRAST", endnode_type='contrast') response = self.client.post( reverse('add_task_concept', kwargs={'uid': tsk.properties['id']}), {'concept_selection': con.properties['id']}) self.assertEqual(response.status_code, 200) response = self.client.get( reverse('task', kwargs={'uid': tsk.properties['id']})) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context['task']['relations']['ASSERTS']), 1) self.assertEqual( response.context['task']['relations']['ASSERTS'][0]['id'], con.properties['id']) tsk.delete_related() con.delete_related() tsk.delete() con.delete() cont.delete()
def test_view_concept(self): concept = Concept() con = concept.create("test_view_concept", {"prop": "prop"}) uid = con.properties['id'] response = self.client.get(reverse('concept', kwargs={'uid': uid})) self.assertEqual(response.status_code, 200) self.assertEqual(response.context['concept']['id'], uid) con.delete()
def test_update_concept_no_def(self): self.assertTrue( self.client.login(username=self.user.username, password=self.password)) concept = Concept() con = concept.create('test_update_concept', {'prop': 'prop'}) response = self.client.post( reverse('update_concept', kwargs={'uid': con.properties['id']}), {'definition_text': 'new def'}) self.assertEqual(response.status_code, 200) self.assertEqual('new def', response.context['concept']['definition_text']) con.delete()
def setUp(self): self.task = Task() self.node_name = "test_name" self.node_properties = {'test_key': 'test_value'} self.graph = Graph("http://graphdb:7474/db/data/") self.task1 = self.task.create( name=self.node_name, properties=self.node_properties) self.task2 = self.task.create( name=self.node_name, properties=self.node_properties) condition = Condition() self.cond = condition.create( name=self.node_name, properties=self.node_properties) contrast = Contrast() self.cont = contrast.create( name=self.node_name, properties=self.node_properties) concept = Concept() self.con = concept.create( name=self.node_name, properties=self.node_properties) self.task.link( self.task1.properties['id'], self.cond.properties['id'], "HASCONDITION", endnode_type='condition') self.task.link( self.task1.properties['id'], self.con.properties['id'], "ASSERTS", endnode_type='concept') condition.link( self.cond.properties['id'], self.cont.properties['id'], "HASCONTRAST", endnode_type='contrast') concept.link( self.con.properties['id'], self.cont.properties['id'], "MEASUREDBY", endnode_type='contrast')
def test_add_concept_relation(self): self.assertTrue( self.client.login(username=self.user.username, password=self.password)) concept = Concept() con1 = concept.create('test_update_concept', {'prop': 'prop'}) con2 = concept.create('test_update_concept', {'prop': 'prop'}) response = self.client.post( reverse('add_concept_relation', kwargs={'uid': con1.properties['id']}), { 'relation_type': 'PARTOF', 'concept_selection': con2.properties['id'] }) self.assertEqual(response.status_code, 200) self.assertEqual( response.context['concept']['relations']['PARTOF'][0]['id'], con2.properties['id']) con1.delete_related() con1.delete() con2.delete()
def add_term(request): '''add_term will add a new term to the atlas ''' if request.method == "POST": term_type = request.POST.get('term_type', '') term_name = request.POST.get('term_name', '') definition_text = request.POST.get('definition_text', '') properties = None if definition_text != '': properties = {"definition": definition_text} if term_type == "concept": node = Concept.create(name=term_name, properties=properties) return view_concept(request, node["id"]) elif term_type == "task": node = Task.create(name=term_name, properties=properties) return view_task(request, node["id"])
def setUp(self): concept = Concept() self.con1 = concept.create("test_view_concept", {"prop": "prop"}) self.con2 = concept.create("test_view_concept2", {"prop": "prop"})