예제 #1
0
 def test_adding(self):
     s_id= self.folder.invokeFactory('emas.app.service',
                                     'service1',
                                     service_type='subscription',
                                     grade='12',
                                     subject='maths',
                                     price='111')
     s1 = self.folder._getOb(s_id)
     self.failUnless(IService.providedBy(s1))
예제 #2
0
    def warnings(self):
        """ Find all the current member's active memberservices.
            Use that to compute the related services.
            Compare that to the current order's services.
            If there are matches, return a list of those that match.

            We do this in order to warn the user that he might be ordering and
            paying for a service or product again.
        """
        ordered_services = []
        ordered_products = []
        for oi in self.order.order_items():
            r_item = oi.related_item.to_object
            if IService.providedBy(r_item):
                ordered_services.append(r_item)
            else:
                ordered_products.append(r_item)
        ordered_services = set(ordered_services)
        ordered_products = set(ordered_products)
            
        pps = self.context.restrictedTraverse('@@plone_portal_state')
        memberid = pps.member().getId()
        orders = get_paid_orders_for_member(self.context, memberid)
        paid_products = []
        paid_services = []
        for order in orders:
            for item in order.order_items():
                r_item = item.related_item.to_object
                if r_item is None:
                    continue
                if 'discount' in r_item.title.lower():
                    continue

                if IService.providedBy(r_item):
                    paid_services.append(r_item)
                else:
                    paid_products.append(r_item)

        paid_services = set(paid_services)
        paid_products = set(paid_products)
        
        matching_products = paid_products.intersection(ordered_products)
        matching_services = paid_services.intersection(ordered_services)
        return matching_products.union(matching_services)
예제 #3
0
    def test_get_services(self):
        view = self.portal.restrictedTraverse('maths/@@practice')
        self.update_request(view)
        result = view()

        self.assertEqual(len(view.memberservices), NUM_SERVICES,
                         'There should be %s practice memberservices.')

        for ms in view.memberservices:
            assert (IMemberService.providedBy(ms),
                'The memberservice does not provide the correct interface.')

        for service in view.practice_services:
            assert (IService.providedBy(service),
                'The practice_service does not provide the correct interface.')
예제 #4
0
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='emas.app.service')
     factory = fti.factory
     new_object = createObject(factory)
     self.failUnless(IService.providedBy(new_object))