Exemplo n.º 1
0
 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')
     self.firstGraphName = "bobgraph"
     self.secondGraphName = "alicegraph"
Exemplo n.º 2
0
def main():
    """Main entry point for the script"""
    parser = argparse.ArgumentParser(
        prog='PyVegan',
        description='The better way to collect some delicious vegan recipes!',
        usage="""
        PyVegan - Get delicious vegan recipes from the web!
        Usage: pyvegan [-s/--search ingredient_to_search]


        Examples:
        - Get recipes with potato
            $ pyvegan -s batata
        - Get recipes that use more than one ingredient
            $ pyvegan -s "batata e tomate"

        How to get basic options and help? Use -h/--help
        """,
    )
    parser.add_argument('-s',
                        '--search',
                        type=str,
                        help='Get recipes using the given ingredients')

    options = parser.parse_args()

    if options.search:
        param = options.search
    else:
        param = ''

    try:
        browser = Browser()
        browser.search(param)
        content = browser.page_content()
    except requests.ConnectionError:
        print('A connection problem occurred.')
    except requests.Timeout:
        print('A timeout problem occurred.')
    except requests.TooManyRedirects:
        msg = ('The request exceeds the configured'
               ' number of maximum redirections.')
        print(msg)
    except Exception as e:
        print(e)

    if not content:
        return

    recipeManager = RecipeManager(content)
    recipes = recipeManager.recipes

    menu = Menu(recipes)
    menu.build()
    menu.show()
Exemplo n.º 3
0
    def setup_class(self):
        """
        Подготовка тестового окружения. Запуск броузера если он не запущен.
        """
        browser = Browser()
        browser.browser_run(pytest.url, timeout=pytest.start_timeout)
        time.sleep(pytest.start_timeout)

        self.ocr = OCR(pytest.path_to_res,
                       search_accuracy=pytest.search_accuracy,
                       debug=pytest.debug_mode)
        self.mouse = Mouse()
        self.keyboard = Keyboard()
Exemplo n.º 4
0
 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')
     self.firstGraphName = "bobgraph"
     self.secondGraphName = "alicegraph"
Exemplo n.º 5
0
    def get_iwencai_token(self):
	token = None
	with Browser() as b:
	    b.get(self.iwencai_search_url)
	    content = b.content
	token_search = re.search(r'token":\s?"([^"]+)"', content)
	if token_search:
	    token = token_search.group(1)
	return token
class FunctionalTestCase(TestCase):

    def setUp(self):
        self.browser = Browser()
        self.web_app = self.browser.open_app('http://*****:*****@example.com')
        self.web_app.set_password('123456')
        self.web_app.submit_login()

    def tearDown(self):
        self.browser.close()

    def test_authentication(self):
        self.web_app.click_logout()

        self.assertEqual(self.web_app.page_title, 'Login page')

    def test_view_all_posts_and_create_post(self):
        post_title = 'another post title'
        post_content = 'another post content'

        self.web_app.click_posts()
        self.web_app.click_new_post()
        self.web_app.set_post_title(post_title)
        self.web_app.set_post_content(post_content)
        self.web_app.submit_post()

        self.assertIn(post_title, self.web_app.page_source)

    def test_view_one_post_and_create_post(self):
        post_title = 'just another post title'
        post_content = 'just another post content'

        self.web_app.click_posts()
        self.web_app.click_first_post()
        self.web_app.click_new_post()
        self.web_app.set_post_title(post_title)
        self.web_app.set_post_content(post_content)
        self.web_app.submit_post()

        self.assertIn(post_title, self.web_app.page_source)
Exemplo n.º 7
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))
Exemplo n.º 8
0
 def setUp(self):
     self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
     socket.setdefaulttimeout(30)
