Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to PlaybyPlay Regex. Added Integration Tests to Validate Game PlaybyPlay Data #70

Merged
merged 1 commit into from Apr 29, 2019

Conversation

rsforbes
Copy link
Collaborator

This PR does a couple of things

  1. PlayByPlay data & Regular Expressions have been updated to reflect game data that was found to not work on the Regular Expressions. That has been fixed.
  2. Restructured the PlayByPlay data and test so that every line of data is now a test.
  3. Included a new EventMsgType to Regular Expression mapping (Examples are shown in the Integration Tests)
  4. Create an integration test using pytest that will look for yesterday's games and validate all playby pay data. Super cool feature as it will produce the following
========================================================================================================================= test session starts =========================================================================================================================
platform win32 -- Python 3.7.2, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: C:\Users\randy\Development\nba_api
collecting ... test
collected 2823 items                                                                                                                                                                                                                                                   

tests\stats\library\playbyplay\test_pbp_integration.py .......................................................................................................................................................................................................................................................................................................................................................................F...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

============================================================================================================================== FAILURES ===============================================================================================================================
____________________________________________________________________________________________________________________ test_play[0021800665-play359] ____________________________________________________________________________________________________________________

game = '0021800665', play = {'EVENTMSGACTIONTYPE': 9, 'EVENTMSGTYPE': 5, 'EVENTNUM': 492, 'GAME_ID': '0021800665', ...}

    def test_play(game, play):
        for count in range(0, 1):
            dict_patterns = eventmsgtype_to_re[EventMsgType(play["EVENTMSGTYPE"])]
            description = play["HOMEDESCRIPTION"] if count == 0 else play["VISITORDESCRIPTION"]
    
            #Validate description
            if description is not None:
                match = False
                for pattern in dict_patterns:
                    if pattern.match(description): match = True
    
                if match == False:
                    msg = 'EVENTMSGTYPE {eventmsgtype}: [{description}]\n\tAttempted Patterns\n'.format(eventmsgtype=play["EVENTMSGTYPE"], description=description )
                    for pattern in dict_patterns:
                        msg += '\t\t{pattern}\n'.format(pattern=pattern.pattern)
    
>                   assert False, msg
E                   AssertionError: EVENTMSGTYPE 5: [WIZARDS Turnover: 5 Second Violation (T#12)]
E                       Attempted Patterns
E                               ^(?P<player>\w+((?#char)(\. \w+)|(\-?\'?\w+))?((?#suffix)([\s](Jr\.|III|II|IV)))?)\s{1,2}?(?P<turnover_type>[\w+?\-? ]*) (Turnover[ ]?)+ \(P(?P<personal>\d+)\.T(?P<team>\d+)\)$
E                               ^(?P<player>\w+((?#char)(\. \w+)|(\-?\'?\w+))?((?#suffix)([\s](Jr\.|III|II|IV)))?)\s{1,2}?STEAL \((?P<steals>\d+) STL\)$
E                               ^(?P<team>\w+( \w+)?) Turnover: (?P<turnover_type>\w+\s?\w+) \(T#(?P<turnovers>\d+)\)$
E                     
E                   assert False

tests\stats\library\playbyplay\test_pbp_integration.py:58: AssertionError
=============================================================================================================== 1 failed, 2822 passed in 10.92 seconds ================================================================================================================

… to validate previous days play by play data.
@swar swar merged commit ffb37a0 into swar:master Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants