def contest_two(self, dbsession, user): contest_data = dict(self.contest_user_data) contest_data['owner'] = user contest = Contest(**contest_data) with DeleteOnExit(dbsession, contest): yield contest
def question_two(self, dbsession, contest_two): question_data = dict(self.question_user_data) question_data['contest_id'] = contest_two.id question = Question(**question_data) with DeleteOnExit(dbsession, question): yield question
def answer_two(self, dbsession, question_two): answer_data = dict(self.answer_user_data) answer_data['question_id'] = question_two.id answer = Answer(**answer_data) with DeleteOnExit(dbsession, answer): yield answer
def test_list_event_after(self, screen, query, command, dbsession): """ .list_event_after should list events after specyfic date in order of creation """ event1 = command.send_event('view', screen.id) event2 = command.send_event('view', screen.id) event3 = command.send_event('view', screen.id) with DeleteOnExit(dbsession, event1): with DeleteOnExit(dbsession, event2): with DeleteOnExit(dbsession, event3): result = query.list_events_after(screen.id, event1.created_at) assert len(result) == 2 assert result[0].id == event2.id assert result[1].id == event3.id
def game(self, dbsession, contest_from_user): game_data = dict(self.game_data) game_data['contest_id'] = contest_from_user.id game_data['owner_id'] = contest_from_user.owner_id game = Game(**game_data) with DeleteOnExit(dbsession, game): yield game
def test_send_event(self, screen, query, command, dbsession): """ .send_event should create event and update screen object """ event = command.send_event('change view', screen.id, view='newview') with DeleteOnExit(dbsession, event): dbsession.refresh(screen) assert screen.view == 'newview' assert event.screen_id == screen.id
def test_create_screen(self, game, query, command, dbsession): """ .create_screen should create screen for game """ screen = command.create_screen(game.id) with DeleteOnExit(dbsession, screen): assert screen result = query.list_for_game(game.id) assert len(result) == 1 assert result[0].id == screen.id
def test_list_event_after_with_timestamp(self, screen, query, command, dbsession): """ .list_event_after should list events after specyfic timestamp in order of creation """ timestamp = time() event = command.send_event('view', screen.id) with DeleteOnExit(dbsession, event): result = query.list_events_after(screen.id, timestamp) assert len(result) == 1 assert result[0].id == event.id
def screen(self, dbsession, game): screen = Screen(game_id=game.id) with DeleteOnExit(dbsession, screen): yield screen