Exemplo n.º 1
0
 def test_isonce_in_history(self):
     u = User()
     u.save()
     s = Scenario(attributes={'id': '111'}, response='bbb')
     s.save()
     h = History(scenario=s.to_dict(), user=u)
     h.save()
     eq_(False, self.client.globals(u.id)['isonce'](s.attributes['id']))
Exemplo n.º 2
0
 def test_add_history(self):
     u = User()
     h = History()
     h.user = u
     h.scenario = {"response": "aaa"}
     u.save()
     h.save()
     eq_(h.id, History.objects().only('id').first().id)
Exemplo n.º 3
0
 def test_client_globals_history(self):
     u = User()
     h = History()
     h.user = u
     h.scenario = {"response": "aaa"}
     u.save()
     h.save()
     eq_(u.id,
         self.client.globals(u.id)["history"].only('user').first().user.id)
Exemplo n.º 4
0
 def test_add_history_check_created_at(self):
     u = User()
     h = History()
     h.user = u
     h.scenario = {"response": "aaa"}
     u.save()
     h.save()
     utc = datetime.datetime.utcnow()
     ok_(utc >= h.created_at >= utc - datetime.timedelta(seconds=1))
Exemplo n.º 5
0
 def test_get_last_history(self):
     u = User()
     u.save()
     s = Scenario(attributes={'id': '111'}, response='bbb')
     s.save()
     h = History(scenario=s.to_dict(), user=u)
     h.save()
     h = History(scenario=s.to_dict(), user=u)
     h.save()
     eq_(h.id, self.client.globals(u.id)['last_history']().id)
Exemplo n.º 6
0
 def test_save_history(self):
     s = Scenario(response='bbb')
     u = User()
     s.save()
     u.save()
     self.client.save_history('aaa', s, u.id)
     eq_(
         'aaa',
         History.objects(
             scenario__response='bbb').only('request').first().request)
Exemplo n.º 7
0
 def test_client_globals_user(self):
     u = User()
     u.save()
     u = User()
     u.save()
     eq_(len(User.objects()), 2)
     eq_(len(self.client.globals(u.id)["user"]), 1)
Exemplo n.º 8
0
 def test_isonce_in_history_with_time(self):
     u = User()
     u.save()
     s = Scenario(attributes={'id': '111'}, response='bbb')
     s.save()
     h = History(scenario=s.to_dict(), user=u)
     h.save()
     eq_(
         False,
         self.client.globals(u.id)['isonce'](
             s.attributes['id'], period=datetime.timedelta(seconds=5)))
Exemplo n.º 9
0
 def test_save_history_user_is_not_in_db(self):
     s = Scenario(response='bbb')
     u = User()
     s.save()
     self.client.save_history('aaa', s, u.id)
     eq_(
         'aaa',
         History.objects(
             scenario__response='bbb').only('request').first().request)
     eq_(
         None,
         History.objects(
             scenario__response='bbb').only('user').first().user)
Exemplo n.º 10
0
 def test_client_globals_history_with_user(self):
     u = User()
     h = History()
     h.user = u
     h.scenario = {"response": "aaa"}
     u.save()
     h.save()
     u = User()
     h = History()
     h.user = u
     h.scenario = {"response": "aaa"}
     u.save()
     h.save()
     eq_(len(History.objects()), 2)
     eq_(len(self.client.globals(u.id)["history"]), 1)
Exemplo n.º 11
0
 def test_get_last_history_case_nothing(self):
     u = User()
     u.save()
     s = Scenario(attributes={'id': '111'}, response='bbb')
     s.save()
     eq_(None, self.client.globals(u.id)['last_history']())
Exemplo n.º 12
0
 def test_isonce(self):
     u = User()
     u.save()
     s = Scenario(attributes={'id': '111'}, response='bbb')
     s.save()
     eq_(True, self.client.globals(u.id)['isonce'](s.id))
Exemplo n.º 13
0
 def test_add_user_add_any_attributes(self):
     u = User()
     u.favotire = 'sports'
     u.save()
     eq_(u.id, User.objects(favotire='sports').only('id').first().id)
Exemplo n.º 14
0
 def test_add_history_no_scenario(self):
     u = User()
     h = History()
     h.user = u
     u.save()
     h.save()
Exemplo n.º 15
0
 def test_get_user_id(self):
     u = self.client.create_new_user(**{"aaa": "aaa"})
     eq_(u.id, User.objects().only('id').first().id)
     user_id = self.client.get_user_id(**{"aaa": "aaa"})
     eq_(user_id, u.id)
Exemplo n.º 16
0
 def test_get_user_attributes(self):
     u = self.client.create_new_user()
     eq_(u.id, User.objects().only('id').first().id)
     get_u = self.client.get_user_attributes(u.id)
     eq_(get_u, {})
Exemplo n.º 17
0
 def test_create_new_user_with_option(self):
     u = self.client.create_new_user(**{"aaa": "aaa"})
     eq_(u.id, User.objects().only('id').first().id)
     eq_(u.aaa, "aaa")
Exemplo n.º 18
0
 def test_create_new_user(self):
     u = self.client.create_new_user()
     eq_(u.id, User.objects().only('id').first().id)
Exemplo n.º 19
0
 def teardown(self):
     Scenario.objects().delete()
     User.objects().delete()
     History.objects().delete()
     Intent.objects().delete()
Exemplo n.º 20
0
 def test_add_user(self):
     u = User()
     u.save()
     eq_(u.id, User.objects().only('id').first().id)
Exemplo n.º 21
0
 def test_save_history_scenario_is_not_allowed_type(self):
     u = User()
     u.save()
     self.client.save_history('aaa', [], u.id)
Exemplo n.º 22
0
 def test_save_history_scenario_is_none(self):
     u = User()
     u.save()
     self.client.save_history('aaa', None, u.id)
     eq_(None,
         History.objects(scenario__response='bbb').only('request').first())
Exemplo n.º 23
0
 def test_client_globals_user_with_user(self):
     u = User()
     u.save()
     eq_(u.id, self.client.globals(u.id)["user"].only('id').first().id)