예제 #1
0
    def test_alter_number_segment(self):
        """
        alter existing number segment
        """
        for security in self.operator.company.security_set.all():
            security.number_segments = [1, 2]
            security.track_numbers = True
            security.save()

        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.wait_until_visible((By.CLASS_NAME, 'security'))
            p.click_to_edit("security")
            p.enter_string("security", ", 88, 99-100", clear=True)
            p.save_edit("security")

            # wait for form to disappear
            p.wait_until_invisible((By.CSS_SELECTOR, '.tr.security form'))
            time.sleep(1)  # FIXME replace by wait

        except Exception, e:
            self._handle_exception(e)
예제 #2
0
    def test_edit_founding_date_76(self):
        """
        edit companies founding_date using the datepicker
        """
        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:

            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_to_edit("founding-date")
            p.click_open_datepicker("founding-date")
            p.click_date_in_datepicker("founding-date")
            p.save_edit("founding-date")

            # wait for form to disappear
            p.wait_until_invisible((By.CSS_SELECTOR, '.tr.founding-date form'))

            today = datetime.datetime.now().date()
            founding_date = datetime.date(today.year, today.month, 1)

            time.sleep(1)
            self.assertEqual(p.get_founding_date(),
                             founding_date.strftime('%d.%m.%y'))

        except Exception as e:
            self._handle_exception(e)

        self.assertEqual(
            Company.objects.get(id=self.operator.company.id).founded_at,
            founding_date)
예제 #3
0
    def test_add_number_segment(self):
        """
        add number segement to existing one
        """
        for s in self.operator.company.security_set.all():
            s.track_numbers = True
            s.save()

        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.wait_until_visible((By.CLASS_NAME, 'security'))
            p.click_to_edit("security")
            p.enter_string("security", "88, 99-100")
            p.save_edit("security")

            # wait for form to disappear
            p.wait_until_invisible((By.CSS_SELECTOR, '.tr.security form'))
            p.refresh()
            p.wait_until_visible((By.CSS_SELECTOR, '.tr.security'))
            p.wait_until_js_rendered()
            self.assertIn("88, 99-100", self.selenium.page_source)

        except Exception, e:
            self._handle_exception(e)
예제 #4
0
    def test_no_numbered_shares(self):
        """
        test that company without numbered shares does not see anything
        """
        try:
            page.CompanyPage(self.selenium, self.live_server_url,
                             self.operator.user, self.operator.company)

        except Exception, e:
            self._handle_exception(e)
예제 #5
0
 def test_delete_operator(self):
     operator = OperatorGenerator().generate(company=self.operator.company)
     try:
         p = page.CompanyPage(self.selenium, self.live_server_url,
                              self.operator.user, self.operator.company)
         p.click_remove_operator(operator)
         self.assertFalse(p.is_operator_displayed(operator.user.email))
         self.assertFalse(
             self.operator.company.operator_set.filter(
                 user=operator.user).exists())
     except Exception, e:
         self._handle_exception(e)
예제 #6
0
    def test_add_new_operator_invalid_user(self):
        """ means: create a option plan and move options for users """

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_open_add_new_operator_form()
            p.enter_new_operator_email('*****@*****.**')
            p.click_save_new_operator()
            self.assertFalse(p.is_operator_displayed('*****@*****.**'))
            self.assertFalse(User.objects.filter(email='*****@*****.**').exists())
        except Exception, e:
            self._handle_exception(e)
예제 #7
0
    def test_no_numbered_shares(self):
        """
        test that company without numbered shares does not see anything
        """
        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)

        except Exception, e:
            self._handle_exception(e)
예제 #8
0
    def test_add_number_segment(self):

        for s in self.operator.company.security_set.all():
            s.track_numbers = True
            s.save()

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_to_edit("security")
            p.enter_string("security", "88, 99-100")
            p.save_edit("security")

        except Exception, e:
            self._handle_exception(e)
예제 #9
0
    def test_save_invalid_number_segment(self):

        security = self.operator.company.security_set.all()[0]
        security.number_segments = [1, 2]
        security.track_numbers = True
        security.save()

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_to_edit("security")
            p.enter_string("security", ";X, 88, 99-100")
            p.save_edit("security")

        except Exception, e:
            self._handle_exception(e)
