Ejemplo n.º 1
0
 def test_filter_dataset_nofilter(self):
     ''' Test if dataset returns when no filter is actually sent '''
     self.assertEqual(
         BaseModel.filter_pandas_dataset(SAMPLE_DATAFRAME, None).to_dict(),
         {
             'col_1': {0: 'd', 1: 'b', 2: 'a', 3: 'c'},
             'col_2': {0: 3, 1: 2, 2: 1, 3: 0},
             'col_3': {0: 3, 1: 2, 2: 1, 3: 0}
         }
     )
Ejemplo n.º 2
0
 def test_filter_dataset_mixed(self):
     ''' Test if dataset is filtered by multiple clauses '''
     self.assertEqual(
         BaseModel.filter_pandas_dataset(
             SAMPLE_DATAFRAME_NA,
             [['post', 'in', 'col_3', '3', '1'], ['post', 'in', 'col_2', '3', '2']]
         ).to_dict(),
         {
             'col_1': {0: 'd'},
             'col_2': {0: 3},
             'col_3': {0: 3}
         }
     )
Ejemplo n.º 3
0
 def test_filter_dataset_nn(self):
     ''' Test if dataset is filtered by NN clause '''
     self.assertEqual(
         BaseModel.filter_pandas_dataset(
             SAMPLE_DATAFRAME_NA,
             [['post', 'nn', 'col_2']]
         ).to_dict(),
         {
             'col_1': {0: 'd', 1: 'b', 2: 'a'},
             'col_2': {0: 3, 1: 2, 2: 1},
             'col_3': {0: 3, 1: 2, 2: 1}
         }
     )
Ejemplo n.º 4
0
 def test_filter_dataset_in(self):
     ''' Test if dataset is filtered by IN clause '''
     self.assertEqual(
         BaseModel.filter_pandas_dataset(
             SAMPLE_DATAFRAME,
             [['post', 'in', 'col_2', '3', '2']]
         ).to_dict(),
         {
             'col_1': {0: 'd', 1: 'b'},
             'col_2': {0: 3, 1: 2},
             'col_3': {0: 3, 1: 2}
         }
     )
Ejemplo n.º 5
0
 def test_filter_dataset_eq(self):
     ''' Test if dataset is filtered by EQ clause '''
     self.assertEqual(
         BaseModel.filter_pandas_dataset(
             SAMPLE_DATAFRAME,
             [['post', 'eq', 'col_2', '3']]
         ).to_dict(),
         {
             'col_1': {0: 'd'},
             'col_2': {0: 3},
             'col_3': {0: 3}
         }
     )