Ignore:
Timestamp:
30 Nov 2014, 08:12:27 (10 years ago)
Author:
Henrik Bettermann
Message:

Add applications_catalog. We need this catalog for imports.

Add catalog tests.

Add attribute last_product_id. This ensures that the last product can be identified even if the product assigned to the application has been removed.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12093 r12094  
    10731073        self.browser.getLink("a102").click()
    10741074        self.browser.getLink("Manage").click()
     1075        self.browser.getControl(name="form.product").value = ['SAM']
    10751076        self.browser.getControl(name="form.title").value = 'My second app'
    10761077        self.browser.getControl("Save").click()
     
    11441145        # ... but NOTSAM not.
    11451146        self.assertFalse('<option value="LIC">' in self.browser.contents)
     1147        # So far last_product_id is None.
     1148        self.assertTrue(self.customer['applications']['a102'].last_product_id is None)
    11461149        self.browser.getControl(name="form.product").value = ['SAM']
    11471150        self.browser.getControl("Save").click()
     1151        # After saving the form, last_product_id is set.
     1152        self.assertEqual(self.customer['applications']['a102'].last_product_id, 'SAM')
     1153        self.assertTrue('Form has been saved.' in self.browser.contents)
     1154        # Saving the form again does not unset last_product_id
    11481155        self.assertEqual(application.title, 'My second app')
     1156        self.browser.getControl("Save").click()
     1157        self.assertEqual(self.customer['applications']['a102'].last_product_id, 'SAM')
    11491158        self.assertTrue('Form has been saved.' in self.browser.contents)
    11501159        self.browser.getLink("View").click()
     
    11531162        self.browser.getLink("Edit").click()
    11541163        self.browser.getControl(name="form.title").value = 'My third app'
    1155         self.browser.getControl("Final Submit").click()
     1164        self.browser.getControl("Apply now").click()
    11561165        self.assertEqual(application.title, 'My third app')
    11571166        self.assertEqual(application.state, 'submitted')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py

    r11997 r12094  
    1 ## $Id: test_catalog.py 10552 2013-08-28 14:33:33Z henrik $
     1## $Id$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    2626from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    2727from waeup.ikoba.customers.customer import Customer
     28from waeup.ikoba.customers.applications import SampleApplication
     29
    2830
    2931class CatalogTestSetup(FunctionalTestCase):
     
    5456        self.customer_id = customer.customer_id
    5557        self.customer = self.app['customers'][self.customer_id]
    56         # Update the customers_catalog
    57         notify(grok.ObjectModifiedEvent(self.customer))
     58
     59        product = createObject('waeup.Product')
     60        product.product_id = u'SAM'
     61        product.title = u'Our Samle Product'
     62        product.application_category = u'sample'
     63        self.app['products'].addProduct(product)
     64        self.product_id = product.product_id
     65        self.product = self.app['products'][self.product_id]
     66
     67        application = createObject('waeup.SampleApplication')
     68        application.title = u'My Samle Application'
     69        application.product = product
     70        application.last_product_id = product.product_id
     71        self.customer['applications'].addApplication(application)
     72        self.application_id = application.application_id
     73        self.application = self.customer['applications'][self.application_id]
     74
     75        document = createObject('waeup.CustomerSampleDocument')
     76        document.title = u'My Samle Document'
     77        self.customer['documents'].addDocument(document)
     78        self.document_id = document.document_id
     79        self.document = self.customer['documents'][self.document_id]
     80
    5881        return
    5982
     
    6386        return
    6487
    65 class CustomerCatalogTests(CatalogTestSetup):
     88
     89class CustomersCatalogTests(CatalogTestSetup):
    6690
    6791    layer = FunctionalLayer
     
    88112        assert len(results) == 1
    89113        assert results[0] is self.app['customers'][self.customer_id]
     114
     115
     116class DocumentsCatalogTests(CatalogTestSetup):
     117
     118    layer = FunctionalLayer
     119
     120    def test_get_catalog(self):
     121        # We can get an customers catalog if we wish
     122        cat = queryUtility(ICatalog, name='documents_catalog')
     123        assert cat is not None
     124
     125    def test_search_by_id(self):
     126        # We can find a certain application id
     127        cat = queryUtility(ICatalog, name='documents_catalog')
     128        results = cat.searchResults(document_id=(self.document_id,
     129                                                self.document_id))
     130        results = [x for x in results] # Turn results generator into list
     131        assert len(results) == 1
     132        assert results[0] is self.customer['documents'][self.document_id]
     133
     134
     135class ApplicationsCatalogTests(CatalogTestSetup):
     136
     137    layer = FunctionalLayer
     138
     139    def test_get_catalog(self):
     140        # We can get an customers catalog if we wish
     141        cat = queryUtility(ICatalog, name='applications_catalog')
     142        assert cat is not None
     143
     144    def test_search_by_id(self):
     145        # We can find a certain application id
     146        cat = queryUtility(ICatalog, name='applications_catalog')
     147        results = cat.searchResults(application_id=(self.application_id,
     148                                                self.application_id))
     149        results = [x for x in results] # Turn results generator into list
     150        assert len(results) == 1
     151        assert results[0] is self.customer['applications'][self.application_id]
     152
     153    def test_search_by_category(self):
     154        # We can find a certain name
     155        cat = queryUtility(ICatalog, name='applications_catalog')
     156        results = cat.searchResults(application_category=('sample', 'sample'))
     157        results = [x for x in results] # Turn results generator into list
     158        assert len(results) == 1
     159        assert results[0] is self.customer['applications'][self.application_id]
     160
     161    def test_search_by_last_product_id(self):
     162        # We can find a certain name
     163        cat = queryUtility(ICatalog, name='applications_catalog')
     164        results = cat.searchResults(last_product_id=('SAM', 'SAM'))
     165        results = [x for x in results] # Turn results generator into list
     166        assert len(results) == 1
     167        assert results[0] is self.customer['applications'][self.application_id]
     168        assert results[0].product is self.product
Note: See TracChangeset for help on using the changeset viewer.