def test_stock_price_summary_with_one_negative_value(self):
     """ Test stock_price_summary function with a list
         with one negative value """
     price_changes = [-1.0]
     actual = a1.stock_price_summary(price_changes)
     expected = (0.0, -1.0)
     self.assertEqual(actual, expected)
Esempio n. 2
0
 def test_stock_price_summary_empty(self):
     """
     Test stock_price_summary where there is not gains in price changes.
     """
     actual = a1.stock_price_summary([])
     expected = (0, 0)
     self.assertEqual(actual, expected)
Esempio n. 3
0
    def test_stock_price_changes_exm_1(self):
        '''Test a1.stock_price_summary with empty list.'''

        list = []
        actual = a1.stock_price_summary(list)
        expected = (0, 0)
        self.assertEqual(expected, actual)
Esempio n. 4
0
 def test_stock_price_summary_one_not_price_change(self):
     """
     Test stock_price_summary where there is only price change value with zero.
     """
     actual = a1.stock_price_summary([0])
     expected = (0, 0)
     self.assertEqual(actual, expected)
Esempio n. 5
0
    def test_stock_price_changes_exm_4(self):
        '''Test a1.stock_price_summary with 0 along with both pos & neg value in the list.'''

        list = [2, 0, -4]
        actual = a1.stock_price_summary(list)
        expected = (2, -4)
        self.assertEqual(expected, actual)
Esempio n. 6
0
    def test_stock_price_changes_exm_5(self):
        '''Test a1.stock_price_summary with multiple value in the list.'''

        list = [1.01, -2.00, 0, 3.15, -4.21, 0.97, -0.54, 0]
        actual = a1.stock_price_summary(list)
        expected = (5.13, -6.75)
        self.assertEqual(expected, actual)
Esempio n. 7
0
    def test_stock_price_changes_exm_2(self):
        '''Test a1.stock_price_summary with one positive value in list.'''

        list = [3]
        actual = a1.stock_price_summary(list)
        expected = (3, 0)
        self.assertEqual(expected, actual)
Esempio n. 8
0
    def test_stock_price_changes_exm_3(self):
        '''Test a1.stock_price_summary with one neg value in the list.'''

        list = [-2]
        actual = a1.stock_price_summary(list)
        expected = (0, -2)
        self.assertEqual(expected, actual)
Esempio n. 9
0
	def test_stock_price_summary_empty_list(self):
		"testing stock_price_summary function with an empty list as input"
		price_changes = []
		actual_result = a1.stock_price_summary(price_changes)
		expected_result = (0.0,0.0)
		
		self.assertEqual(actual_result, expected_result)
 def test_stock_price_summary_empty(self):
     """
     Test stock_price_summary when input list is empty.
     """
     actual = a1.stock_price_summary([])
     expected = (0, 0)
     self.assertEqual(actual, expected)
Esempio n. 11
0
	def test_stock_price_summary_negative_value(self):
		"testing stock_price_summary function with a single negative value as input"
		price_changes = [-5.0]
		actual_result = a1.stock_price_summary(price_changes)
		expected_result = (0.0,-5.0)
		
		self.assertEqual(actual_result, expected_result)
Esempio n. 12
0
	def test_stock_price_summary_multiple_positive_negative_values(self):
		"testing stock_price_summary function with different negative and positive values as input"
		price_changes = [5.0,-5.0,3.0,-3.0,1,-1]
		actual_result = a1.stock_price_summary(price_changes)
		expected_result = (9.0,-9.0)
		
		self.assertEqual(actual_result, expected_result)
    def test_stock_price_example_7(self):
        """Test stock_price with [10, 0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01, 12]."""

        actual = a1.stock_price_summary(
            [10, 0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01, -12])
        expected = (10.14, -12.17)
        self.assertEqual(expected, actual)
    def test_stock_price_example_6(self):
        """Test stock_price with [-0.01, -0.03, -0.02, -0.14, 0, 0, -0.10, -0.01]."""

        actual = a1.stock_price_summary(
            [-0.01, -0.03, -0.02, -0.14, 0, 0, -0.10, -0.01])
        expected = (0, -0.31)
        self.assertEqual(expected, actual)
