Exemplo n.º 1
0
    def test_new_category(self):
        response = self.client.get(url_for('catalog.newCategory'))
        self.assertTrue(response.status_code == 200)

        response = self.client.post(url_for('catalog.newCategory'), data={
            'category_name' : 'tess', 
        }, follow_redirects=True)
        self.assertTrue(response.status_code == 200)
        data = response.get_data(as_text=True)
        self.assertTrue("tess" in data)

        response = self.client.post(url_for('catalog.newCategory'), data={
            'category_name' : 'tess', 
        }, follow_redirects=True)
        #logging.error(response.status)
        self.assertTrue(response.status_code == 200)
        data = response.get_data(as_text=True)
        self.assertTrue("Category already exists" in data)

        response = self.client.post(url_for('catalog.newCategory'), data={
            'category_name' : '', 
        }, follow_redirects=True)
        self.assertTrue(response.status_code == 200)
        data = response.get_data(as_text=True)
        self.assertTrue("Empty Category Name" in data)

        Category.delete_by_id(Category.get_by_name('tess').id)
Exemplo n.º 2
0
    def test_edit_category(self):
        category = Category.store('Wuki')
        response = self.client.get(url_for('catalog.editCategory', category_id=category.id))
        self.assertTrue(response.status_code == 200)

        response = self.client.post(url_for('catalog.editCategory', category_id=category.id), data= {
            'category_name' : 'tess', 
        }, follow_redirects=True)
        logging.error(response.status)
        self.assertTrue(response.status_code == 200)
        data = response.get_data(as_text=True)
        self.assertTrue("tess" in data)