def test_validation_raises_exception_if_one_of_the_elements_of_the_tuples_is_not_integer(self):
		fractions = [(1, 5), (1, 2.0)]
		exc = None

		try:
			validate_input_collect(fractions)
		except Exception as err:
			exc = err

		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'Tuple can only contain integers.')
	def test_validation_raises_exception_if_one_of_the_elements_has_denominator_zero(self):
		fractions = [(1, 2), (1, 0)]
		exc = None

		try:
			validate_input_collect(fractions)
		except Exception as err:
			exc = err

		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'Cannot devide by zero.')
	def test_validation_raises_exception_if_length_of_element_is_not_two(self):
		fractions = [(1, 2), (1, 3, 4)]
		exc = None

		try:
			validate_input_collect(fractions)
		except Exception as err:
			exc = err

		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'Tuple can only contain 2 elements.')
	def test_validation_raises_exception_if_fractions_is_not_of_type_list(self):
		fractions = ((1, 3), (4, 5))
		exc = None

		try:
			validate_input_collect(fractions)
		except Exception as err:
			exc = err

		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'Argument can only be of type "list".')
	def test_validation_raises_exception_with_empty_list(self):
		fractions = []
		exc = None

		try:
			validate_input_collect(fractions)
		except Exception as err:
			exc = err

		self.assertIsNotNone(exc)
		self.assertEqual(str(exc), 'List cannot be empty.')
def sort_fractions(fractions, ascending=True):
    validate_input_collect(fractions)
    validate_ascending(ascending)

    length = len(fractions)

    for i in range(0, length - 1):
        for j in range(0, length - i - 1):
            a = fractions[j]
            b = fractions[j + 1]
            if (a[0] / a[1]) > (b[0] / b[1]):
                helper = fractions[j]
                fractions[j] = fractions[j + 1]
                fractions[j + 1] = helper

    if ascending == False:
        fractions.reverse()

    return fractions
	def test_validation_passes_with_correct_input(self):
		fractions = [(1, 3), (4, 5)]

		validate_input_collect(fractions)