def test_unblock_holder_not_exists(self):
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.unblockDomainsId.side_effect = Registry.Administrative.NEW_OWNER_DOES_NOT_EXISTS(
         what='KONTAKT')
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'New holder KONTAKT does not exists.')
 def test_restore_domain_not_found(self):
     tc.fv(2, 'restore_prev_state', True)
     self.blocking_mock.restorePreAdministrativeBlockStatesId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_FOUND(
         what=[1])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) with id 1 not found\.')
 def test_unblock_domain_not_found(self):
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.unblockDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_FOUND(
         what=[1])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) with id 1 not found\.')
Ejemplo n.º 4
0
 def test_login_auth(self):
     """ test login page """
     self.general_login_action('user1', 'password1', 'Welcome, user1')
     go("%s/accounts/login/" % SITE)
     code(200)
     url('/accounts/profile/')
     find('Welcome, user1')
Ejemplo n.º 5
0
    def test_edit_email_address(self):
        # Opt out of the periodic emails. This way, the only "checked"
        # checkbox is the one for if the user's email address gets shown.
        paulproteus = Person.objects.get()
        paulproteus.email_me_re_projects = False
        paulproteus.save()

        self.login_with_twill()

        _url = "http://openhatch.org/account/settings/contact-info/"
        url = make_twill_url(_url)

        email = "*****@*****.**"

        # Go to contact info form
        tc.go(url)

        # Let's first ensure that "*****@*****.**" doesn't appear on the page.
        # (We're about to add it.)
        tc.notfind('checked="checked"')
        tc.notfind(email)

        # Edit email
        tc.fv("a_settings_tab_form", "edit_email-email", email)
        tc.submit()

        # Form submission ought to redirect us back to the form.
        tc.url(url)

        # Was email successfully edited?
        tc.find(email)

        # And does the email address show up on the profile?
        tc.go(make_twill_url("http://openhatch.org/people/1"))
        tc.find(email)
Ejemplo n.º 6
0
def dismod_server_login():
    """ login to the dismod server given in dismod3/settings.py."""
    
    twc.go(DISMOD_LOGIN_URL)
    twc.fv('1', 'username', DISMOD_USERNAME)
    twc.fv('1', 'password', DISMOD_PASSWORD)
    twc.submit()
    twc.url('accounts/profile')
 def test_restore_holder_not_exists(self):
     tc.fv(2, 'restore_prev_state', True)
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.restorePreAdministrativeBlockStatesId.side_effect = Registry.Administrative.NEW_OWNER_DOES_NOT_EXISTS(
         what='KONTAKT')
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'New holder KONTAKT does not exists.')
Ejemplo n.º 8
0
def dismod_server_login():
    """ login to the dismod server given in dismod3/settings.py."""

    twc.go(DISMOD_LOGIN_URL)
    twc.fv("1", "username", DISMOD_USERNAME)
    twc.fv("1", "password", DISMOD_PASSWORD)
    twc.submit()
    twc.url("accounts/profile")
Ejemplo n.º 9
0
 def test_reg_passwords_not_equal(self):
     """
     failed registration with entering not equal passwords
     """
     self.general_reg_action('user3',
                             '*****@*****.**',
                             'password3',
                             'password')
     url('accounts/register')
 def test_domain_not_blocked(self):
     self.blocking_mock.updateBlockDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_BLOCKED(
         what=[
             Registry.Administrative.DomainIdHandle(
                 domainId=1, domainHandle='test1.cz'),
         ])
     tc.submit()
     tc.url(self.START_URL)
     tc.find('Domain\(s\) test1.cz not blocked\.')
 def test_domain_already_blocked(self):
     self.blocking_mock.blockDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_ALREADY_BLOCKED(
         what=[
             Registry.Administrative.DomainIdHandle(
                 domainId=1, domainHandle='test1.cz'),
         ])
     tc.submit()
     tc.url(self.START_URL)
     tc.find('Domain\(s\) test1.cz are already blocked\.')
