예제 #1
0
class DashboardTestCase(LiveServerTestCase):
    """
    These tests check basic functions of Sylva's dashboard.
    """
    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)
        signup(self, 'bob', '*****@*****.**', 'bob_secret')

    def tearDown(self):
        logout(self)
        self.browser.quit()

    @classmethod
    def tearDownClass(cls):
        sleep(10)  # It needs some time for close the LiverServerTestCase
        super(DashboardTestCase, cls).tearDownClass()

    def test_dashboard(self):
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEquals(self.browser.title,
                                              'SylvaDB - Dashboard'))
        text = self.browser.find_by_xpath(
            "//header[@class='global']/h1").first.value
        spin_assert(lambda: self.assertEqual(text, 'Dashboard'))

    def test_dashboard_new_graph(self):
        signin(self, 'bob', 'bob_secret')
        create_graph(self)
        Graph.objects.get(name="Bob's graph").destroy()

    def test_dashboard_graph_preview(self):
        """
        This test, after create a graph with data, checks the Sigma
        visualization running a simple JavaScript code. This code gets the
        current instance of Sigma and checks the data with Sylva JavaScript
        object.
        """
        signin(self, 'bob', 'bob_secret')
        create_graph(self)
        create_schema(self)
        create_type(self)
        create_data(self)
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.is_element_present_by_id('wait_for_js', 3)
        js_code = '''
            var instance = sigma.instances(0);
            var node = instance.graph.nodes()[0];
            sylva.test_node_name = node.properties.Name;
            '''
        self.browser.execute_script(js_code)
        text = self.browser.evaluate_script('sylva.test_node_name')
        Graph.objects.get(name="Bob's graph").destroy()
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's node"), -1))

    def test_automatic_tour(self):
        """
        Thist test checks that the tour starts automatically after signup, only
        once.
        """
        self.browser.is_element_present_by_id('wait_for_cookie_tour', 3)
        signin(self, 'bob', 'bob_secret')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertEqual(exist, True))
        self.browser.visit(self.live_server_url + '/dashboard/')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertNotEqual(exist, True))
예제 #2
0
파일: bug.py 프로젝트: CulturePlex/Sylva
class BugTestCase(LiveServerTestCase):
    """
    A set of tests to check the existence of bugs.
    """

    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')

    def tearDown(self):
        logout(self)
        self.browser.quit()
        Graph.objects.get(name="Bob's graph").destroy()

    @classmethod
    def tearDownClass(cls):
        sleep(10)  # It needs some time for close the LiverServerTestCase
        super(BugTestCase, cls).tearDownClass()

    def test_node_rel_count_one(self):
        '''
        This test show that reflexive outgoing `relationships` don't count if
        there are more relationships.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        rels = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(
            str(real_nodes) + " nodes", nodes))
        spin_assert(lambda: self.assertEqual(
            str(real_rels) + " relationships", rels))

    def test_node_rel_count_two(self):
        '''
        This test shows that new `nodes` with relationships don't count.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        rels = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(
            str(real_nodes) + " nodes", nodes))
        spin_assert(lambda: self.assertEqual(
            str(real_rels) + " relationships", rels))

    def test_node_rel_count_three(self):
        '''
        This test show that reflexive outgoing `relationships` DO count if
        there are NO more relationships.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToFirst" outgoing relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[0].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        rels = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(
            str(real_nodes) + " nodes", nodes))
        spin_assert(lambda: self.assertEqual(
            str(real_rels) + " relationships", rels))

    def test_node_rel_count_four(self):
        '''
        This test show that when there are reflexive incoming `relationships`
        only count those.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath("//a[@class='addButton inFormsets']")[2].click()
        # Adding the relationships
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[4].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input")[5].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input").first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        rels = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(
            str(real_nodes) + " nodes", nodes))
        spin_assert(lambda: self.assertEqual(
            str(real_rels) + " relationships", rels))