Esempio n. 15
0
 def test_mixed_case(self):
     """
     Test a mixture of positive and negative price changes
     """
     actual = a1.stock_price_summary([0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
     expected = (0.14, -0.17)
     self.assertEqual(actual, expected)
Esempio n. 16
0
    def test_only_gains(self):
        """ Stock prices changes containing only increasing trend
        leading to gains only."""

        actual = a1.stock_price_summary([0.2])
        expected = (0.2, 0)
        self.assertEqual(expected, actual)
Esempio n. 17
0
    def test_both_trends(self):
        """ Stock prices changes containing increasing and decreasing
        trends leading to gains and losses."""

        actual = a1.stock_price_summary([0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
        expected = (0.14, -0.17)
        self.assertEqual(expected, actual)
Esempio n. 18
0
    def test_stock_price_summary_mix(self):
        """ Test stock_price_summary with list of negative, positive and zero item."""

        actual = a1.stock_price_summary(
            [-0.01, -0.03, -0.10, 0.01, 0.03, 0.10, 0])
        expected = (0.14, -0.14)
        self.assertEqual(expected, actual)
Esempio n. 19
0
 def test_stock_price_summary_with_multiple_negative_values(self):
     """ Test stock_price_summary function with a list
         with only multiple negative values """
     price_changes = [-0.01, -0.03, -0.14]
     actual = a1.stock_price_summary(price_changes)
     expected = (0.0, -0.18)
     self.assertEqual(actual, expected)
Esempio n. 20
0
 def test_stock_price_summary_1(self):
 	"""
 	Test stock_price_summary for a normal mixed number filled list.
 	"""
 	actual = a1.stock_price_summary([0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
 	expected = (0.14, -0.17)
 	self.assertEqual(expected, actual)
Esempio n. 21
0
 def test_stock_price_summary_with_mixed_positive_negative_values(self):
     """ Test stock_price_summary function with a list
         with mixed positive and negative values """
     price_changes = [0.01, -0.01, 0.03, -0.03, 0.14, -0.14]
     actual = a1.stock_price_summary(price_changes)
     expected = (0.18, -0.18)
     self.assertEqual(actual, expected)
Esempio n. 22
0
    def test_several_values(self):
        """Test a list of different values, from the example."""
        actual = a1.stock_price_summary(
            [0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
        expected = (0.14, -0.17)

        self.assertEqual(actual, expected)
    def test_gains(self):
        """
	  Test we get correct result for gains only
        """
        g = [0.3, 0.3, 0.3, 0.1]
        (gains, losses) = a1.stock_price_summary(g)
        self.assertAlmostEqual(gains, math.fsum(g))
 def test_empty_list(self):
     """
     Test stock_price_summary() with empty price_change list.
     """
     actual = a1.stock_price_summary([])
     expected = (0, 0)
     self.assertEqual(actual, expected)
    def test_losses(self):
        """
	  Test that we get correct result for losses	  
        """
        g = [-0.3, -0.3, -0.3, -0.1]
        (gains, losses) = a1.stock_price_summary(g)
        self.assertAlmostEqual(losses, math.fsum(g))
    def test_stock_price_summary_ex2(self):
        """Test stock_price_summary with new arguments"""

        actual = a1.stock_price_summary(
            [0.05, 0.08, -0.03, -0.14, 0.1, 0.6, 0])
        expected = (0.83, -0.17)
        self.assertEqual(expected, actual)
    def test_stock_price_summary_ex1(self):
        """Test the function with stock_price_summary"""

        actual = a1.stock_price_summary(
            [0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
        expected = (0.14, -0.17)
        self.assertEqual(expected, actual)
Esempio n. 28
0
 def test_stock_price_summary_only_losses(self):
     """
     Test stock_price_summary where there is not losses in price changes.
     """
     actual = a1.stock_price_summary([-0.1, -0.2, -0.1, 0, 0, -0.1, -0.1])
     expected = (0, -0.6)
     self.assertEqual(actual, expected)
Esempio n. 29
0
 def test_stock_price_summary_only_gains(self):
     """
     Test stock_price_summary where there is not gains in price changes.
     """
     actual = a1.stock_price_summary([0.1, 0.2, 0.1, 0.14, 0, 0, 0.1, 0.1])
     expected = (0.74, 0)
     self.assertEqual(actual, expected)
Esempio n. 30
0
 def test_stock_price_summary_no_gains_no_losses(self):
     """
     Test stock_price_summary where there is not gains neither losses in price changes.
     """
     actual = a1.stock_price_summary([0, 0, 0])
     expected = (0, 0)
     self.assertEqual(actual, expected)
Esempio n. 31
0
 def test_stock_price_summary_one_negative_price_change(self):
     """
     Test stock_price_summary where there is only one negative price change.
     """
     actual = a1.stock_price_summary([-0.01])
     expected = (0, -0.01)
     self.assertEqual(actual, expected)
    def test_stock_price_summary_mixed(self):
        """Test stock_price_summary when there are gains, losses, and zeros."""

        actual = a1.stock_price_summary(
            [0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01])
        expected = (0.14, -0.17)
        self.assertEqual(expected, actual)
Esempio n. 33
0
    def test_only_losses(self):
        """ Stock prices changes containing only decreasing trend
        leading to losses only."""

        actual = a1.stock_price_summary([-0.2])
        expected = (0, -0.2)
        self.assertEqual(expected, actual)
    def test_empty(self):
        """
	  Test if we have correct result in case of
	  empty list
        """
        (gains, losses) = a1.stock_price_summary([])
        self.assertAlmostEqual(gains, 0.0)
        self.assertAlmostEqual(losses, 0.0)
 def test_large_pricechange_list2(self):
     exp_result, price_chg = 0.0, []
     for i in range(100):
         price_chg.append(i / 100.0)
         price_chg.append(-i / 100.0)
         exp_result += i / 100.0
     gain, loss = a1.stock_price_summary(price_chg)
     self.assertEqual((exp_result, -exp_result), (round(gain, 10), round(loss, 10)))
Esempio n. 36
0
 def test_stock_price_summary_3(self):
 	"""
 	Test stock_price_summary with an empty list.
 	The return value should be the tuple (0.00, 0.00).
 	"""
 	actual = a1.stock_price_summary([])
 	expected = (0.00, 0.00)
 	self.assertEqual(expected, actual)
    def test_all(self):
        """
	  Test that we get correct result for losses
	  and gains
        """
        g = [-0.3, 0.3, -0.3, 0.3, 0.0]
        (gains, losses) = a1.stock_price_summary(g)
        self.assertAlmostEqual(losses, -0.6)
        self.assertAlmostEqual(gains, 0.6)
Esempio n. 38
0
 def test_stock_price_summary_2(self):
 	"""
 	Test stock_price_summary for a normal mixed number filled list.
 	In this case the sums exceed 1.00. The results are rounded to two
     decimal points using the round function.
 	""" 
 	actual = a1.stock_price_summary([0.01, 0.03, -0.60, 0, -0.40, 0.60, 0.50, -0.02])
 	expected = (1.14, -1.02)
 	self.assertEqual(expected, actual)
    def test_TSPS_example_1(self):
        """ Test stock_price_summary with [0.01, 0.03, -0.02, 0, 0, 0.10, -0.01]"""

        actual = a1.stock_price_summary([0.01, 0.03, -0.02, 0, 0, 0.10, -0.01])
        expected = (0.14, -0.03)
        self.assertEqual(actual, expected)
    def test_TSPS_example_2(self):
        """ Test stock_price_summary with no real vaules [0, 0, 0, 0]"""

        actual = a1.stock_price_summary([0, 0, 0, 0])
        expected = (0, 0)
        self.assertEqual(actual, expected)
    def test_TSPS_example_3(self):
        """ Test stock_price_summary with only positive vaules [0.12, 0.22, 0.01, 0.07]"""

        actual = a1.stock_price_summary([0.12, 0.22, 0.01, 0.07])
        expected = (0.42, 0)
        self.assertEqual(actual, expected)
 def test_list_with_one_positive_change(self):
     """Tests stock_price_summary with for one change"""
     positive_change = 1.32
     expected = (positive_change, 0.0)
     actual = a1.stock_price_summary([1.32])
     self.assertEquals(expected, actual)
 def test_stock_empty(self):
     """empty list"""
     price_changes = []
     expected = (0, 0)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
Esempio n. 44
0
 def test_single_positive_element_case(self):
     """
     a single positive element
     """
     self.assertEqual(a1.stock_price_summary([1.0]),(1.0,0))
Esempio n. 45
0
    def test_empty_changes(self):

        expected = (0, 0)
        actual = a1.stock_price_summary([])

        self.assertEqual(expected, actual)
 def test_stock_only_one(self):
     """list of one element"""
     price_changes = [0.3]
     expected = (0.3, 0)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
 def test_stock_all_zero(self):
     """list of all zero elements"""
     price_changes = [0, 0, 0, 0, 0]
     expected = (0, 0)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
Esempio n. 48
0
 def test_two_zero_positive_element_case(self):
     """
     two elements in list, one zero and one positive.
     """
     self.assertEqual(a1.stock_price_summary([1.0, 0]),(1.0,0))
Esempio n. 49
0
 def test_two_negative_zero_element_case(self):
     """
     two elements in list, one negative and one zero
     """
     self.assertEqual(a1.stock_price_summary([0, -1.0]),(0,-1.0))
 def test_empty_list(self):
     """Tests stock_price_summary with empty list"""
     expected = (0.0, 0.0)
     actual = a1.stock_price_summary([])
     self.assertEquals(expected, actual)
 def test_list_with_multiple_values(self):
     """Test the function with multiple values both positive and negative"""
     price_changes = [0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01]
     expected = (0.14, -0.17)
     actual = a1.stock_price_summary(price_changes)
     self.assertEquals(expected, actual)
 def test_list_with_one_negative_vhange(self):
     """Test stock_price_summary with one negative change"""
     negative_change = -1.32
     expected = (0.0, negative_change)
     actual = a1.stock_price_summary([-1.32])
     self.assertEquals(expected, actual)
Esempio n. 53
0
 def test_two_negative_positive_element_case(self):
     """
     two elements in list, one negative and one positive.
     """
     self.assertEqual(a1.stock_price_summary([1.0, -1.0]),(1.0,-1.0))
Esempio n. 54
0
 def test_null_case(self):
     """
     null list passed
     """
     self.assertEqual(a1.stock_price_summary([]),(0,0))
Esempio n. 55
0
 def test_single_negative_element_case(self):
     """
     a single negative element
     """
     self.assertEqual(a1.stock_price_summary([-1.0]),(0,-1.0))
 def test_stock_all_neg(self):
     """list of all negative values, i.e. without positive values"""
     price_changes = [-0.01, -0.02, -0.03, -0.14, -0, -0, -0.15, -0.06]
     expected = (0, -0.41)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
Esempio n. 57
0
 def test_zero_single_case(self):
     """
     a single element list and of value 0 is passed
     """
     self.assertEqual(a1.stock_price_summary([0]),(0,0))
 def test_stock_pos_and_neg(self):
     """list of mix of positive, negative and zero values"""
     price_changes = [0.01, 0.03, -0.02, -0.14, 0, 0, 0.10, -0.01]
     expected = (0.14, -0.17)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
 def test_stock_all_pos(self):
     """list of all positive or zero values, i.e. without negative values"""
     price_changes = [0.01, 0.02, 0.03, 0.14, 0, 0, 0.15, 0.06]
     expected = (0.41, 0)
     actual = a1.stock_price_summary(price_changes)
     self.assertEqual(actual, expected)
Esempio n. 60
0
 def test_general_case_more_negative(self):
     """
     combiation of more negative elements
     """
     self.assertEqual(a1.stock_price_summary([1.0, -1.0, -1.0]),(1.0,-2.0))