Esempio n. 1
0
 def test_show_wrong_arg(self):
     try:
         Standings(server).show(None)
     except TypeError:
         pass
Esempio n. 2
0
 def test_get_eastern_standings(self):
     self.assertIsNotNone(Standings(server).get_eastern_standings())
Esempio n. 3
0
 def test_get_standings_correct_argument(self):
     a = Standings(server)
     self.assertIsNotNone(a.get_standings(server.get_all_standings()))
Esempio n. 4
0
 def test_get_standings_wrong_argument(self):
     try:
         Standings(server).get_standings(None)
     except TypeError:
         pass
Esempio n. 5
0
 def test_init(self):
     self.assertIsNotNone(Standings(server))
Esempio n. 6
0
def standings():
    global standings_buff
    if date is None:
        set_data()
    while True:
        stdscr.clear()
        stdscr.refresh()

        title = "STANDINGS"
        all_st = "1. All standings"
        western = "2. Western conference standings"
        eastern = "3. Eastern conference standings"
        back = "4. Back"
        enter_message = "Enter your choice: "

        stdscr.clear()
        stdscr.refresh()

        to_print = []
        to_print.extend((all_st, western, eastern, back, enter_message))

        start_x = 5

        start_y = 2

        print_title(start_y, start_x, title)

        for item in to_print:
            start_y += 2
            stdscr.addstr(start_y, start_x, item)

        curses.echo()

        stdscr.move(start_y, start_x + len(enter_message))

        tmp = stdscr.getstr(start_y, start_x + len(enter_message), 1)

        option = int(tmp.decode("utf-8"))

        if option == 4:
            return
        elif option != 3 and option != 2 and option != 1:
            wrong_oprion()
            continue
        try:
            standings_var = Standings(server)
            if option == 1:
                standings_buff = standings_var.get_all_standings()
            elif option == 2:
                standings_buff = standings_var.get_western_standings()
            elif option == 3:
                standings_buff = standings_var.get_eastern_standings()

            standings_var.show(standings_buff)
            break
        except NoDataFoundError:
            msg = "No standings information on given date, please change date and try again."
            print_middle(msg)
            stdscr.getch()
        except ConnectionError:
            msg = "Cannot connect to the server"
            print_middle(msg)
            stdscr.getch()
        except TypeError as err:
            msg = 'Type error {}'.format(err)
            print_middle(msg)
            stdscr.getch()
        return