Ejemplo n.º 12
0
    def test_edit_email_address(self):
        # Opt out of the periodic emails. This way, the only "checked"
        # checkbox is the one for if the user's email address gets shown.
        paulproteus = Person.objects.get()
        paulproteus.email_me_re_projects = False
        paulproteus.save()

        self.login_with_twill()
        

        _url = 'http://openhatch.org/account/settings/contact-info/'
        url = make_twill_url(_url)

        email = '*****@*****.**'

        # Go to contact info form
        tc.go(url)

        # Let's first ensure that "*****@*****.**" doesn't appear on the page.
        # (We're about to add it.)
        tc.notfind('checked="checked"')
        tc.notfind(email)

        # Edit email
        tc.fv("a_settings_tab_form", 'edit_email-email', email)
        # Show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '1') # [1]
        tc.submit()

        # Form submission ought to redirect us back to the form.
        tc.url(url)

        # Was email successfully edited? 
        tc.find(email)

        # Was email visibility successfully edited? [2]
        tc.find('checked="checked"')

        # And does the email address show up on the profile?
        tc.go(make_twill_url(
                'http://openhatch.org/people/paulproteus'))
        tc.find(email)

        # 2. And when we uncheck, does it go away?
        
        # 2.1. Go to contact info form
        tc.go(url)

        # 2.2. Don't show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '0') # [1]
        tc.submit()

        # 2.3. Verify it's not on profile anymore
        tc.go(make_twill_url(
                'http://openhatch.org/people/paulproteus'))
        tc.notfind(email)
Ejemplo n.º 13
0
def delete_course(id):
    course = admin_find_course(id=id)

    post2(
        '/py/teacher/agroup/%s/course/%s/delete/' % (course['agroup_id'], id),
        dict(course=id, delete='Delete'))

    cmd.url('.*/course_list/')

    cmd.notfind('course/%s' % id)  # in href
 def test_unblock_domain_not_blocked(self):
     tc.fv(2, 'new_holder', 'KONTAKT')
     self.blocking_mock.unblockDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_BLOCKED(
         what=[
             Registry.Administrative.DomainIdHandle(
                 domainId=1, domainHandle='test1.cz'),
         ])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) test1.cz not blocked\.')
 def test_unblockable_contact(self):
     tc.fv(2, 'owner_block_mode', '1')
     self.blocking_mock.blockDomainsId.side_effect = Registry.Administrative.CONTACT_BLOCK_PROHIBITED(
         what=[
             Registry.Administrative.ContactIdHandle(
                 contactId=1, contactHandle='I_R_MOJEID')
         ])
     tc.submit()
     tc.url(self.START_URL)
     tc.find('Contact\(s\) I_R_MOJEID cannot be blocked')
 def test_restore_domain_not_blocked(self):
     tc.fv(2, 'restore_prev_state', True)
     self.blocking_mock.restorePreAdministrativeBlockStatesId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_BLOCKED(
         what=[
             Registry.Administrative.DomainIdHandle(
                 domainId=1, domainHandle='test1.cz'),
         ])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) test1.cz not blocked\.')
Ejemplo n.º 17
0
 def test_form_sends_data_to_get(self):
     # This test will fail if a query that selects one project but doesn't
     # equal the project's name causes a redirect.
     relevant = mysite.search.models.Project.create_dummy(name='Twisted System')
     tc.go(better_make_twill_url('http://openhatch.org/+projects'))
     query = 'Twisted'
     tc.fv(1, 'search_q', query)
     tc.submit()
     tc.url('\?q=Twisted') # Assert that URL contains this substring.
     tc.find(query)
