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']))
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)))
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)
def test_save_history_user_is_none(self): s = Scenario(response='bbb') self.client.save_history('aaa', s, None) eq_( 'aaa', History.objects( scenario__response='bbb').only('request').first().request)
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)
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)
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)
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)
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))
def teardown(self): Scenario.objects().delete() User.objects().delete() History.objects().delete() Intent.objects().delete()
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())
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)
def test_add_history_no_scenario(self): u = User() h = History() h.user = u u.save() h.save()
def test_add_history_no_user(self): h = History() h.scenario = {"response": "aaa"} h.save()