示例#1
0
 def test_data_delete_with_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     add_permission(self, 'alice', DATA_VIEW)
     add_permission(self, 'alice', DATA_CHANGE)
     add_permission(self, 'alice', DATA_DELETE)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
     self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first.click()
     self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
     self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[text()='Remove']").first.click()
     self.browser.choose('confirm', '1')
     self.browser.find_by_xpath("//input[@type='submit']").first.click()
     text = self.browser.find_by_xpath(
         "//div[@id='content2']/div[@class='indent']").first.value
     self.assertNotEqual(text.find('Nodes: 0'), -1)
     Graph.objects.get(name="Bob's graph").destroy()
示例#2
0
 def test_graph_export_csv(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     self.browser.find_by_id('toolsMenu').first.click()
     cookies = {
         self.browser.cookies.all()[0]["name"]:
         self.browser.cookies.all()[0]["value"],
         self.browser.cookies.all()[1]["name"]:
         self.browser.cookies.all()[1]["value"]
     }
     result = requests.get(self.live_server_url +
                           '/tools/bobs-graph/export/csv/',
                           cookies=cookies)
     self.assertEqual(result.headers['content-type'], 'application/zip')
     self.assertEqual(self.browser.status_code.is_success(), True)
     test_file = StringIO(result.content)
     csv_zip = ZipFile(test_file)
     for name in csv_zip.namelist():
         fw = open('sylva/base/tests/files/' + name, 'w')
         fw.write(csv_zip.read(name))
         fw.close()
     for name in csv_zip.namelist():
         f = open('sylva/base/tests/files/' + name)
         csvFile = ""
         for line in f:
             csvFile += line
         f.close()
         self.assertEqual(csv_zip.read(name), csvFile)
     Graph.objects.get(name="Bob's graph").destroy()
示例#3
0
 def test_data_change_with_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     add_permission(self, 'alice', DATA_VIEW)
     add_permission(self, 'alice', DATA_CHANGE)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
     self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first.click()
     self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
     self.browser.find_by_xpath(
         "//input[@id='id_Name']").first.fill("Alice's node")
     self.browser.find_by_xpath("//input[@type='submit']").first.click()
     text = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[1].value
     self.assertEqual(text, "Alice's node")
     Graph.objects.get(name="Bob's graph").destroy()
示例#4
0
 def test_graph_export_csv(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     self.browser.find_by_id('toolsMenu').first.click()
     cookies = {self.browser.cookies.all()[0]["name"]: self.browser.cookies.all()[0]["value"], self.browser.cookies.all()[1]["name"]: self.browser.cookies.all()[1]["value"]}
     result = requests.get(self.live_server_url + '/tools/bobs-graph/export/csv/', cookies=cookies)
     spin_assert(lambda: self.assertEqual(
         result.headers['content-type'], 'application/zip'))
     spin_assert(lambda: self.assertEqual(
         self.browser.status_code.is_success(), True))
     test_file = StringIO(result.content)
     csv_zip = ZipFile(test_file)
     for name in csv_zip.namelist():
         fw = open('sylva/sylva/tests/files/' + name, 'w')
         fw.write(csv_zip.read(name))
         fw.close()
     for name in csv_zip.namelist():
         f = open('sylva/sylva/tests/files/' + name)
         csvFile = ""
         for line in f:
             csvFile += line
         f.close()
         spin_assert(lambda: self.assertEqual(csv_zip.read(name), csvFile))
     Graph.objects.get(name="Bob's graph").destroy()
示例#5
0
 def test_graph_export_gexf(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     self.browser.find_by_id('toolsMenu').first.click()
     cookies = {
         self.browser.cookies.all()[0]["name"]:
         self.browser.cookies.all()[0]["value"],
         self.browser.cookies.all()[1]["name"]:
         self.browser.cookies.all()[1]["value"]
     }
     result = requests.get(self.live_server_url +
                           '/tools/bobs-graph/export/gexf/',
                           cookies=cookies)
     self.assertEqual(result.headers['content-type'], 'application/xml')
     self.assertEqual(self.browser.status_code.is_success(), True)
     fw = open('sylva/base/tests/files/bobs-graph.gexf', 'w')
     fw.write(result.content)
     fw.close()
     f = open('sylva/base/tests/files/bobs-graph.gexf')
     xmlFile = ""
     for line in f:
         xmlFile += line
     f.close()
     self.assertEqual(xmlFile, result.content)
     Graph.objects.get(name="Bob's graph").destroy()
示例#6
0
 def test_data_delete_without_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     add_permission(self, 'alice', DATA_VIEW)
     add_permission(self, 'alice', DATA_CHANGE)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     spin_click(
         self.browser.find_by_xpath("//a[@id='dataMenu']").first,
         self.browser.find_by_xpath(
             "//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']"
         ).first)
     self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
     self.browser.find_by_xpath(
         "//span[@class='buttonLinkOption buttonLinkRight']/a[text()='Remove']"
     ).first.click()
     text = self.browser.find_by_xpath(
         "//div[@class='heading']/h1").first.value
     spin_assert(lambda: self.assertNotEqual(text.find("403"), -1))
     Graph.objects.get(name="Bob's graph").destroy()
示例#7
0
 def test_data_node_addition(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     # Check the node name
     self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
     text = self.browser.find_by_id('propertiesTitle').first.value
     spin_assert(lambda: self.assertEqual(text, 'Properties'))
     self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a").first.click()
     self.browser.choose('confirm', '1')
     self.browser.find_by_value('Continue').first.click()
     text = self.browser.find_by_xpath("//div[@class='indent']/div").first.value
     Graph.objects.get(name="Bob's graph").destroy()
     spin_assert(lambda: self.assertEqual(text, 'Nodes: 0'))
示例#8
0
 def test_data_node_clone(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     original_name = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[1].value
     # Clone the node
     self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td/a[@class='edit']").first.click()
     self.browser.find_by_name('Name').first.fill(original_name + " clone")
     self.browser.find_by_name("as-new").first.click()
     # Check that two nodes exist
     original_name = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[1].value
     clone_name = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[4].value
     spin_assert(lambda: self.assertEqual(original_name, "Bob's node"))
     spin_assert(lambda: self.assertEqual(clone_name, "Bob's node clone"))
     Graph.objects.get(name="Bob's graph").destroy()
示例#9
0
 def test_data_node_addition(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     # Check the node name
     self.browser.find_by_xpath(
         "//td[@class='dataList']/a[@class='edit']").first.click()
     text = self.browser.find_by_id('propertiesTitle').first.value
     self.assertEqual(text, 'Properties')
     self.browser.find_by_xpath(
         "//span[@class='buttonLinkOption buttonLinkRight']/a").first.click(
         )
     self.browser.choose('confirm', '1')
     self.browser.find_by_value('Continue').first.click()
     text = self.browser.find_by_xpath(
         "//div[@class='indent']/div").first.value
     Graph.objects.get(name="Bob's graph").destroy()
     self.assertEqual(text, 'Nodes: 0')
示例#10
0
 def test_data_view_without_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     self.browser.find_by_xpath("//a[@id='dataMenu']").first.click()
     self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first.click()
     text = self.browser.find_by_xpath(
         "//div[@class='heading']/h1").first.value
     self.assertNotEqual(text.find("403"), -1)
     Graph.objects.get(name="Bob's graph").destroy()
示例#11
0
 def test_data_view_with_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     add_permission(self, 'alice', DATA_VIEW)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     spin_click(self.browser.find_by_xpath("//a[@id='dataMenu']").first,
                                           self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first)
     text = self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td")[1].value
     spin_assert(lambda: self.assertEqual(text, "Bob's node"))
     Graph.objects.get(name="Bob's graph").destroy()
示例#12
0
 def test_graph_export_gexf(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     self.browser.find_by_id('toolsMenu').first.click()
     cookies = {self.browser.cookies.all()[0]["name"]: self.browser.cookies.all()[0]["value"], self.browser.cookies.all()[1]["name"]: self.browser.cookies.all()[1]["value"]}
     result = requests.get(self.live_server_url + '/tools/bobs-graph/export/gexf/', cookies=cookies)
     self.assertEqual(result.headers['content-type'], 'application/xml')
     self.assertEqual(self.browser.status_code.is_success(), True)
     fw = open('sylva/base/tests/files/bobs-graph.gexf', 'w')
     fw.write(result.content)
     fw.close()
     f = open('sylva/base/tests/files/bobs-graph.gexf')
     xmlFile = ""
     for line in f:
         xmlFile += line
     f.close()
     self.assertEqual(xmlFile, result.content)
     Graph.objects.get(name="Bob's graph").destroy()
示例#13
0
 def test_data_node_clone(self):
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     original_name = self.browser.find_by_xpath(
         "//table[@id='content_table']/tbody/tr/td")[1].value
     # Clone the node
     self.browser.find_by_xpath(
         "//table[@id='content_table']/tbody/tr/td/a[@class='edit']"
     ).first.click()
     self.browser.find_by_name('Name').first.fill(original_name + " clone")
     self.browser.find_by_name("as-new").first.click()
     # Check that two nodes exist
     original_name = self.browser.find_by_xpath(
         "//table[@id='content_table']/tbody/tr/td")[1].value
     clone_name = self.browser.find_by_xpath(
         "//table[@id='content_table']/tbody/tr/td")[4].value
     self.assertEqual(original_name, "Bob's node")
     self.assertEqual(clone_name, "Bob's node clone")
     Graph.objects.get(name="Bob's graph").destroy()
示例#14
0
 def test_data_delete_without_permissions(self):
     signup(self, 'alice', '*****@*****.**', 'alice_secret')
     signin(self, 'alice', 'alice_secret')
     logout(self)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
     signin(self, 'bob', 'bob_secret')
     create_graph(self)
     create_schema(self)
     create_type(self)
     create_data(self)
     add_permission(self, 'alice', CREATE_COLLAB)
     add_permission(self, 'alice', DATA_VIEW)
     add_permission(self, 'alice', DATA_CHANGE)
     logout(self)
     signin(self, 'alice', 'alice_secret')
     self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
     spin_click(self.browser.find_by_xpath("//a[@id='dataMenu']").first,
                                           self.browser.find_by_xpath("//div[@id='dataBrowse']/table/tbody/tr/td/a[@class='dataOption list']").first)
     self.browser.find_by_xpath("//td/a[@title='Edit node']").first.click()
     self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[text()='Remove']").first.click()
     text = self.browser.find_by_xpath(
         "//div[@class='heading']/h1").first.value
     spin_assert(lambda: self.assertNotEqual(text.find("403"), -1))
     Graph.objects.get(name="Bob's graph").destroy()