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

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

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

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

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

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

    def test_automatic_tour(self):
        """
        Thist test checks that the tour starts automatically after signup, only
        once.
        """
        self.browser.is_element_present_by_id('wait_for_cookie_tour', 3)
        signin(self, 'bob', 'bob_secret')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertEqual(exist, True))
        self.browser.visit(self.live_server_url + '/dashboard/')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertNotEqual(exist, True))
Example #2
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()
Example #3
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.'))
Example #4
0
class DashboardTestCase(LiveServerTestCase):
    """
    These tests check basic functions of Sylva's dashboard.
    """

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

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

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

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

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

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

    def test_automatic_tour(self):
        """
        Thist test checks that the tour starts automatically after signup, only
        once.
        """
        self.browser.is_element_present_by_id('wait_for_cookie_tour', 3)
        signin(self, 'bob', 'bob_secret')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertEqual(exist, True))
        self.browser.visit(self.live_server_url + '/dashboard/')
        exist = self.browser.is_element_present_by_xpath(
            "//div[@class='joyride-content-wrapper']")
        spin_assert(lambda: self.assertNotEqual(exist, True))
Example #5
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.'))