Ejemplo n.º 1
0
 def test_output_to_csv(self):
     client.search(
         term="ko",
         output_type=OutputType.CSV,
         output_file_path="./ko-search.csv",
         output_write_option=OutputWriteOption.WRITE,
     )
Ejemplo n.º 2
0
 def test_output_to_json(self):
     client.search(
         term="ko",
         output_type=OutputType.JSON,
         output_file_path="./ko-search.json",
         output_write_option=OutputWriteOption.WRITE,
     )
Ejemplo n.º 3
0
 def test_ko_search_json_output_includes_expected_json_output(self):
     client.search(
         term="ko",
         output_type=OutputType.JSON,
         output_file_path=self.output_file_path,
         output_write_option=OutputWriteOption.WRITE,
     )
     with open(self.output_file_path, "r", encoding="utf8") as output_file, \
             open(self.expected_output_file_path, "r", encoding="utf8") as expected_output_file:
         output_data = json.load(output_file)
         expected_output_data = json.load(expected_output_file)
         for expected_data_row in expected_output_data:
             self.assertTrue(expected_data_row in output_data)
Ejemplo n.º 4
0
 def test_players_in_kobe_search_results(self):
     results = client.search(term="kobe")
     self.assertListEqual(
         [
             {
                 "name": "Kobe Bryant",
                 "identifier": "bryanko01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
             },
             {
                 "name": "Ruben Patterson",
                 "identifier": "patteru01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
             },
             {
                 "name": "Dion Waiters",
                 "identifier": "waitedi01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
             },
             {
                 "name": "Oleksandr Kobets",
                 "identifier": "kobetol01",
                 "leagues": set()
             }
         ],
         results["players"]
     )
 def test_exact_search_result(self):
     results = client.search(term="kobe bryant")
     self.assertEqual([{
         "name": "Kobe Bryant",
         "identifier": "bryanko01",
         "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
     }], results["players"])
Ejemplo n.º 6
0
    def test_ko_csv_output_search_includes_expected_csv_output(self):
        client.search(
            term="ko",
            output_type=OutputType.CSV,
            output_file_path=self.output_file_path,
            output_write_option=OutputWriteOption.WRITE,
        )

        with open(self.output_file_path, "r", encoding="utf8") as output_file, \
                open(self.expected_output_file_path, "r", encoding="utf8") as expected_output_file:
            output_data = output_file.readlines()
            expected_output_data = expected_output_file.readlines()
            for expected_data_row in expected_output_data:
                # TODO: @jaebradley this is freakin' gross but sets are not ordered (duh)
                # so serialization of the set of leagues will not be consistent.
                # Need to find a way to use an ordered set or something for this.
                # In the interim, ignore serialized sets of leagues - quick and dirty way
                # is to look for `-` (this ignores players with a `-` but I'll take the tradeoff for now)
                if "-" not in expected_data_row:
                    self.assertTrue(expected_data_row in output_data)
Ejemplo n.º 7
0
 def test_search_rick_barry(self):
     results = client.search(term="Rick Barry")
     self.assertEqual(
         [
             {
                 "name": "Rick Barry",
                 "identifier": "barryri01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION, League.AMERICAN_BASKETBALL_ASSOCIATION}
             }
         ],
         results["players"]
     )
Ejemplo n.º 8
0
 def test_search_dominique_wilkins(self):
     results = client.search(term="Dominique Wilkins")
     self.assertEqual(
         [
             {
                 "name": "Dominique Wilkins",
                 "identifier": "wilkido01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
             }
         ],
         results["players"]
     )
Ejemplo n.º 9
0
 def test_search_alonzo_mourning(self):
     results = client.search(term="Alonzo Mourning")
     self.assertEqual(
         [
             {
                 "name": "Alonzo Mourning",
                 "identifier": "mournal01",
                 "leagues": {League.NATIONAL_BASKETBALL_ASSOCIATION}
             }
         ],
         results["players"]
     )
Ejemplo n.º 10
0
 def test_length_of_kobe_search_results(self):
     results = client.search(term="kobe")
     self.assertEqual(4, len(results["players"]))
Ejemplo n.º 11
0
 def test_search_results_key(self):
     results = client.search(term="jaebaebae")
     self.assertListEqual(list(results), ["players"])
Ejemplo n.º 12
0
 def test_search_jaebaebae(self):
     results = client.search(term="jaebaebae")
     self.assertListEqual([], results["players"])
Ejemplo n.º 13
0
 def test_search_ja(self):
     results = client.search(term="ja")
     self.assertIsNotNone(results["players"])
Ejemplo n.º 14
0
 def test_large_search_pagination(self):
     results = client.search(term="a")
     self.assertGreaterEqual(len(results["players"]), 960)
Ejemplo n.º 15
0
 def test_search_ja(self):
     results = client.search(term="ja")
     self.assertLessEqual(498, len(results["players"]))
Ejemplo n.º 16
0
def find_players(player_name):
    return client.search(term=player_name)["players"]
Ejemplo n.º 17
0
 def test_search_alonz(self):
     results = client.search(term="Alonz")
     self.assertGreaterEqual(6, len(results["players"]))