Exemplo n.º 1
0
 def test_input_not_dataframe(self):
     '''
     Test function raises error when input is not dataframe
     '''
     df_input = "some string"
     with pytest.raises(TypeError):
         df_output = calculate(data=df_input)
Exemplo n.º 2
0
 def test_statistic_not_implemented(self):
     '''
     Test function response with a statistic that has not been implemented
     '''
     df_input = pd.DataFrame()
     with pytest.raises(Exception):
         df_output = calculate(data=df_input, stat="asdfasdf")
Exemplo n.º 3
0
 def test_empty_dataframe(self):
     '''
     Test function response with an emtpy dataframe, expect error.
     '''
     df_input = pd.DataFrame()
     with pytest.raises(Exception):
         df_output = calculate(data=df_input)
Exemplo n.º 4
0
 def test_output_statistic(self):
     '''
     Test that the output's statistic is coming out as expected.
     '''
     df_input = pd.DataFrame(columns=["response", "sample_id"],
                           data=[[1,1],[2,1],[2,2],[3,2],[3,3],[4,3]])
     df_output = calculate(df_input)
     assert df_output['stat'].dtype == "float64"
     assert df_output.loc[df_output['sample_id']==3]['stat'][2] == 3.5
Exemplo n.º 5
0
    def test_shape_output(self):
        '''
        Test that the output's shape is coming out as expected.
        '''
        df_input = pd.DataFrame(columns=["response", "sample_id"],
                              data=[[1,1],[2,1],[2,2],[3,2],[3,3],[4,3]])
        df_output = calculate(df_input)
        # Since the calculate is taking the output of generate as input,
        # the shape of the input should be (n,2), and the test data shape is (6,2)
        # Hence, the output shape should be (# of sample_id, 2)

        assert df_output.shape == (3,2)