Exemplo n.º 9
0
class CollaboratorTestCase(LiveServerTestCase):
    """
    These tests check the permissions system creating two users: one creates a
    graph and gives permissions to the other, the other tests the permissions
    given.
    On these tests, is the developer who must keep the logic of the
    permissions. If he/she wants to give any permission to an user he/she must
    first creates the usar and then creates the collaboration adding the basic
    perrmission: 'chk_graph_view_graph'.
    The name of the tests self-explain the behaviour of them.
    """

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

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

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

    def test_graph_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)
        self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.visit(self.live_server_url + '/graphs/bobs-graph/')
        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()

    def test_graph_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)
        self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
        add_permission(self, 'alice', CREATE_COLLAB)
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        text = self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.value
        spin_assert(lambda: self.assertEqual(text, "Bob's graph"))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_graph_change_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)
        self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
        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("//div[@class='graph-item']/span[@class='graph-title']/a").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()

    def test_graph_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)
        self.browser.find_by_xpath("//div[@class='dashboard-graphs']/div/div/span[@class='graph-title']/a").first.click()
        add_permission(self, 'alice', CREATE_COLLAB)
        add_permission(self, 'alice', GRAPH_CHANGE)
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.click()
        self.browser.find_by_xpath(
            "//input[@id='id_name']").first.fill("Alice's graph")
        self.browser.find_by_xpath(
            "//form/input[@type='submit']").first.click()
        text = self.browser.find_by_xpath("//div[@class='graph-item']/span[@class='graph-title']/a").first.value
        spin_assert(lambda: self.assertEqual(text, "Alice's graph"))
        Graph.objects.get(name="Alice's graph").destroy()

    def test_schema_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)
        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(
            "//nav[@class='menu']/ul/li[3]/a").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()

    def test_schema_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)
        add_permission(self, 'alice', CREATE_COLLAB)
        add_permission(self, 'alice', SCHEMA_VIEW)
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.find_by_xpath(
            "//nav[@class='menu']/ul/li[3]/a").first.click()
        text = self.browser.find_by_xpath(
            "//fieldset[@class='module aligned wide model']/h2/a").first.value
        spin_assert(lambda: self.assertEqual(text, "Bob's type"))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_schema_change_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)
        add_permission(self, 'alice', CREATE_COLLAB)
        add_permission(self, 'alice', SCHEMA_VIEW)
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.find_by_xpath(
            "//nav[@class='menu']/ul/li[3]/a").first.click()
        self.browser.find_by_xpath("//fieldset[@class='module aligned wide model']/h2/a").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()

    def test_schema_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)
        add_permission(self, 'alice', CREATE_COLLAB)
        add_permission(self, 'alice', SCHEMA_VIEW)
        add_permission(self, 'alice', SCHEMA_CHANGE)
        logout(self)
        signin(self, 'alice', 'alice_secret')
        self.browser.find_link_by_href('/graphs/bobs-graph/').first.click()
        self.browser.find_by_xpath(
            "//nav[@class='menu']/ul/li[3]/a").first.click()
        self.browser.find_by_xpath("//fieldset[@class='module aligned wide model']/h2/a").first.click()
        self.browser.find_by_xpath(
            "//input[@id='id_name']").first.fill("Alice's type")
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkLeft']/input[@type='submit']").first.click()
        text = self.browser.find_by_xpath(
            "//fieldset[@class='module aligned wide model']/h2/a").first.value
        spin_assert(lambda: self.assertEqual(text, "Alice's type"))
        Graph.objects.get(name="Bob's graph").destroy()

    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()
        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(
            "//div[@class='heading']/h1").first.value
        spin_assert(lambda: self.assertNotEqual(text.find("403"), -1))
        Graph.objects.get(name="Bob's graph").destroy()

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

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

    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()
        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(
            "//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
        spin_assert(lambda: self.assertEqual(text, "Alice's node"))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_data_add_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)
        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()
        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 new']").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()

    def test_data_add_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)
        add_permission(self, 'alice', CREATE_COLLAB)
        add_permission(self, 'alice', DATA_VIEW)
        add_permission(self, 'alice', DATA_ADD)
        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 new']").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
        spin_assert(lambda: self.assertEqual(text, "Alice's node"))
        Graph.objects.get(name="Bob's graph").destroy()

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

    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()
        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()
        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
        spin_assert(lambda: self.assertNotEqual(text.find('Nodes: 0'), -1))
        Graph.objects.get(name="Bob's graph").destroy()
Exemplo n.º 10
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()
Exemplo n.º 11
0
 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')
