def test_calc_average_rating_with_out_ratings(): p = Provider('1', '1', '1', '', '', '') assert (p.average_rating == 0) p.add_rating('*****@*****.**', 3) p.remove_rating('*****@*****.**') assert (p.average_rating == 0)
def test_calc_average_rating_with_1_rating(): p = Provider('1', '1', '1', '', '', '') p.add_rating('*****@*****.**', 3) assert (p.average_rating == 3)
def test_calc_average_rating_with_more_than_1_rating(): p = Provider('1', '1', '1', '', '', '') p.add_rating('*****@*****.**', 3) p.add_rating('*****@*****.**', 2) p.add_rating('*****@*****.**', 5) assert (p.average_rating == (3 + 2 + 5) / (float(3)))
def test_remove_rating_of_existing_patient(): p = Provider('1', '1', '1', '', '', '') p.add_rating('*****@*****.**', 3) checker = p.remove_rating('*****@*****.**') assert (checker == True) assert (list(p.rating.keys()) == [])
def test_add_rating_for_existing_patient(): p = Provider('1', '1', '1', '', '', '') p.add_rating('*****@*****.**', 3) assert (p.rating['*****@*****.**'] == 3) p.add_rating('*****@*****.**', 5) assert (p.rating['*****@*****.**'] == 5)
def test_add_string_rating(): p = Provider('1', '1', '1', '', '', '') assert (list(p.rating.keys()) == []) checker = p.add_rating('*****@*****.**', '1') assert (checker == False) assert (list(p.rating.keys()) == [])
def test_add_int_NOT_between_0_and_5_rating(): p = Provider('1', '1', '1', '', '', '') assert (list(p.rating.keys()) == []) checker = p.add_rating('*****@*****.**', -1) assert (checker == False) assert (list(p.rating.keys()) == [])
def test_add_int_between_0_and_5_rating(): p = Provider('1', '1', '1', '', '', '') p.add_rating('*****@*****.**', 3) assert ('*****@*****.**' in p.rating.keys()) assert (p.rating['*****@*****.**'] == 3)