Пример #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']))
Пример #2
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)
Пример #3
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)
Пример #4
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)))
Пример #5
0
 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))
Пример #6
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)
Пример #7
0
 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)
Пример #8
0
 def test_add_scenario_check_client_property(self):
     eq_(len(self.client.scenarios), 0)
     s = Scenario()
     s.save()
     eq_(len(self.client.scenarios), 1)
Пример #9
0
 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)
Пример #10
0
 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))
Пример #11
0
 def test_add_scenario(self):
     s = Scenario()
     s.save()
     eq_(s.id, Scenario.objects().only('id').first().id)
Пример #12
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']())
Пример #13
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))