Ejemplo n.º 18
0
 def test_form_on_project_search_page_submits_to_project_creation_post_handler(self):
     project_search_page_url = better_make_twill_url(
             "http://openhatch.org%s?q=newproject" % reverse(mysite.project.views.projects))
     tc.go(project_search_page_url)
     # Fill form out with slightly different project name, which we
     # anticipate happening sometimes
     tc.fv('create_project', 'project_name', 'NewProject')
     tc.submit()
     post_handler_url = reverse(mysite.project.views.create_project_page_do)
     import re
     tc.url(re.escape(post_handler_url))
Ejemplo n.º 19
0
 def test1(self):
     url = "http://www.yourwebsite.com/signup/"
     twill_quiet()
     tc.go('ubuntu')
     tc.find('Registro Brasileiro')
     tc.follow('register')
     tc.url()
     # Fill in the form
     tc.fv('1', 'username', 'test123')
     tc.fv('1', 'email', '*****@*****.**')
     tc.submit()
     tc.find('click the activation link')
Ejemplo n.º 20
0
    def test_edit_email_address(self):
        # Opt out of the periodic emails. This way, the only "checked"
        # checkbox is the one for if the user's email address gets shown.
        paulproteus = Person.objects.get()
        paulproteus.email_me_re_projects = False
        paulproteus.save()

        self.login_with_twill()

        _url = 'http://openhatch.org/account/settings/contact-info/'
        url = make_twill_url(_url)

        email = '*****@*****.**'

        # Go to contact info form
        tc.go(url)

        # Let's first ensure that "*****@*****.**" doesn't appear on the page.
        # (We're about to add it.)
        tc.notfind('checked="checked"')
        tc.notfind(email)

        # Edit email
        tc.fv("a_settings_tab_form", 'edit_email-email', email)
        # Show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '1')  # [1]
        tc.submit()

        # Form submission ought to redirect us back to the form.
        tc.url(url)

        # Was email successfully edited?
        tc.find(email)

        # Was email visibility successfully edited? [2]
        tc.find('checked="checked"')

        # And does the email address show up on the profile?
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus'))
        tc.find(email)

        # 2. And when we uncheck, does it go away?

        # 2.1. Go to contact info form
        tc.go(url)

        # 2.2. Don't show email
        tc.fv("a_settings_tab_form", 'show_email-show_email', '0')  # [1]
        tc.submit()

        # 2.3. Verify it's not on profile anymore
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus'))
        tc.notfind(email)
Ejemplo n.º 21
0
    def test_form_sends_data_to_get(self):
        # This test will fail if a query that selects one project but doesn't
        # equal the project's name causes a redirect.

        # First, create the project that we will refer to below.
        mysite.search.models.Project.create_dummy(name='Twisted System')

        tc.go(better_make_twill_url('http://openhatch.org/projects'))
        query = 'Twisted'
        tc.fv(1, 'search_q', query)
        tc.submit()
        tc.url('\?q=Twisted') # Assert that URL contains this substring.
        tc.find(query)
Ejemplo n.º 22
0
    def test_form_sends_data_to_get(self):
        # This test will fail if a query that selects one project but doesn't
        # equal the project's name causes a redirect.

        # First, create the project that we will refer to below.
        mysite.search.models.Project.create_dummy(name="Twisted System")

        tc.go(better_make_twill_url("http://openhatch.org/+projects"))
        query = "Twisted"
        tc.fv(1, "search_q", query)
        tc.submit()
        tc.url("\?q=Twisted")  # Assert that URL contains this substring.
        tc.find(query)
    def test_owner_has_other_domain(self):
        self.blocking_mock.blockDomainsId.side_effect = Registry.Administrative.OWNER_HAS_OTHER_DOMAIN(
            what=[
                Registry.Administrative.OwnerDomain(
                    ownerId=1,
                    ownerHandle='THEPEPE',
                    otherDomainList=[
                        Registry.Administrative.DomainIdHandle(
                            domainId=1, domainHandle='test1.cz')
                    ])
            ])

        tc.submit()
        tc.url(self.START_URL)
        tc.find('Cannot block holder')
