def bubble_sort(list):
  n = len(list)
  for i in range(n):
    for j in range(0, n-i-1):
      if list[j] > list[j+1] :
        list[j], list[j+1] = list[j+1], list[j]

  return list

def main():
  list = [5,3,2,4,1]
  print("Original List: ", list)
  sorted_list = bubble_sort(list)
  print("Sorted List: ", sorted_list)
  list = [5,3,2,4,1]
  print("Original List: ", list)
  sorted_list = sortasscending(list)


#create a test for def sortasscending(list)
def sortasscending(list):
  n = len(list)
  for i in range(n):
    for j in range(0, n-i-1):
      if list[j] > list[j+1] :
        list[j], list[j+1] = list[j+1], list[j]

  return list
    

main()

import unittest
from bbsort import bubble_sort
from bbsort import sortasscending

class TestSortAscending(unittest.TestCase):

  def test_sort_ascending_list(self):
    list_to_sort = [5,3,4,2,1]
    sorted_list = sortasscending(list_to_sort)
    self.assertEqual(sorted_list, [1, 2, 3, 4, 5])

  def test_sort_empty_list(self):
    list_to_sort = []
    sorted_list = sortasscending(list_to_sort)
    self.assertEqual(sorted_list, [])

  def test_sort_already_sorted_list(self):
    list_to_sort = [1,2,3,4,5]
    sorted_list = sortasscending(list_to_sort)
    self.assertEqual(sorted_list, [1, 2, 3, 4, 5])

class TestBubbleSort(unittest.TestCase):

  def test_sort_small_list(self):
    list_to_sort = [5,3,4,2,1]
    sorted_list = bubble_sort(list_to_sort) 
    self.assertEqual(sorted_list, [1,2,3,4,5])

  def test_sort_empty_list(self):
    list_to_sort = []
    sorted_list = bubble_sort(list_to_sort)
    self.assertEqual(sorted_list, [])

  def test_sort_already_sorted_list(self):  
    list_to_sort = [1,2,3,4,5]
    sorted_list = bubble_sort(list_to_sort)
    self.assertEqual(sorted_list, [1,2,3,4,5])

if __name__ == '__main__':
  unittest.main()
