def test_setup(self, get_profile): facebook_data = { "profile_pic": "https://scontent.xx.fbcdn.net/v/t1.0-1/387900_111423898972930_532477064_n.jpg?oh=b0a2ee0279851025f4cdecfbbbf7d30c&oe=59DDB290", "first_name": "Johnny", "last_name": "Tester", "locale": "en_US", "gender": "male", "timezone": -7, "is_payment_enabled": True } get_profile.return_value = facebook_data user = AppUser.setup("testid") self.assertEquals(facebook_data['first_name'], user.first_name) self.assertEquals(facebook_data['last_name'], user.last_name) self.assertNotEquals(user.custom_data, {}) user2 = AppUser.setup("testid") self.assertEquals(user2.id, user.id) user.add_child("Jane", "+16027226814") self.assertEquals(user.children.all().count(), 1)
def test_setup_no_facebook(self, get_profile): user = AppUser.setup("testid") self.assertNotEquals(user.id, None) self.assertEquals(user.first_name, None) user2 = AppUser.setup("testid") self.assertEquals(user2.id, user.id)
def schedule_all_users(): users = AppUser.get_users_to_schedule() logger.info("found %s users to schedule" % len(users)) for u in users: run(schedule_user, (u.id, ))
def test_add_action(self): user = AppUser.setup("test_id") child = user.add_child("Jill", "555") user.add_reminder(child_id=child.id, kind=100, for_desc='brand practice', is_repeated=False, choosen_date="2017-08-01", reminder_time="16:30", days_selected=None) user.add_reminder(child_id=child.id, kind=100, for_desc='brand practice', is_repeated=True, choosen_date=None, reminder_time="16:30", days_selected='0|1|2|5') user.schedule_actions() self.assertEquals(Action.objects.all().count(), 5) user.schedule_actions() self.assertEquals(Action.objects.all().count(), 5)
def test_no_slot_child_3(self): user = AppUser.setup("testid") child = user.add_child("Jane","555") user.add_child("Jill","444") event = self._build_test_event( intent="AddBeReadyBy", slots=self.slots, transcript="record_id|-1", ) resp = route_logic(event) #incorrect child id self._test_intent_case(resp,"no_slot_child") #correct child id event = self._build_test_event( intent="AddBeReadyBy", slots=self.slots, transcript="record_id|%s" % child.id, session = { "last_case": "no_slot_child", "current_slot": "child", "attempt_count": 1 } ) resp = route_logic(event) #correct, move on self._test_intent_case(resp,"no_slot_time")
def get_user(self): self.child = Child.get_by_phone(self.user_id) if self.child: self.action = self.child.get_active_reminder() if self.child: return AppUser.setup(self.child.user.ref_id) else: return None
def test_no_child(self): user = AppUser.setup("testid") event = self.build_test_event("ParentOrbChild", "CatchAll", self.slots, "hello") resp = route_logic(event) self.check_intent_case(resp, "no_child")
def createAccount(request): data = "failed" post_data = request.POST if post_data['pass'] == post_data['conf_pass']: user = User.objects.create_user(post_data['client_email'], post_data['client_email'], post_data['pass']) appuser = AppUser( user = user, name = post_data['client_name'], email = post_data['client_email'], username = post_data['client_phone'], phone = post_data['client_phone'], status = "active", subscription_type = post_data['subscription_type'], charge = 0.00, ) appuser.save() return redirect('/') else: return redirect('about')
def test_no_slot_child_1(self): user = AppUser.setup("testid") user.add_child("Jane","555") event = self._build_test_event( intent="AddBeReadyBy", slots=self.slots, ) resp = route_logic(event) #child can be derived so it will move on self._test_intent_case(resp,"no_slot_time")
def test_no_slot_child_2(self): user = AppUser.setup("testid") user.add_child("Jane","555") user.add_child("Jill","444") event = self._build_test_event( intent="AddBeReadyBy", slots=self.slots, ) resp = route_logic(event) #child can't be derived so ask self._test_intent_case(resp,"no_slot_child")
def test_missing_timezone(self): user = AppUser.setup("testid") user.add_child("Jane","555") user.time_offset = None user.save() event = self._build_test_event( "AddBeReadyBy", self.slots, "add be ready by" ) resp = route_logic(event) self._test_intent_case(resp,"missing_timezone")
def test_no_slot_time(self): user = AppUser.setup("testid") child = user.add_child("Jane","555") self.slots['child'] = child.first_name self.slots['time'] = "zzzz" event = self._build_test_event( intent="AddBeReadyBy", slots=self.slots, session = { "last_case": "no_slot_time", "current_slot": "time", "attempt_count": 1 } ) resp = route_logic(event)
def test_process(self): user = AppUser.setup("test_id") child = user.add_child("Jill", "555") user.add_reminder(child_id=child.id, kind=100, for_desc='brand practice', is_repeated=False, choosen_date="2017-08-01", reminder_time="16:30", days_selected=None) user.schedule_actions() action = Action.objects.all()[0] action.process()
def test_timezone(self, get_profile): facebook_data = { "profile_pic": "https://scontent.xx.fbcdn.net/v/t1.0-1/387900_111423898972930_532477064_n.jpg?oh=b0a2ee0279851025f4cdecfbbbf7d30c&oe=59DDB290", "first_name": "Johnny", "last_name": "Tester", "locale": "en_US", "gender": "male", "timezone": -7, "is_payment_enabled": True } get_profile.return_value = facebook_data user = AppUser.setup("testid") self.assertNotEquals(user.local_time(), None) print user.relevant_server_time("17:30")
def test_no_action_default(self): user = AppUser.setup("testid") child = user.add_child("Jane", "+555") user.add_reminder(child_id=child.id, kind=100, for_desc='brand practice', is_repeated=False, choosen_date="2017-08-01", reminder_time="16:30", days_selected=None) user.schedule_actions() event = self.build_test_event("ParentOrbChild", "CatchAll", self.slots, "hello", userId="555") resp = route_logic(event)
def get_user(self): return AppUser.setup(self.user_id)