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_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_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_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_add_scenario_update_modified(self): s = Scenario() s.save() utc = datetime.datetime.utcnow() __import__("time").sleep(1) s.response = 'aaa' s.save() utc_modified = datetime.datetime.utcnow() eq_(s.response, 'aaa') ok_(utc >= s.created_at >= utc - datetime.timedelta(seconds=1)) ok_(utc_modified >= s.modified_at >= utc_modified - datetime.timedelta(seconds=1))
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_check_scenarios_property_order(self): s = Scenario(attributes={'id': 1, 'priority': 100}) s.save() eq_(self.client.scenarios.first().attributes['id'], 1) s = Scenario(attributes={'id': 2, 'priority': 110}) s.save() eq_(self.client.scenarios.first().attributes['id'], 2) s = Scenario(attributes={'id': 3}) s.save() eq_(self.client.scenarios[2].attributes['id'], 3)
def test_add_scenario_check_client_property(self): eq_(len(self.client.scenarios), 0) s = Scenario() s.save() eq_(len(self.client.scenarios), 1)
def test_add_scenario_attributes(self): s = Scenario(attributes={'id': '111'}) s.save() eq_(s.id, Scenario.objects(attributes__id='111').only('id').first().id)
def test_add_scenario_check_created_at(self): s = Scenario() s.save() utc = datetime.datetime.utcnow() ok_(utc >= s.created_at >= utc - datetime.timedelta(seconds=1)) ok_(utc >= s.modified_at >= utc - datetime.timedelta(seconds=1))
def test_add_scenario(self): s = Scenario() s.save() eq_(s.id, Scenario.objects().only('id').first().id)
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']())
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))