Exemple #1
0
 def check(self, datadir):
     for parm in self.parameters:
         if not parm['ts_id']:
             continue
         actual_ts = Timeseries(parm['ts_id'])
         enhydris_api.read_tsdata(self.base_url, self.cookies, actual_ts)
         reference_ts = Timeseries()
         with open(os.path.join(
                 datadir, 'generated', parm['expname'] + '.txt')) as f:
             reference_ts.read(f)
             precision = self.guess_precision(f)
         self.assertTimeseriesEqual(actual_ts, reference_ts, precision,
                                    parm['expname'] + '.txt')
Exemple #2
0
 def run_test(self):
     if not self.base_url:
         return
     d = {'filename': full_testdata_filename(self.filename),
          'datafile_fields': str(self.timeseries_id),
          'datafile_format': 'irrelevant'}
     d.update(self.datafiledict)
     df = Datafile_simple(self.base_url, self.cookies, d)
     df.update_database()
     enhydris_api.read_tsdata(self.base_url, self.cookies, self.ts)
     self.assertEqual(len(self.ts), len(self.ref_ts))
     (items, ritems) = [x.items() for x in (self.ts, self.ref_ts)]
     for item, ritem in zip(items, ritems):
         self.assertEqual(item[0], ritem[0])
         self.assertAlmostEqual(item[1], ritem[1], 4)
         self.assertEqual(item[1].flags, ritem[1].flags)
Exemple #3
0
 def upload_test(self):
     d = {'filename': self.file1,
          'datafile_fields': self.datafile_fields,
          'datafile_format': 'msaccess',
          'table': 'Clima'}
     d.update(self.datafiledict)
     df = self.class_being_tested(self.base_url, self.cookies, d)
     df.update_database()
     enhydris_api.read_tsdata(self.base_url, self.cookies, self.ts1)
     enhydris_api.read_tsdata(self.base_url, self.cookies, self.ts2)
     self.assertEqual(len(self.ts1), 10)
     self.assertEqual(len(self.ts2), 10)
     (items1, items2, ritems1, ritems2) = [
         x.items() for x in (self.ts1, self.ts2,
                             self.ref_ts1, self.ref_ts2)]
     for i in range(0, 10):
         self.assertEqual(items1[i][0], ritems1[i][0])
         self.assertAlmostEqual(items1[i][1], ritems1[i][1], 4)
         self.assertEqual(items1[i][1].flags, ritems1[i][1].flags)
         self.assertEqual(items2[i][0], ritems2[i][0])
         self.assertAlmostEqual(items2[i][1], ritems2[i][1], 4)
         self.assertEqual(items2[i][1].flags, ritems2[i][1].flags)
     d['filename'] = self.file2
     df = self.class_being_tested(self.base_url, self.cookies, d)
     df.update_database()
     enhydris_api.read_tsdata(self.base_url, self.cookies, self.ts1)
     enhydris_api.read_tsdata(self.base_url, self.cookies, self.ts2)
     self.assertEqual(len(self.ts1), 17)
     self.assertEqual(len(self.ts2), 17)
     (items1, items2, ritems1, ritems2) = [
         x.items() for x in (self.ts1, self.ts2,
                             self.ref_ts1, self.ref_ts2)]
     for i in range(0, 17):
         self.assertEqual(items1[i][0], ritems1[i][0])
         self.assertAlmostEqual(items1[i][1], ritems1[i][1], 4)
         self.assertEqual(items1[i][1].flags, ritems1[i][1].flags)
         self.assertEqual(items2[i][0], ritems2[i][0])
         self.assertAlmostEqual(items2[i][1], ritems2[i][1], 4)
         self.assertEqual(items2[i][1].flags, ritems2[i][1].flags)