Esempio n. 1
0
 def map_games(self):
     if self.rdd is None or not isinstance(self.rdd, RDD):
         raise Exception("Invalid RDD")
     game_fields = MapGames.get_game_fields(self.rdd)
     if game_fields is None or not isinstance(game_fields, RDD):
         raise Exception("game_fields is None or not an instance of RDD")
     mapped_games = MapGames.map_games(game_fields)
     if mapped_games is None or not isinstance(mapped_games, RDD):
         raise Exception("mapped_games is None or not an instance of RDD")
     return mapped_games
Esempio n. 2
0
def test_get_mapped_game_invalid_len(spark_context):
    rdd = spark_context.parallelize(
        ["1,2,3,4,5,6", "10,20,30,40,50,60", "400,500,600,700,800,900"])
    game_fields = MapGames.get_game_fields(rdd)
    mapped_games = MapGames.map_games(game_fields).collect()
    for r in mapped_games:
        if r[0] == "1":
            assert r[1] is None
        if r[0] == "10":
            assert r[1] is None
        if r[0] == "100":
            assert r[1] is None
Esempio n. 3
0
def test_get_mapped_game(spark_context):
    rdd = spark_context.parallelize(
        ["1,2,3,4,5,6,7,8,9", "10,20,30,40,50,60,70,80,90", "100,200,300,400,500,600,700,800,900"])
    game_fields = MapGames.get_game_fields(rdd)
    mapped_games = MapGames.map_games(game_fields).collect()
    for r in mapped_games:
        if r[0] == "1":
            assert r[1].homeTeam == "8"
            assert r[1].visitingTeam == "9"
            assert r[1].season == "6"
        if r[0] == "10":
            assert r[1].homeTeam == "80"
            assert r[1].visitingTeam == "90"
            assert r[1].season == "60"
        if r[0] == "100":
            assert r[1].homeTeam == "800"
            assert r[1].visitingTeam == "900"
            assert r[1].season == "600"
Esempio n. 4
0
def test_get_mapped_game_not_rdd(spark_context):
    mapped_games = MapGames.map_games({})
    assert mapped_games is None