Пример #1
0
    def test_can_see_products_list(self):
        #set up entry
        p1 = utils.createTestProduct()
        a1 = utils.createTestAlias(p1)
        a2 = utils.createTestAlias(p1)
        d1 = utils.createTestDrawing(a1)

        # Klaus enters the url and is shown a styled Products list page
        self.browser.get(self.server_url+ "/products/")
        self.assertIn('Product', self.browser.title)
        header_text = self.browser.find_element_by_tag_name('h1').text
        self.assertIn('Product', header_text)
        self.assertGreater(self.browser.find_element_by_tag_name('h1').location['x'], 10)


        # In the list he sees one entry with a standard two alias
        body_text = self.browser.find_element_by_tag_name('body').text
        self.assertIn(p1.product_no, body_text)
        self.assertIn(a1.product_no, body_text)
        self.assertIn(a2.product_no, body_text)

        # He finds the link to create a new Product and  clicks it
        self.browser.find_element_by_id("add_product_link").click()
        # He is then shown a forms page and enters a Product No and clicks submit
        self.assertIn('Add new Product', self.browser.title)
        self.browser.find_element_by_id('id_product_no').send_keys("AnotherGuide")
        self.browser.find_element_by_id('submit-id-save').click()

        # He is then shown the product entry page
        self.assertIn('Product Details', self.browser.title)
        self.assertIn("AnotherGuide", self.browser.find_element_by_tag_name('body').text)

        # In the product detail page he sees a "add Alias" link and clicks it
        self.browser.find_element_by_id("add_alias_link").click()

        # He is shown a alias form page
        self.assertIn("Add Alias", self.browser.title)


        # In the detail page he clicks the "edit" link







        self.fail("So far so good! Finish the test!")
Пример #2
0
    def test_can_add_and_retrieve_product(self):
        p1 = utils.createTestProduct()

        self.assertEqual(models.Product.objects.count(), 1)

        self.assertEqual(models.Product.objects.last().product_group,p1.product_group)
Пример #3
0
    def test_displays_product(self):
        p1 = utils.createTestProduct()
        url="/products/"
        response = self.app.get(url)

        response.mustcontain(p1.product_no)
Пример #4
0
    def test_add_alias_forbids_same_product_no_as_parent_product(self):

        p1 = utils.createTestProduct()

        with self.assertRaises(ValidationError):
            a1 = utils.createTestAlias(p1, p1.product_no)