def get_card_event(soup: BeautifulSoup, support_card: SupportCard, update: bool = False): choice_tables = soup.find_all('div', {"class": "uma_choice_table"}) for choice_table in choice_tables: title = choice_table.find_previous_sibling('h3').text card_event = CardEvent(title=title, title_kr=title, support_card=support_card) event_from_db = db_session.query(CardEvent).filter_by( support_card_id=card_event.support_card_id, title=card_event.title).first() if event_from_db and update: card_event = event_from_db get_card_event_choice(choice_table, card_event, update) db_session.add(card_event)
def test_process_fails_when_non_existent_event(self, mock_card, mock_log): ce = CardEvent(mock_card, 'non_existent_event_type') ce.process() assert mock_log.error.called
def test_state_change_is_processed_when_state_change_called(self, mock_card, mock_log, mock_unregister): ce = CardEvent(mock_card, 'state_change') ce.process() assert ce._state_change.called assert mock_card.called assert mock_log.info.called
def test_unregister_is_processed_when_unreg_called(self, mock_card, mock_log, mock_unregister): ce = CardEvent(mock_card, 'unregister') ce.process() assert ce._unregister.called assert mock_card.called assert mock_log.info.called