Example #1
0
File: tests.py Project: jo-dy/plotr
 def setUp(self):
     WINE_CSVPATH = 'plotr/testdata/wine.csv'
     self.data = dataimport.fix_data(dataimport.readcsv(WINE_CSVPATH))
     self.modelInsert = dataimport.create_model(self.data,
                                                "Alabaster Plaster")
     WINE_CSVPATH = 'plotr/testdata/wine_with_blanks.csv'
     self.dataBlank = dataimport.fix_data(dataimport.readcsv(WINE_CSVPATH))
     self.modelBlank = dataimport.create_model(self.dataBlank,
                                               "Alabaster Plaster")
Example #2
0
File: tests.py Project: jo-dy/plotr
 def test_low_quality_data(self):
     POOR_QUALITY_CSV = 'plotr/testdata/poordata.csv'
     new_data_low_quality = dataimport.fix_data(
         dataimport.readcsv(POOR_QUALITY_CSV))
     warnings = new_data_low_quality['warnings']
     modelLowQual = dataimport.create_model(new_data_low_quality,
                                            "Something About Fruits")
     print
     print "[*] Begin Testing insertion of data from poorly formatted csv"
     print "[+] INFO: data_id: %s " % modelLowQual.data_id
     correct_headers = [
         "Potato", "Field2", "Bananas", "Orange", "AppleSauce", "Potato1",
         "Field7"
     ]
     actual_headers = []
     for f in modelLowQual.fields.all():
         actual_headers.append(f.fieldName)
     #print correct_headers, actual_headers
     self.assertEqual(len(actual_headers), len(correct_headers))
     print "[+] OK  : field count correct"
     difference = set(correct_headers) - set(actual_headers)
     self.assertEqual(len(difference), 0)
     print "[+] OK  : Actual Headers == Correct Headers"
     self.assertEqual(len(warnings), 6)
     correct_warnings = [
         "Renamed field 2: '' to 'Field2'",
         "Renamed field 3: 'Banana's' to 'Bananas'",
         "Renamed field 4: 'Orange!' to 'Orange'",
         "Renamed field 5: 'Apple Sauce' to 'AppleSauce'",
         "Renamed field 6: 'Potato' to 'Potato1'",
         "Renamed field 7: '' to 'Field7'"
     ]
     self.assertEqual(sorted(warnings), correct_warnings)
     print "[*] End of Testing insertion of data from csv"
Example #3
0
File: tests.py Project: jo-dy/plotr
    def test_model_inserted(self):
        WINE_FIELDCOUNT = 7
        WINE_VALUECOUNT = 25
        WINE_CSVPATH = 'plotr/testdata/wine.csv'
        WINE_TABPATH = 'plotr/testdata/wine.txt'

        for p in (WINE_CSVPATH, WINE_TABPATH):
            print
            if p == WINE_CSVPATH:
                print "[*] Begin Testing insertion of data from csv"
                new_data_wine = dataimport.fix_data(dataimport.readcsv(p))
            else:
                print "[*] Begin Testing insertion of data from tab-delimited text"
                new_data_wine = dataimport.fix_data(
                    dataimport.readcsv(p, delim='\t'))
            warnings = new_data_wine['warnings']
            modelInsert = dataimport.create_model(new_data_wine, "Wine")
            print "[+] INFO: data_id: %s " % modelInsert.data_id
            self.assertEqual(len(modelInsert.fields.all()), WINE_FIELDCOUNT)
            print "[+] OK  : field count correct"
            for f in modelInsert.fields.all():
                self.assertEqual(len(f.values.all()), WINE_VALUECOUNT)
            print "[+] OK  : value count correct"
            self.assertEqual(len(warnings), 0)
            print "[+] OK  : No warnings on clean file"
            print "[*] End of Test"
Example #4
0
File: tests.py Project: jo-dy/plotr
 def setUp(self):
     WINE_CSVPATH = 'plotr/testdata/wine.csv'
     self.data = dataimport.fix_data(dataimport.readcsv(WINE_CSVPATH))
     self.modelT = dataimport.create_model(self.data, "Alabaster Plaster")
     pass