def setUp(self, datastore_hr_probability=0): mc_unittest.TestCase.setUp( self, datastore_hr_probability=datastore_hr_probability) self.current_user = users.User('*****@*****.**') create_user_profile(self.current_user, u'test', DEFAULT_LANGUAGE) set_current_user(self.current_user)
def test_static_flex_service(self): self.set_datastore_hr_probability(1) print 'Test service creation with static modules' email = u'test1.flex.foo.com' r = create_flex_service(email, name="test", address="Antwerpsesteenweg 19\n9080 Lochristi", phone_number="+32 9 324 25 64", languages=["en", "nl"], currency=u"€", modules=list(SolutionModule.STATIC_MODULES), broadcast_types=['test1', 'test2', 'test3'], apps=[a.app_id for a in App.all()], allow_redeploy=False, organization_type=random.choice([ x for x in OrganizationType.all() if x > 0 ])) service_user = users.User(r.login) set_current_user(service_user) print 'Test provisioning of static modules' common_provision(service_user) print 'Test rendering the home page' FlexHomeHandler({}, webapp2.Response()).get()
def test_association_creation(self): self.set_datastore_hr_probability(1) apps = [a.app_id for a in App.all()] r = create_flex_service(email=u'*****@*****.**', name=u"test", address=u"Antwerpsesteenweg 19\n9080 Lochristi", phone_number=u"+32 9 324 25 64", languages=[u"en", u"nl"], currency=u"€", modules=[SolutionModule.CITY_APP, SolutionModule.BROADCAST, SolutionModule.ASK_QUESTION, SolutionModule.WHEN_WHERE], broadcast_types=['News', 'test'], apps=apps, allow_redeploy=False, organization_type=OrganizationType.CITY) # Create city customer shop_user = users.User(u'*****@*****.**') customer_id = None vat = u'' name = u'Town Lochristi' address1 = u'Dorp - West 52' address2 = u'' zip_code = u'9080' city = u'Lochristi' country = u'BE' language = u'nl' organization_type = OrganizationType.CITY prospect_id = None city_customer = create_or_update_customer(shop_user, customer_id, vat, name, address1, address2, zip_code, city, country, language, organization_type, prospect_id, team_id=RegioManagerTeam.all().get().id) city_customer.service_email = city_customer.user_email = r.login city_customer.default_app_id = apps[0] city_customer.app_ids = apps city_customer.put() # Create city contact first_name = u'Firstname' last_name = u'Lastname' email_address = u'*****@*****.**' phone_number = u'+3293268806' create_contact(city_customer, first_name, last_name, email_address, phone_number) name = u'test-Test association' address1 = u'Antwerpsesteenweg 19' address2 = u'' zip_code = u'9080' city = u'Lochristi' user_email = u'*****@*****.**' telephone = u'+32 9 324 25 64' language = u'nl' modules = [u'agenda', u'bulk_invite', u'static_content', u'ask_question', u'broadcast'] broadcast_types = [u'Evenementen', u'Nieuws'] set_current_user(users.User(r.login), set_google_user=False) output = rest_put_service(name, address1, address2, zip_code, city, user_email, telephone, language, modules, broadcast_types) self.assertTrue(output.success, output.errormsg) self.assertFalse(output.errormsg)
def _test_dynamic_flex_service(self, language): self.set_datastore_hr_probability(1) print 'Test %s service creation with all modules' % language email = u'*****@*****.**' r = create_flex_service(email, name="test", address="Antwerpsesteenweg 19\n9080 Lochristi", phone_number="+32 9 324 25 64", languages=[language], currency=u"€", modules=SolutionModule.visible_modules(), broadcast_types=['test1', 'test2', 'test3'], apps=[a.app_id for a in App.all()], allow_redeploy=False, organization_type=random.choice([ x for x in OrganizationType.all() if x > 0 ])) service_user = users.User(r.login) set_current_user(service_user) print 'Setting order type to advanced' _put_default_menu(service_user) sln_settings = get_solution_settings(service_user) sln_order_settings = SolutionOrderSettings( key=SolutionOrderSettings.create_key(service_user)) sln_order_settings.text_1 = 'text_1' sln_order_settings.order_type = SolutionOrderSettings.TYPE_ADVANCED sln_order_settings.leap_time = 1 sln_order_settings.leap_time_type = 86400 sln_order_settings.put() SolutionOrderWeekdayTimeframe.create_default_timeframes_if_nessecary( service_user, sln_settings.solution) print 'Test provisioning of all modules' common_provision(service_user) print 'Test rendering the home page' FlexHomeHandler({}, webapp2.Response()).get() print 'Test deletion of all modules' solution_settings = get_solution_settings(service_user) solution_settings.modules = [] solution_settings.put() common_provision(service_user) print 'Test rendering the home page' FlexHomeHandler({}, webapp2.Response()).get()
def test_customer_store(self): xcty_product = ShopProductTO.create(u'be-berlare', u'XCTY', 1) posm_product = ShopProductTO.create(MISSING, u'POSM', 250) _, customer = self._create_customer_and_subscription_order( [u'MSUP', u'BEAC', u'KSUP', u'ILOS']) self._create_service(customer) customer = Customer.get_by_id(customer.id) self.current_user = users.User(customer.service_email) set_current_user(self.current_user) product_xcty, product_posm = db.get( [Product.create_key(u'XCTY'), Product.create_key(u'POSM')]) xcty_order_item = add_item_to_order(xcty_product).order_item remaining_subscription_length = get_subscription_order_remaining_length( customer.id, customer.subscription_order_number)[0] price_xcty = remaining_subscription_length * product_xcty.price temp_order = Order.get_by_order_number(customer.id, '-1') self.assertEqual(temp_order.is_subscription_order, False) self.assertEqual(temp_order.amount, price_xcty) self.assertEqual(temp_order.is_subscription_extension_order, False) # Is set when paying the order add_item_to_order(posm_product).order_item temp_order = Order.get_by_order_number(customer.id, '-1') self.assertEqual(temp_order.amount, price_xcty + product_posm.price * 250) # test removing an order item remove_from_order(xcty_order_item.id) temp_order = Order.get_by_order_number(customer.id, '-1') self.assertEqual(temp_order.amount, product_posm.price * 250) xcty_order_item = add_item_to_order(xcty_product).order_item temp_order = Order.get_by_order_number(customer.id, '-1') self.assertEqual(temp_order.amount, price_xcty + product_posm.price * 250) self.assertEqual( pay_order().success, False) # should be false since we have no credit card linked