예제 #1
0
    def setUp(self):
        self.powertype_name = unique_name('beerpowered%s')
        with session.begin():
            self.powertype = PowerType(name=self.powertype_name)
            session.add(self.powertype)

        self.s = requests.Session()
        login(self.s)
예제 #2
0
    def setUp(self):
        self.powertype_name = unique_name('beerpowered%s')
        with session.begin():
            self.powertype = PowerType(name=self.powertype_name)
            session.add(self.powertype)

        self.s = requests.Session()
        login(self.s)
예제 #3
0
    def test_uncheck_numeric_keytype(self):
        with session.begin():
            key = Key(data_setup.unique_name(u'FOOBAR%s'), numeric=1)
            session.add(key)

        b = self.browser
        login(b)
        b.get(get_server_base() + 'keytypes/')
        b.find_element_by_link_text('F').click()
        b.find_element_by_link_text(key.key_name).click()
        b.find_element_by_name('numeric').click()
        b.find_element_by_id('keytypes').submit()

        with session.begin():
            session.refresh(key)
            self.assertEqual(key.numeric, False)
예제 #4
0
    def test_add_numeric_key_type(self):
        new_key_name = data_setup.unique_name(u'FROB%s')
        b = self.browser
        login(b)
        b.get(get_server_base() + 'keytypes/')
        b.find_element_by_link_text('Add').click()
        b.find_element_by_xpath('//h1[text()="New Key Type"]')
        b.find_element_by_name('key_name').send_keys(new_key_name)
        b.find_element_by_name('numeric').click()
        b.find_element_by_id('keytypes').submit()
        b.find_element_by_link_text('F').click()
        b.find_element_by_xpath('//table/tbody/tr/td[1]'
                '[normalize-space(string(.))="%s"]' % new_key_name)

        with session.begin():
            keytype = Key.query.filter_by(key_name=new_key_name).first()
            self.assertEqual(keytype.numeric, True)
예제 #5
0
    def test_deletes_power_type_successfully(self):
        powertype_name = unique_name('beerpowered%s')
        with session.begin():
            pt = PowerType(name=powertype_name)
            session.add(pt)
            activity_count = Activity.query.count()

        b = self.browser
        b.get(get_server_base() + 'powertypes/')
        b.find_element_by_xpath('//li[contains(., "%s")]/button' % pt.name).click()
        b.find_element_by_xpath('//ul[contains(@class, "power-types-list") and '
                'not(./li[contains(., "%s")])]' % pt.name)

        with session.begin():
            session.expire_all()
            self.assertEqual(0, session.query(PowerType).filter_by(name=powertype_name).count())
            self.assertEqual(activity_count + 1, Activity.query.count())
예제 #6
0
    def test_deletes_power_type_successfully(self):
        powertype_name = unique_name('beerpowered%s')
        with session.begin():
            pt = PowerType(name=powertype_name)
            session.add(pt)
            activity_count = Activity.query.count()

        b = self.browser
        b.get(get_server_base() + 'powertypes/')
        b.find_element_by_xpath('//li[contains(., "%s")]/button' %
                                pt.name).click()
        b.find_element_by_xpath(
            '//ul[contains(@class, "power-types-list") and '
            'not(./li[contains(., "%s")])]' % pt.name)

        with session.begin():
            session.expire_all()
            self.assertEqual(
                0,
                session.query(PowerType).filter_by(
                    name=powertype_name).count())
            self.assertEqual(activity_count + 1, Activity.query.count())