예제 #10
0
    def test_add_new_operator(self):
        """ means: create a option plan and move options for users """

        user = UserGenerator().generate()

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_open_add_new_operator_form()
            p.enter_new_operator_email(user.email)
            p.click_save_new_operator()
            self.assertTrue(p.is_operator_displayed(user.email))
            self.assertTrue(
                user.operator_set.filter(
                    company=self.operator.company).exists())
        except Exception, e:
            self._handle_exception(e)
예제 #11
0
    def test_add_new_operator_invalid_user(self):
        """ means: create a option plan and move options for users """
        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_open_add_new_operator_form()
            email = '*****@*****.**'
            p.enter_new_operator_email(email)
            p.click_save_new_operator()
            # wait for error
            p.wait_until_visible((By.CSS_SELECTOR, '.form-error'))
            self.assertFalse(email in p.driver.page_source)
            self.assertFalse(User.objects.filter(email=email).exists())
        except Exception, e:
            self._handle_exception(e)
예제 #12
0
    def test_delete_operator(self):
        # securities require a subscription
        self.add_subscription(self.operator.company)

        operator = OperatorGenerator().generate(company=self.operator.company)
        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_remove_operator(operator)
            p.wait_until_invisible(
                (By.XPATH,
                 u'//div[contains(text(), "{}")]'.format(operator.user.email)))

            self.assertFalse(p.is_operator_displayed(operator.user.email))
            self.assertFalse(
                self.operator.company.operator_set.filter(
                    user=operator.user).exists())
        except Exception, e:
            self._handle_exception(e)
예제 #13
0
    def test_reset_company(self):
        """
        reset company and related data and it's redirect to the new data form
        """
        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            user = self.operator.user

            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_reset_company()
            p.confirm_reset_company()

            self.assertFalse(user.operator_set.exists())
            self.assertIn('/start/', p.driver.current_url)

        except Exception, e:
            self._handle_exception(e)
예제 #14
0
    def test_edit_founding_date_76(self):
        """
        edit companies founding_date using the datepicker
        """
        try:

            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_to_edit("founding-date")
            p.click_open_datepicker("founding-date")
            p.click_date_in_datepicker("founding-date")
            p.save_edit("founding-date")

            today = datetime.datetime.now().date()
            founding_date = datetime.date(today.year, today.month, 1)
            time.sleep(1)
            self.assertEqual(p.get_founding_date(),
                             founding_date.strftime('%d.%m.%y'))

        except Exception, e:
            self._handle_exception(e)
예제 #15
0
    def test_add_new_operator(self):
        """ means: create a option plan and move options for users """
        # securities require a subscription
        self.add_subscription(self.operator.company)

        user = UserGenerator().generate()

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.click_open_add_new_operator_form()
            p.enter_new_operator_email(user.email)
            p.click_save_new_operator()
            p.wait_until_visible(
                (By.XPATH,
                 u'//div[@id="company"]//div[contains(@class, "operators")]'
                 u'//div[contains(@class, "tr")]//div[contains(text(), "{}")]'
                 u''.format(user.email)))
            self.assertTrue(p.is_operator_displayed(user.email))
            self.assertTrue(
                user.operator_set.filter(
                    company=self.operator.company).exists())
        except Exception, e:
            self._handle_exception(e)
예제 #16
0
    def test_save_invalid_number_segment(self):

        for security in self.operator.company.security_set.all():
            security.number_segments = [1, 2]
            security.track_numbers = True
            security.save()

        # securities require a subscription
        self.add_subscription(self.operator.company)

        try:
            p = page.CompanyPage(self.selenium, self.live_server_url,
                                 self.operator.user, self.operator.company)
            p.wait_until_visible((By.CLASS_NAME, 'security'))
            p.click_to_edit("security")
            p.enter_string("security", ";X, 88, 99-100")
            p.save_edit("security")

            # wait for error
            # NOTE: this is kind of duplicate to the assertTrue below
            p.wait_until_visible((By.CSS_SELECTOR, '.editable-error'))

        except Exception, e:
            self._handle_exception(e)