def test_confidence_interval_calculator(self): test_data = CsvReader("/Tests/Data/randomdata.csv") answers = CsvReader('Tests/Data/answers.csv').data values = Data(test_data, 'value') for column in answers: self.assertEqual(self.statistics.conf_interval(values), (float( column['conf_int_high']), float(column['conf_int_low'])))
def test_proportion(self): test_data = CsvReader("/Tests/Data/randomdata.csv") answers = CsvReader("Tests/Data/answers.csv").data values = Data(test_data, 'value') for column in answers: self.assertEqual(self.statistics.proportion(values), float((column['proportion'])))
def test_z_score(self): test_data = CsvReader("/Tests/Data/randomdata.csv") answers = CsvReader("Tests/Data/answers.csv").data values = Data(test_data, "value") for column in answers: self.assertEqual(self.statistics.z_score(values), float((column['zscore'])))
def test_sqrt_method_calculator(self): test_data = CsvReader("Tests/Data/sq_rt.csv").data pprint(test_data) for row in test_data: self.assertEqual(self.calculator.sq_rt(int(row['Value 1'])), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) test_data.clear()
def test_pop_std_dev(self): test_data = CsvReader("/Tests/Data/randomdata.csv") answers = CsvReader("Tests/Data/answers.csv").data values = Data(test_data, 'value') for column in answers: self.assertEqual( round(self.statistics.pop_standard_dev(values), 4), float((column['PSD'])))
def test_divide_method_calculator(self): test_data = CsvReader("Tests/Data/division.csv").data pprint(test_data) for row in test_data: self.assertEqual( self.calculator.divide(row['Value 1'], row['Value 2']), float(row['Result'])) self.assertEqual(self.calculator.result, float(row['Result'])) test_data.clear()
def test_sqrt(self): test_data = CsvReader("Tests/testdata/UnitTestSquareRoot.csv").data for row in test_data: fmt = ".8f" result = float(row['Result']) if float(result).is_integer(): fmt = ".1f" result = format(float(row['Result']), fmt) self.assertEqual(self.calculator.sqrt(row['Value 1']), result)
def test_sample_variance(self): test_data = CsvReader("/Tests/Data/randomdata.csv") answers = CsvReader("Tests/Data/answers.csv").data values = Data(test_data, 'value') x = self.statistics.sample_variance(values) self.assertEqual(x, x)
def test_CSV(self): test_data = CsvReader("Tests/Data/csvtester.csv").data for row in test_data: self.assertEqual(row["Value 1"], "480")
def test_square(self): test_data = CsvReader("Tests/testdata/UnitTestSquare.csv").data for row in test_data: result = float(row['Result']) self.assertEqual(self.calculator.square(row['Value 1']), result)
def test_divide(self): test_data = CsvReader("Tests/testdata/UnitTestDivision.csv").data for row in test_data: result = format(float(row['Result']), '.9f') # print('Result is: ' + result) self.assertEqual(self.calculator.divide(row['Value 2'], row['Value 1']), result)
def test_multiply(self): test_data = CsvReader("Tests/testdata/UnitTestMultiplication.csv").data for row in test_data: result = float(row['Result']) self.assertEqual(self.calculator.multiply(float(row['Value 2']), float(row['Value 1'])), result)
def test_subtraction(self): test_data = CsvReader("Tests/testdata/UnitTestSubtraction.csv").data for row in test_data: result = float(row['Result']) self.assertEqual(self.calculator.subtract(float(row['Value 2']), float(row['Value 1'])), result)