Exemplo n.º 12
0
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))
Exemplo n.º 13
0
class UserTestCase(LiveServerTestCase):
    """
    A set of tests for testing Users, Accounts and UserProfiles. Also, we
    check the patterns for the required fields for signup, signin, the menu of
    user details, the change password view and the change email view.
    """

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

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

    def test_user_signup(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.find_by_css('.body-inside').first.value, 'Thank you for signing up with us!\nYou can now use the supplied credentials to signin.'))
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Signup almost done!'))

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

    def test_user_singup_empty_email(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_bad_email(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('bobcultureplex.ca')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'Enter a valid email address.'))

    def test_user_singup_empty_name(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_empty_password(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_password_unmatched(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_password')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, "The two password fields didn't match."))

    def test_user_signin(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        logout(self)

    def test_user_signin_empty_user(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('')
        self.browser.find_by_name('password').fill('bob_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'Either supply us with your email or username.'))

    def test_user_signin_bad_user(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('alice')
        self.browser.find_by_name('password').fill('bob_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Please enter a correct username or email and password. Note that both fields are case-sensitive.'))

    def test_user_signin_empty_password(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('bob')
        self.browser.find_by_name('password').fill('')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_signin_bad_password(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('bob')
        self.browser.find_by_name('password').fill('alice_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Please enter a correct username or email and password. Note that both fields are case-sensitive.'))

    def test_user_logout(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        logout(self)
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Signed out'))
        spin_assert(lambda: self.assertEqual(self.browser.find_by_css('.body-inside').first.value, 'You have been signed out. Till we meet again.'))

    def test_user_details(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('01/01/1975')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        logout(self)

    def test_user_details_bad_website(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('bobweb')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('01/01/1975')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Account setup'))
        logout(self)

    def test_user_details_bad_birthdate(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('birthdate')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Enter a valid date.'))
        logout(self)

    def test_user_details_future_birthdate(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file('mugshot', 'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90')
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('2020-01-11')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'You need to introduce a past date.'))
        logout(self)

    def test_user_change_pass(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Password changed'))
        logout(self)

    def test_user_change_pass_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))
        logout(self)

    def test_user_change_pass_incorrectly(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bad_password')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Your old password was entered incorrectly. Please enter it again.'))
        logout(self)

    def test_user_change_new_pass_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))
        logout(self)

    def test_user_change_new_pass_unmatched(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('alice_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, "The two password fields didn't match."))
        logout(self)

    def test_user_change_mail(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_value('Change email').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Email verification'))

    def test_user_change_mail_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('')
        self.browser.find_by_value('Change email').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_change_bad(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('bobnewcultureplex.ca')
        self.browser.find_by_value('Change email').first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'Enter a valid email address.'))
Exemplo n.º 14
0
class ToolsTestCaseCsv(LiveServerTestCase):
    """
    A master test to check the behaviour of the new 'auto' fields.
    Actually only works with gephi format.
    """

    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')
        self.firstGraphName = "bobgraph"
        self.secondGraphName = "alicegraph"

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

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

    def test_graph_export_csv(self):
        # Create a graph with a auto_user property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "e")
        create_advanced_data(self)
        # Create new graph for import the data
        import_advanced_schema_csv(self, self.firstGraphName, self.secondGraphName)
        # Data import
        self.browser.find_by_id('toolsMenu').first.click()
        self.browser.find_link_by_href('/tools/' + self.secondGraphName + '/import/').first.click()
        self.browser.find_by_id('csv-radio').first.click()
        # Change the display field of input to attach the file
        script = """
            $('#files').css('display', '');
            """
        self.browser.execute_script(script)
        self.browser.is_text_present('Drop your nodes files here', wait_time=10)
        # Import the nodes
        file_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'files/csv/bobs-type.csv'
        )
        self.browser.attach_file('file', file_path)
        self.browser.is_text_present('Nodes files loaded. Loading edges files...', wait_time=10)
        # Wait until the data is imported
        self.browser.is_text_present('Now drop your edges files', wait_time=10)
        # Change the display field of input to attach the file
        script = """
            $('#files2').css('display', '');
            """
        self.browser.execute_script(script)
        # Import the relationships
        file_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'files/csv/bobs-rels.csv'
        )
        self.browser.attach_file('file2', file_path)
        self.browser.is_text_present('Data loaded. Uploading to the server...', wait_time=10)
        # Wait until the data is imported
        self.browser.is_text_present('Data uploaded.', wait_time=10)
        # Check that nodes and relationships are ok
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//a[@class='dataOption list']").first.click()
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(3, alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(
            1, alicegraph.relationships.count()))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(
            alicegraphNodes + 1, alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()
Exemplo n.º 15
0
class ToolsTestCaseGexf(LiveServerTestCase):
    """
    A master test to check the behaviour of the new 'auto' fields.
    Actually only works with gephi format.
    """

    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')
        self.firstGraphName = "bobgraph"
        self.secondGraphName = "alicegraph"

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

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

    def test_graph_export_gexf_autoincrement(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "i")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(
            bobgraph.nodes.count(), alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(
            bobgraph.relationships.count(), alicegraph.relationships.count()))
        # We store the auto value to compare later
        alice_type = alicegraph.schema.nodetype_set.get()
        alice_properties = alice_type.properties.values()[0]
        alice_auto = alice_properties['auto']
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(
            alicegraphNodes + 1, alicegraph.nodes.count()))
        # We check the new value for auto
        alice_type_new = alicegraph.schema.nodetype_set.get()
        alice_properties_new = alice_type_new.properties.values()[0]
        alice_auto_new = alice_properties_new['auto']
        spin_assert(lambda: self.assertEqual(alice_auto + 1, alice_auto_new))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()

    '''
    def test_graph_export_gexf_autonow(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "a")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(
            bobgraph.nodes.count(), alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(
            bobgraph.relationships.count(), alicegraph.relationships.count()))
        # We store the auto now value to compare
        auto_now_date_bob = ""
        auto_now_date_alice = ""
        for node in bobgraph.nodes.all():
            auto_now_date_bob = node.properties.values()[0]
        for node in alicegraph.nodes.all():
            auto_now_date_alice = node.properties.values()[0]
        spin_assert(lambda: self.assertEqual(
            auto_now_date_bob, auto_now_date_alice))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(
            alicegraphNodes + 1, alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()
    '''

    def test_graph_export_gexf_autouser(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "e")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(
            bobgraph.nodes.count(), alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(
            bobgraph.relationships.count(), alicegraph.relationships.count()))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(
            alicegraphNodes + 1, alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()
Exemplo n.º 16
0
class UserTestCase(LiveServerTestCase):
    """
    A set of tests for testing Users, Accounts and UserProfiles. Also, we
    check the patterns for the required fields for signup, signin, the menu of
    user details, the change password view and the change email view.
    """
    def setUp(self):
        self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
        socket.setdefaulttimeout(30)

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

    def test_user_signup(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        spin_assert(lambda: self.assertEqual(
            self.browser.find_by_css('.body-inside').first.value,
            'Thank you for signing up with us!\nYou can now use the supplied credentials to signin.'
        ))
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Signup almost done!'))

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

    def test_user_singup_empty_email(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_bad_email(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('bobcultureplex.ca')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(
            lambda: self.assertEqual(text, 'Enter a valid email address.'))

    def test_user_singup_empty_name(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_empty_password(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('')
        self.browser.find_by_name('password2').fill('bob_secret')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_singup_password_unmatched(self):
        self.browser.visit(self.live_server_url + '/accounts/signup/')
        self.browser.find_by_name('username').fill('bob')
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_name('password1').fill('bob_secret')
        self.browser.find_by_name('password2').fill('bob_password')
        self.browser.find_by_value('Signup').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, "The two password fields didn't match."))

    def test_user_signin(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        logout(self)

    def test_user_signin_empty_user(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('')
        self.browser.find_by_name('password').fill('bob_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'Either supply us with your email or username.'))

    def test_user_signin_bad_user(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('alice')
        self.browser.find_by_name('password').fill('bob_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text,
            'Please enter a correct username or email and password. Note that both fields are case-sensitive.'
        ))

    def test_user_signin_empty_password(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('bob')
        self.browser.find_by_name('password').fill('')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_signin_bad_password(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        self.browser.visit(self.live_server_url + '/accounts/signin/')
        self.browser.find_by_name('identification').fill('bob')
        self.browser.find_by_name('password').fill('alice_secret')
        self.browser.find_by_xpath(
            "//div[@id='body']/div/form/input")[1].click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text,
            'Please enter a correct username or email and password. Note that both fields are case-sensitive.'
        ))

    def test_user_logout(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        logout(self)
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Signed out'))
        spin_assert(lambda: self.assertEqual(
            self.browser.find_by_css('.body-inside').first.value,
            'You have been signed out. Till we meet again.'))

    def test_user_details(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file(
            'mugshot',
            'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90'
        )
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('01/01/1975')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        logout(self)

    def test_user_details_bad_website(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file(
            'mugshot',
            'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90'
        )
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('bobweb')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('01/01/1975')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Account setup'))
        logout(self)

    def test_user_details_bad_birthdate(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file(
            'mugshot',
            'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90'
        )
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('birthdate')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Enter a valid date.'))
        logout(self)

    def test_user_details_future_birthdate(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/edit/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Account setup'))
        self.browser.find_by_name('first_name').fill('Bob')
        self.browser.find_by_name('last_name').fill('Doe')
        self.browser.attach_file(
            'mugshot',
            'http://www.gravatar.com/avatar/3d4bcca5d9c3a56a0282f308f9acda07?s=90'
        )
        self.browser.select('language', 'en')
        self.browser.select('gender', '1')
        self.browser.find_by_name('website').fill('http://www.bobweb.com')
        self.browser.find_by_name('location').fill('London, Ontario')
        self.browser.find_by_name('birth_date').fill('2020-01-11')
        self.browser.find_by_name('about_me').fill('I am a very nice guy')
        self.browser.find_by_name('institution').fill('University')
        self.browser.find_by_name('company').fill('CulturePlex')
        self.browser.find_by_name('lab').fill('CulturePlex')
        self.browser.find_by_value('Save changes').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, 'You need to introduce a past date.'))
        logout(self)

    def test_user_change_pass(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Password changed'))
        logout(self)

    def test_user_change_pass_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))
        logout(self)

    def test_user_change_pass_incorrectly(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bad_password')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text,
            'Your old password was entered incorrectly. Please enter it again.'
        ))
        logout(self)

    def test_user_change_new_pass_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('')
        self.browser.find_by_name('new_password2').fill('bob_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))
        logout(self)

    def test_user_change_new_pass_unmatched(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/password/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Change password'))
        self.browser.find_by_name('old_password').fill('bob_secret')
        self.browser.find_by_name('new_password1').fill('bob_password')
        self.browser.find_by_name('new_password2').fill('alice_password')
        self.browser.find_by_value('Change password').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(
            text, "The two password fields didn't match."))
        logout(self)

    def test_user_change_mail(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('*****@*****.**')
        self.browser.find_by_value('Change email').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Email verification'))

    def test_user_change_mail_empty(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('')
        self.browser.find_by_value('Change email').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))

    def test_user_change_bad(self):
        signup(self, 'bob', '*****@*****.**', 'bob_secret')
        signin(self, 'bob', 'bob_secret')
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             'SylvaDB - Dashboard'))
        self.browser.find_link_by_href('/accounts/bob/').first.click()
        spin_assert(lambda: self.assertEqual(self.browser.title,
                                             "SylvaDB - bob's profile."))
        self.browser.find_link_by_href('/accounts/bob/email/').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Welcome to The Sylva Project'))
        self.browser.find_by_name('email').fill('bobnewcultureplex.ca')
        self.browser.find_by_value('Change email').first.click()
        text = self.browser.find_by_xpath(
            "//ul[@class='errorlist']/li").first.text
        spin_assert(
            lambda: self.assertEqual(text, 'Enter a valid email address.'))
Exemplo n.º 17
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))
Exemplo n.º 18
0
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))
Exemplo n.º 19
0
 def setUp(self):
     self.browser = Browser()
     self.web_app = self.browser.open_app('http://*****:*****@example.com')
     self.web_app.set_password('123456')
     self.web_app.submit_login()
Exemplo n.º 20
0
 def setUp(self):
     self.browser = Browser(firefox_path=os.getenv('FIREFOX_PATH', None))
     socket.setdefaulttimeout(30)
     signup(self, 'bob', '*****@*****.**', 'bob_secret')
Exemplo n.º 21
0
class ToolsTestCaseGexf(LiveServerTestCase):
    """
    A master test to check the behaviour of the new 'auto' fields.
    Actually only works with gephi format.
    """
    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')
        self.firstGraphName = "bobgraph"
        self.secondGraphName = "alicegraph"

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

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

    def test_graph_export_gexf_autoincrement(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "i")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(bobgraph.nodes.count(),
                                             alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(bobgraph.relationships.count(),
                                             alicegraph.relationships.count()))
        # We store the auto value to compare later
        alice_type = alicegraph.schema.nodetype_set.get()
        alice_properties = alice_type.properties.values()[0]
        alice_auto = alice_properties['auto']
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='pagination']/span[@class='pagination-info']"
        ).first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(alicegraphNodes + 1,
                                             alicegraph.nodes.count()))
        # We check the new value for auto
        alice_type_new = alicegraph.schema.nodetype_set.get()
        alice_properties_new = alice_type_new.properties.values()[0]
        alice_auto_new = alice_properties_new['auto']
        spin_assert(lambda: self.assertEqual(alice_auto + 1, alice_auto_new))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()

    '''
    def test_graph_export_gexf_autonow(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "a")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(
            bobgraph.nodes.count(), alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(
            bobgraph.relationships.count(), alicegraph.relationships.count()))
        # We store the auto now value to compare
        auto_now_date_bob = ""
        auto_now_date_alice = ""
        for node in bobgraph.nodes.all():
            auto_now_date_bob = node.properties.values()[0]
        for node in alicegraph.nodes.all():
            auto_now_date_alice = node.properties.values()[0]
        spin_assert(lambda: self.assertEqual(
            auto_now_date_bob, auto_now_date_alice))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//div[@class='pagination']/span[@class='pagination-info']").first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(
            alicegraphNodes + 1, alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()
    '''

    def test_graph_export_gexf_autouser(self):
        # Create a graph with an auto_increment property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "e")
        create_advanced_data(self)
        # Schema export
        export_advanced_schema(self, self.firstGraphName)
        # Data export in gexf format
        data_export_gexf(self)
        # Create new graph for import the data
        import_advanced_schema(self, self.firstGraphName, self.secondGraphName)
        # Data import
        data_import_gexf(self)
        bobgraph = Graph.objects.get(name=self.firstGraphName)
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(bobgraph.nodes.count(),
                                             alicegraph.nodes.count()))
        spin_assert(lambda: self.assertEqual(bobgraph.relationships.count(),
                                             alicegraph.relationships.count()))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='pagination']/span[@class='pagination-info']"
        ).first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(alicegraphNodes + 1,
                                             alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()
Exemplo n.º 22
0
class SchemaTestCase(LiveServerTestCase):
    """
    A set of tests for testing export schema, import schema and everything
    related to advanced types (patterns, options, etc.).
    """

    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(SchemaTestCase, cls).tearDownClass()

    def test_export_schema(self):
        create_graph(self)
        create_schema(self)
        create_type(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 + '/schemas/bobs-graph/export/', cookies=cookies)
        spin_assert(lambda: self.assertEqual(
            result.headers['content-type'], 'application/json'))
        spin_assert(lambda: self.assertEqual(
            self.browser.status_code.is_success(), True))
        f = open('sylva/sylva/tests/files/bobs-graph_schema.json')
        spin_assert(lambda: self.assertEqual(
            f.read().split("\n")[0], result.content))

    def test_import_schema(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_by_id('schemaImport').first.click()
        file_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'files/bobs-graph_schema.json'
        )
        self.browser.attach_file('file', file_path)
        self.browser.find_by_value('Continue').first.click()
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - Bob's graph"))
        text = self.browser.find_by_id('diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Name"))

    def test_new_type(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_xpath(
            "//div[@class='content2-first']/p/textarea[@name='description']").first.fill('The loved type')
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_xpath(
            "//div[@id='diagramBox_bobs-type']/div[@class='title']").first.value
        spin_assert(lambda: self.assertNotEqual(text.find("Bob's type"), -1))

    def test_new_advanced_type(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        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_name('properties-0-required').first.check()
        self.browser.find_by_name('properties-0-default').first.fill(
            "Bob's node default name")
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Name"))

    def test_new_advanced_type_string_empty(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('String name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='s']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "String name"))
        # Testing data
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption new']").first.click()
        self.browser.find_by_name('String name').first.fill('')
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'This field is required.'))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_new_advanced_type_boolean(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Boolean name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='b']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Boolean name"))

    def test_new_advanced_type_number(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Number name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='n']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Number name"))

    def test_new_advanced_type_number_float(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Number name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='n']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Number name"))
        # Testing data
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption new']").first.click()
        self.browser.find_by_name('Number name').first.fill('1.5')
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_css('input:invalid').first.value
        spin_assert(lambda: self.assertEqual(text, '1.5'))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_new_advanced_type_number_string(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Number name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Basic']/option[@value='n']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Number name"))
        # Testing data
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption new']").first.click()
        self.browser.find_by_name('Number name').first.fill('number')
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_css('input:invalid').first.outer_html
        spin_assert(lambda: self.assertEqual(
            text,
            '<input id="id_Number name" name="Number name" type="number">'))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_new_advanced_type_text(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Text name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='x']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Text name"))

    def test_new_advanced_type_date(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Date name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='d']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Date name"))

    def test_new_advanced_type_time(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Time name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='t']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Time name"))

    def test_new_advanced_type_time_string(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Time name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='t']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Time name"))
        # Testing data
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath("//td[@class='dataActions']/a[@class='dataOption new']").first.click()
        self.browser.find_by_name('Time name').first.fill('0123456789')
        sleep(5)  # Wating to the datepicker to open
        self.browser.find_by_xpath("//button[@class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all']").first.click()
        sleep(5)  # Waiting to the datepicker to close
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath("//ul[@class='errorlist']/li").first.text
        spin_assert(lambda: self.assertEqual(text, 'Enter a valid time.'))
        Graph.objects.get(name="Bob's graph").destroy()

    def test_new_advanced_type_choices(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('Choices name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='c']").first.click()
        self.browser.find_by_name('properties-0-default').first.fill('Bob, Alice')
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "Choices name"))

    def test_new_advanced_type_float(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('float name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='f']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "float name"))

    def test_new_advanced_type_collaborator(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('collaborator name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Advanced']/option[@value='r']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "collaborator name"))

    def test_new_advanced_type_auto_now(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('auto now name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='w']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "auto now name"))

    def test_new_advanced_type_auto_now_add(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('auto now add name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='a']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "auto now add name"))

    def test_new_advanced_type_auto_increment(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('auto increment name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='i']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "auto increment name"))

    def test_new_advanced_type_auto_increment_update(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('auto increment update')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='o']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "auto increment update"))

    def test_new_advanced_type_auto_user(self):
        create_graph(self)
        create_schema(self)
        self.browser.find_link_by_href(
            '/schemas/bobs-graph/types/create/').first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='content2-first']/h2").first.value
        spin_assert(lambda: self.assertEqual(text, 'Type'))
        self.browser.find_by_name('name').first.fill("Bob's type")
        self.browser.find_by_id('advancedModeButton').first.click()
        self.browser.find_by_name('properties-0-key').first.fill('auto user name')
        self.browser.find_by_name('properties-0-display').first.check()
        self.browser.find_by_name('properties-0-required').first.check()
        self.browser.find_by_xpath("//select[@id='id_properties-0-datatype']/optgroup[@label='Auto']/option[@value='e']").first.click()
        self.browser.find_by_name('properties-0-order').first.fill('1')
        self.browser.find_by_name('properties-0-description').first.fill(
            "The name of this Bob's node")
        self.browser.find_by_value('Save Type').first.click()
        text = self.browser.find_by_id(
            'diagramBoxField_bobs-graph.bobs-type.undefined').first.value
        spin_assert(lambda: self.assertEqual(text, "auto user name"))

    def test_schema_allowed_rel_addition(self):
        create_graph(self)
        spin_assert(lambda: self.assertEqual(
            self.browser.title, 'SylvaDB - Dashboard'))
        create_schema(self)
        create_type(self)
        spin_assert(lambda: self.assertEqual(
            self.browser.title, "SylvaDB - Bob's graph"))
        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"))
        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))

    def test_schema_allowed_rel_addition_deletion(self):
        create_graph(self)
        spin_assert(lambda: self.assertEqual(self.browser.title, 'SylvaDB - Dashboard'))
        create_schema(self)
        create_type(self)
        spin_assert(lambda: self.assertEqual(self.browser.title, "SylvaDB - Bob's graph"))
        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"))
        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))
        self.browser.find_by_xpath("//div[@class='form-row indent']/div[@class='form-row indent']/a").first.click()
        self.browser.find_by_xpath("//span[@class='buttonLinkOption buttonLinkRight']/a[@class='delete']").first.click()
        self.browser.choose('confirm', '1')
        self.browser.find_by_value('Continue').first.click()
        notExists = self.browser.is_element_not_present_by_xpath(
            "//div[@class='form-row indent']/label")
        spin_assert(lambda: self.assertEqual(notExists, True))
Exemplo n.º 23
0
class ToolsTestCaseCsv(LiveServerTestCase):
    """
    A master test to check the behaviour of the new 'auto' fields.
    Actually only works with gephi format.
    """
    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')
        self.firstGraphName = "bobgraph"
        self.secondGraphName = "alicegraph"

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

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

    def test_graph_export_csv(self):
        # Create a graph with a auto_user property
        create_graph(self, self.firstGraphName)
        create_advanced_schema(self, self.firstGraphName)
        create_advanced_type(self, self.firstGraphName, "e")
        create_advanced_data(self)
        # Create new graph for import the data
        import_advanced_schema_csv(self, self.firstGraphName,
                                   self.secondGraphName)
        # Data import
        self.browser.find_by_id('toolsMenu').first.click()
        self.browser.find_link_by_href('/tools/' + self.secondGraphName +
                                       '/import/').first.click()
        self.browser.find_by_id('csv-radio').first.click()
        # Change the display field of input to attach the file
        script = """
            $('#files').css('display', '');
            """
        self.browser.execute_script(script)
        self.browser.is_text_present('Drop your nodes files here',
                                     wait_time=10)
        # Import the nodes
        file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                 'files/csv/bobs-type.csv')
        self.browser.attach_file('file', file_path)
        self.browser.is_text_present(
            'Nodes files loaded. Loading edges files...', wait_time=10)
        # Wait until the data is imported
        self.browser.is_text_present('Now drop your edges files', wait_time=10)
        # Change the display field of input to attach the file
        script = """
            $('#files2').css('display', '');
            """
        self.browser.execute_script(script)
        # Import the relationships
        file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                 'files/csv/bobs-rels.csv')
        self.browser.attach_file('file2', file_path)
        self.browser.is_text_present('Data loaded. Uploading to the server...',
                                     wait_time=10)
        # Wait until the data is imported
        self.browser.is_text_present('Data uploaded.', wait_time=10)
        # Check that nodes and relationships are ok
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption list']").first.click()
        alicegraph = Graph.objects.get(name=self.secondGraphName)
        alicegraphNodes = alicegraph.nodes.count()
        spin_assert(lambda: self.assertEqual(3, alicegraph.nodes.count()))
        spin_assert(
            lambda: self.assertEqual(1, alicegraph.relationships.count()))
        # Add new nodes and relationships and check all is correct
        self.browser.find_by_id('dataMenu').first.click()
        self.browser.find_by_xpath(
            "//a[@class='dataOption new']").first.click()
        text = self.browser.find_by_id('propertiesTitle').first.value
        spin_assert(lambda: self.assertEqual(text, 'Properties'))
        self.browser.find_by_value("Save Bob's type").first.click()
        text = self.browser.find_by_xpath(
            "//div[@class='pagination']/span[@class='pagination-info']"
        ).first.value
        spin_assert(lambda: self.assertNotEqual(
            text.find(" elements Bob's type."), -1))
        spin_assert(lambda: self.assertEqual(alicegraphNodes + 1,
                                             alicegraph.nodes.count()))
        # Destroy the databases
        Graph.objects.get(name=self.firstGraphName).destroy()
        Graph.objects.get(name=self.secondGraphName).destroy()