Ejemplo n.º 24
0
def create_task(course_id, name, instructions, template='epf', **kwargs):
    """ create task and return through_id

       kwargs - additional parameters

    """
    agroup_id = admin_find_course(id=course_id)['agroup_id']

    cmd.go('/py/teacher/agroup/%s/course/%s/task/new/' %
           (agroup_id, course_id))

    cmd.fv(1, 'task_name', name)
    cmd.fv(1, 'task_template', template)
    cmd.submit()

    through_id = cmd.url('.+/task/(?P<task_through_id>\d+)/edit/')

    cmd.fv(1, 'instructions', instructions)
    cmd.submit('save')

    errors = soup().findAll('ul', {'class': 'errorlist'})
    if errors:
        raise AssertionError('Page errors: %s' % errors)

    cmd.find('Changes saved')

    return through_id
Ejemplo n.º 25
0
def student_casual_register(access_key, login):
    cmd.go('/py/student/login/')
    cmd.show()
    cmd.fv(2, 'full_access_key', access_key)
    cmd.submit()

    no = re.search(
        re.compile('(\/py\/student\/login\/\d+-\w+\/join\/register\/)'),
        cmd.show()).groups()[0]
    cmd.go(no)
    cmd.fv(1, 'forename', 'generic')
    cmd.fv(1, 'surname', 'robot')
    cmd.fv(1, 'login', login)
    cmd.fv(1, 'passwd', 'mymy')
    cmd.fv(1, 'passwd2', 'mymy')
    cmd.submit()
    cmd.url('/py/student/')
Ejemplo n.º 26
0
    def change_password(self, old_pass, new_pass, should_succeed=True):
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus'))
        tc.follow('settings')
        tc.follow('Password')
        tc.url('/account/settings/password')

        tc.fv('a_settings_tab_form', 'old_password', old_pass)
        tc.fv('a_settings_tab_form', 'new_password1', new_pass)
        tc.fv('a_settings_tab_form', 'new_password2', new_pass)
        tc.submit()

        # Try to log in with the new password now
        client = Client()
        username = '******'
        success = client.login(username=username, password=new_pass)
        if should_succeed:
            success = success
        else:
            success = not success
        self.assert_(success)
Ejemplo n.º 27
0
    def change_password(self, old_pass, new_pass, should_succeed=True):
        tc.go(make_twill_url("http://openhatch.org/people/1"))
        tc.follow("settings")
        tc.follow("Password")
        tc.url("/account/settings/password")

        tc.fv("a_settings_tab_form", "old_password", old_pass)
        tc.fv("a_settings_tab_form", "new_password1", new_pass)
        tc.fv("a_settings_tab_form", "new_password2", new_pass)
        tc.submit()

        # Try to log in with the new password now
        client = Client()
        username = "******"
        success = client.login(username=username, password=new_pass)
        if should_succeed:
            success = success
        else:
            success = not success
        self.assert_(success)
Ejemplo n.º 28
0
    def change_password(self, old_pass, new_pass,
            should_succeed = True):
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus'))
        tc.follow('settings')
        tc.follow('Password')
        tc.url('/account/settings/password')

        tc.fv('a_settings_tab_form', 'old_password', old_pass)
        tc.fv('a_settings_tab_form', 'new_password1', new_pass)
        tc.fv('a_settings_tab_form', 'new_password2', new_pass)
        tc.submit()

        # Try to log in with the new password now
        client = Client()
        username='******'
        success = client.login(username=username,
                password=new_pass)
        if should_succeed:
            success = success
        else:
            success = not success
        self.assert_(success)
