コード例 #1
0
ファイル: test_model.py プロジェクト: mbryantlibrary/BatCoach
    def test_import_file_calls_parse_players_if_squad_file(self, mock_parse_team_id, mock_add, mock_first, mock_count, mock_parse_players):
        """ Tests that parse_players is called if the HTML file is a Squad file """
        html_file = HTMLFile()
        html_file.type = PageTypes.Squad.value
        html_file.HTML = 'some HTML'

        mock_parse_players.return_value = []
        mock_parse_team_id.return_value = 3000

        team = Team()
        mock_first.result = team

        self.model.import_file(html_file)
        mock_parse_players.assert_called_with(html_file.HTML)
コード例 #2
0
ファイル: test_model.py プロジェクト: mbryantlibrary/BatCoach
    def test_import_file_calls_parse_pavilion_if_pavilion_file(self, mock_ranking,mock_parse_team_id, mock_first, mock_parse_pavilion):
        html_file = HTMLFile()
        html_file.type = PageTypes.Pavilion.value
        html_file.HTML = 'some HTML'
        

        mock_parse_pavilion.return_value = []
        mock_parse_team_id.return_value = 3000

        team = Team()
        team.rankings.append = mock.Mock()

        mock_first.result = team
        self.model.import_file(html_file)

        assert mock_parse_team_id.called
コード例 #3
0
ファイル: test_model.py プロジェクト: mbryantlibrary/BatCoach
    def test_import_file_retrieves_team_from_file(self, mock_add, mock_query, mock_parse_team_id):

        test_id = 49800

        team = Team()

        html_file = HTMLFile()
        html_file.HTML = 'Some HTML'

        mock_query.return_value.filter_by = mock.Mock()

        mock_parse_team_id.return_value = test_id
        mock_result = mock.Mock(spec=Query)
        mock_result.count = mock.Mock()
        mock_result.count.return_value = 1

        mock_query.return_value.filter_by.return_value = mock_result

        self.model.import_file(html_file)

        mock_query.assert_called_with(Team)
        assert mock_parse_team_id.called
        mock_query.return_value.filter_by.assert_called_with(id=test_id)