예제 #3
0
파일: bug.py 프로젝트: anukat2015/Sylva
class BugTestCase(LiveServerTestCase):
    """
    A set of tests to check the existence of bugs.
    """
    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')

    def tearDown(self):
        logout(self)
        self.browser.quit()
        Graph.objects.get(name="Bob's graph").destroy()

    @classmethod
    def tearDownClass(cls):
        sleep(10)  # It needs some time for close the LiverServerTestCase
        super(BugTestCase, cls).tearDownClass()

    def test_node_rel_count_one(self):
        '''
        This test show that reflexive outgoing `relationships` don't count if
        there are more relationships.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath(
            "//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-nodes']"
        ).first.value
        rels = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-relationships']"
        ).first.value
        spin_assert(
            lambda: self.assertEqual(str(real_nodes) + " nodes", nodes))
        spin_assert(
            lambda: self.assertEqual(str(real_rels) + " relationships", rels))

    def test_node_rel_count_two(self):
        '''
        This test shows that new `nodes` with relationships don't count.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath(
            "//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-nodes']"
        ).first.value
        rels = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-relationships']"
        ).first.value
        spin_assert(
            lambda: self.assertEqual(str(real_nodes) + " nodes", nodes))
        spin_assert(
            lambda: self.assertEqual(str(real_rels) + " relationships", rels))

    def test_node_rel_count_three(self):
        '''
        This test show that reflexive outgoing `relationships` DO count if
        there are NO more relationships.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath(
            "//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToFirst" outgoing relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[0].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-nodes']"
        ).first.value
        rels = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-relationships']"
        ).first.value
        spin_assert(
            lambda: self.assertEqual(str(real_nodes) + " nodes", nodes))
        spin_assert(
            lambda: self.assertEqual(str(real_rels) + " relationships", rels))

    def test_node_rel_count_four(self):
        '''
        This test show that when there are reflexive incoming `relationships`
        only count those.
        '''
        real_nodes = 0
        real_rels = 0
        create_graph(self)
        create_schema(self)
        # Creating a nodetype: "First"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("First")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        # Creating another nodetype: "Second"
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        self.browser.find_by_name('name').first.fill("Second")
        self.browser.find_by_name('properties-0-key').first.fill('Name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_value('Save Type').first.click()
        self.browser.find_by_id('dataMenu').first.click()
        # Creating an allowed relationship: "First -> First"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToFirst')
        self.browser.select('target', '1')
        self.browser.find_by_value('Save Type').first.click()
        # Creating an allowed relationship: "First -> Second"
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill('FirstToSecond')
        self.browser.select('target', '2')
        self.browser.find_by_value('Save Type').first.click()
        # Creating a node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "First" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating a node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second1")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second2")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Creating another node of the "Second" type
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[1].click()
        self.browser.find_by_name('Name').first.fill("Second3")
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Editing the "First1" node
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']")[0].click()
        self.browser.find_by_xpath(
            "//td[@class='dataList']/a[@class='edit']").first.click()
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[0].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First1"
        self.browser.find_by_value('Save First').first.click()
        # Creating another node of the "First" type with relationships
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption new']")[0].click()
        self.browser.find_by_name('Name').first.fill("First3")
        # Adding more "FirstToSecond" relationship forms
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[1].click()
        self.browser.find_by_xpath(
            "//a[@class='addButton inFormsets']")[2].click()
        # Adding the relationships
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[1].fill('Second1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[2].fill('Second2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[3].fill('Second3')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[4].fill('First1')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        self.browser.find_by_xpath(
            "//li[@class='token-input-input-token']/input")[5].fill('First2')
        self.browser.is_element_present_by_id("id_user_wait", 3)
        self.browser.find_by_xpath(
            "//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b"
        ).first.click()
        real_rels += 1
        # Saving "First3"
        self.browser.find_by_xpath(
            "//span[@class='buttonLinkOption buttonLinkLeft']/input"
        ).first.click()
        real_nodes += 1
        # Checking the counts
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        nodes = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-nodes']"
        ).first.value
        rels = self.browser.find_by_xpath(
            "//div[@class='flags-block']/span[@class='graph-relationships']"
        ).first.value
        spin_assert(
            lambda: self.assertEqual(str(real_nodes) + " nodes", nodes))
        spin_assert(
            lambda: self.assertEqual(str(real_rels) + " relationships", rels))
예제 #4
0
class DashboardTestCase(LiveServerTestCase):
    """
    These tests check basic functions of Sylva's dashboard.
    """

    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)
        signup(self, 'bob', '*****@*****.**', 'bob_secret')

    def tearDown(self):
        logout(self)
        self.browser.quit()

    @classmethod
    def tearDownClass(cls):
        sleep(10)  # It needs some time for close the LiverServerTestCase
        super(DashboardTestCase, cls).tearDownClass()

    def test_dashboard(self):
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEquals(self.browser.title,
                                              'SylvaDB - Dashboard'))
        text = self.browser.find_by_xpath(
            "//header[@class='global']/h1").first.value
        spin_assert(lambda: self.assertEqual(text, 'Dashboard'))

    def test_dashboard_new_graph(self):
        signin(self, 'bob', 'bob_secret')
        create_graph(self)
        Graph.objects.get(name="Bob's graph").destroy()

    def test_dashboard_graph_preview(self):
        """
        This test, after create a graph with data, checks the Sigma
        visualization running a simple JavaScript code. This code gets the
        current instance of Sigma and checks the data with Sylva JavaScript
        object.
        """
        signin(self, 'bob', 'bob_secret')
        create_graph(self)
        create_schema(self)
        create_type(self)
        create_data(self)
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.is_element_present_by_id('wait_for_js', 3)
        js_code = '''
            var instance = sigma.instances(0);
            var node = instance.graph.nodes()[0];
            sylva.test_node_name = node.properties.Name;
            '''
        self.browser.execute_script(js_code)
        text = self.browser.evaluate_script('sylva.test_node_name')
        Graph.objects.get(name="Bob's graph").destroy()
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's node"), -1))

    def test_automatic_tour(self):
        """
        Thist test checks that the tour starts automatically after signup, only
        once.
        """
        self.browser.is_element_present_by_id('wait_for_cookie_tour', 3)
        signin(self, 'bob', 'bob_secret')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertEqual(exist, True))
        self.browser.visit(self.live_server_url + '/dashboard/')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertNotEqual(exist, True))
예제 #5
0
class DataNodeTestCase(LiveServerTestCase):
    """
    A set of tests to test all interaction related to the creation and
    deletion of nodes and relationships. Also, we test export the data in two
    formats: gexf and csv.
    """

    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')

    def tearDown(self):
        logout(self)
        self.browser.quit()

    @classmethod
    def tearDownClass(cls):
        sleep(10)  # It needs some time for close the LiverServerTestCase
        super(DataNodeTestCase, cls).tearDownClass()

    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'))

    def test_data_node_addition_rel_add_del(self):
        create_graph(self)
        create_schema(self)
        create_type(self)
        create_node(self, "Bob")
        create_node(self, "Alice")
        # We create a allowed relation
        js_code = "$('a#schema-link')[0].click();"
        self.browser.execute_script(js_code)
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill("Bob's rel")
        self.browser.select('target', '1')
        self.browser.find_by_id('id_description').fill("This the allowed relationship for Bob's graph")
        self.browser.find_by_value('Save Type').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - Bob's graph"))
        # We create the link between the nodes
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
        self.browser.is_element_present_by_id("id_user_wait", 5)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        self.browser.find_by_value("Save Bob's type").first.click()
        # Delete the relationship
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        self.browser.find_by_xpath("//span[@class='all-relationships outgoing-relationships o_bobs_rel1-relationships']/span/a[@class='delete-row initial-form floating']").first.click()
        self.browser.find_by_value("Save Bob's type").first.click()
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(text, "0 relationships"))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_node_type_deletion_keeping_nodes(self):
        create_graph(self)
        create_schema(self)
        create_type(self)
        # Adding relationship to the type
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill("Bob's rel")
        self.browser.select('target', '1')
        self.browser.find_by_id('id_description').fill(
            'The loved relationship')
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='form-row indent']/label").first.value
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's rel"), -1))
        # Creating nodes
        create_node(self, 'Bob')
        create_node(self, 'Alice')
        # Creating relationship between nodes
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
        self.browser.is_element_present_by_id("id_user_wait", wait_time=5)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        self.browser.find_by_value("Save Bob's type").first.click()
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(text, "1 relationships"))
        # Deleting type
        js_code = "$('a#schema-link')[0].click();"
        self.browser.execute_script(js_code)
        self.browser.find_by_xpath("//fieldset[@class='module aligned wide model']/h2/a").first.click()
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[@class='delete']").first.click()
        text = self.browser.find_by_xpath(
            "//p/label[@for='id_option_0']").first.value
        spin_assert(lambda: self.assertNotEqual(text.find(
            "We found some elements of this type"), -1))
        # Keeping nodes
        self.browser.choose('option', 'no')
        self.browser.find_by_value('Continue').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='body-inside']/p").first.value
        spin_assert(lambda: self.assertEqual(
            text, 'There are no types defined yet.'))
        # Checking
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        spin_assert(lambda: self.assertEqual(text, "2 nodes"))
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(text, "1 relationships"))
        text = self.browser.find_by_xpath(
            "//div[@class='graph-empty-message']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find("Your Schema is empty."), -1))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_node_type_deletion_deleting_nodes(self):
        create_graph(self)
        create_schema(self)
        create_type(self)
        # Adding relationship to the type
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill("Bob's rel")
        self.browser.select('target', '1')
        self.browser.find_by_id('id_description').fill(
            'The loved relationship')
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='form-row indent']/label").first.value
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's rel"), -1))
        # Creating nodes
        create_node(self, 'Bob')
        create_node(self, 'Alice')
        # Creating relationship between nodes
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
        self.browser.is_element_present_by_id("id_user_wait", wait_time=5)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        self.browser.find_by_value("Save Bob's type").first.click()
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(text, "1 relationships"))
        # Deleting type
        js_code = "$('a#schema-link')[0].click();"
        self.browser.execute_script(js_code)
        self.browser.find_by_xpath("//fieldset[@class='module aligned wide model']/h2/a").first.click()
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[@class='delete']").first.click()
        text = self.browser.find_by_xpath(
            "//p/label[@for='id_option_0']").first.value
        spin_assert(lambda: self.assertNotEqual(text.find(
            "We found some elements of this type"), -1))
        # Deleting nodes
        self.browser.choose('option', 'de')
        self.browser.find_by_value('Continue').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='body-inside']/p").first.value
        spin_assert(lambda: self.assertEqual(
            text, 'There are no types defined yet.'))
        # Checking
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-nodes']").first.value
        spin_assert(lambda: self.assertEqual(text, "0 nodes"))
        text = self.browser.find_by_xpath("//div[@class='flags-block']/span[@class='graph-relationships']").first.value
        spin_assert(lambda: self.assertEqual(text, "0 relationships"))
        Graph.objects.get(name="Bob's graph").destroy()

    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()

    def test_sigma_visualization_in_node_view(self):
        create_graph(self)
        create_schema(self)
        create_type(self)
        # Adding relationship to the type
        self.browser.find_by_id('allowedRelations').first.click()
        self.browser.select('source', '1')
        self.browser.find_by_name('name').fill("Bob's rel")
        self.browser.select('target', '1')
        self.browser.find_by_id('id_description').fill(
            'The loved relationship')
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='form-row indent']/label").first.value
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's rel"), -1))
        # Creating nodes
        create_node(self, 'Bob')
        create_node(self, 'Alice')
        # Creating relationship between nodes
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption list']").first.click()
        self.browser.find_by_xpath("//td[@class='dataList']/a[@class='edit']").first.click()
        self.browser.find_by_xpath("//li[@class='token-input-input-token']/input").first.fill('Alice')
        self.browser.is_element_present_by_id("id_user_wait", wait_time=5)
        self.browser.find_by_xpath("//div[@class='token-input-dropdown']//li[@class='token-input-dropdown-item2 token-input-selected-dropdown-item']/b").first.click()
        self.browser.find_by_value("Save Bob's type").first.click()
        # Checking
        self.browser.find_by_xpath("//table[@id='content_table']/tbody/tr/td/a[@title='View node']/p[text()='Alice']").first.click()
        self.browser.is_element_present_by_id('wait_for_js', 3)
        js_code = '''
            var instance = sigma.instances(0);
            sylva.test_node_count = instance.graph.nodes().length;
            '''
        self.browser.execute_script(js_code)
        text = self.browser.evaluate_script('sylva.test_node_count')
        spin_assert(lambda: self.assertEqual(text, 2))
        Graph.objects.get(name="Bob's graph").destroy()

    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)
        spin_assert(lambda: self.assertEqual(
            result.headers['content-type'], 'application/xml'))
        spin_assert(lambda: self.assertEqual(
            self.browser.status_code.is_success(), True))
        fw = open('sylva/sylva/tests/files/bobs-graph.gexf', 'w')
        fw.write(result.content)
        fw.close()
        f = open('sylva/sylva/tests/files/bobs-graph.gexf')
        xmlFile = ""
        for line in f:
            xmlFile += line
        f.close()
        spin_assert(lambda: self.assertEqual(xmlFile, result.content))
        Graph.objects.get(name="Bob's graph").destroy()

    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()