Ejemplo n.º 29
0
def create_aset(task_id, studentset_id, student_id_list, **kwargs):
    """ assign task to several students and return assignmentset_id

       kwargs - additional parameters

    """
    task = admin_find_task(id=task_id)
    course_id = task['course_id']
    course = admin_find_course(id=course_id)
    agroup_id = course['agroup_id']

    cmd.go('/py/teacher/assignment/new/step3/myown/0/0/%s/' % course_id)

    post2('/py/teacher/assignment/new/step3/myown/0/0/%s/' % course_id,
          dict(task='task:%s' % task['id'], mainform_force_next='yes'))
    cmd.code(200)

    cmd.url('.*/step4/.*/task:%s/0/' % task['id'])

    params = [('save', 'Finish'), ('studentset_id', studentset_id)]
    params.extend([('students', id) for id in student_id_list])

    post2('/py/teacher/assignment/new/step4/myown/0/0/%s/task:%s/0/'\
          % (course_id, task['id']),
          params)
    cmd.code(200)

    cmd.find('New assignments have been added successfully')

    r = re.compile(
        '/student/task.php/\d+/work\?teach=\d+&aset=(?P<assignmentset_id>\d+)')
    assignmentset_id_text = soup().find('a', href=r)['href']
    assignmentset_id = r.search(
        assignmentset_id_text).groupdict()['assignmentset_id']

    return assignmentset_id
Ejemplo n.º 30
0
def create_course(agroup_id, **kwargs):
    """ create course (with kwarg parameters) in agroup and return id """

    if 'gradegridset' not in kwargs:
        kwargs['gradegridset'] = 1

    post2(
        '/py/teacher/agroup/%s/course_list/' % agroup_id,
        dict(action='addcourse',
             course_name=kwargs['name'],
             gradegridset=kwargs['gradegridset'],
             description=kwargs.get('description'),
             submit='Submit'))

    errors = soup().findAll('ul', {'class': 'errorlist'})
    if errors:
        raise AssertionError('Page errors: %s' % errors)
    else:
        id = cmd.url('.*/course/(?P<course_id>\d+)/edit/')

    return id
Ejemplo n.º 31
0
def _django_admin_change_object(url, **kwargs):
    """ create/edit object in django admin and return his id

    url - url of django object modify form
    kwargs - form fields and values

    """
    cmd.go(url)
    cmd.find('Save and continue editing')
    for k, v in kwargs.iteritems():
        # send checked checkboxes as 'on', unchecked not send.
        if type(v) == bool:
            if v:
                cmd.fv(1, k, 'on')
            else:
                pass
        else:
            # default
            cmd.fv(1, k, str(v))

    cmd.submit('_continue')

    try:
        cmd.notfind('Please correct the error below')
    except TwillAssertionError as e:
        print('Page errors: %s' % soup().findAll('ul', {'class': 'errorlist'}))
        ff()
        raise

    try:
        cmd.find('was \w* successfully. You may edit it again below.')
    except TwillAssertionError as e:
        ff()
        raise

    id = cmd.url('.*/(?P<id>\d+)/')

    return id
 def test_block_to_date_past(self):
     tc.fv(2, 'block_to_date', '2000-01-01')
     tc.submit()
     tc.url('http://localhost:8080/domain/blocking/')
     tc.find('Block to date must be in the future.')
Ejemplo n.º 33
0
 def url(self, should_be=None):
     should_be = should_be or self.default_url
     if not should_be.startswith('http://'):
         should_be = self.prefix+should_be
     return c.url(should_be)
 def test_domain_not_found(self):
     self.blocking_mock.blacklistAndDeleteDomainsId.side_effect = Registry.Administrative.DOMAIN_ID_NOT_FOUND(
         what=[1])
     tc.submit()
     tc.url(self.START_URL)
     tc.find(r'Domain\(s\) with id 1 not found\.')
Ejemplo n.º 35
0
def student_logout():
    """ logout student """
    cmd.go('/py/student/logout/')
    cmd.url('/py/student/login')
Ejemplo n.º 36
0
 def test_login_success(self):
     """ successfull login """
     self.general_login_action('user1', 'password1', 'Welcome, user1')
     url('/')