Skip to content

Commit d604263

Browse files
author
Remi Cresson
committed
TEST: fix tests
1 parent 1f6c83c commit d604263

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

tests/decloud_unittest.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class DecloudTest(ABC, unittest.TestCase):
1515
DECLOUD_DATA_DIR = get_env_var("DECLOUD_DATA_DIR")
1616

1717
def get_path(self, path):
18-
return os.path.join(self.DECLOUD_DATA_DIR, path)
18+
pth = os.path.join(self.DECLOUD_DATA_DIR, path)
19+
if not os.path.exists(pth):
20+
raise FileNotFoundError(f"Directory {pth} not found!")
21+
return pth
1922

2023
def compare_images(self, image, reference, mae_threshold=0.01):
2124

tests/train_from_tfrecords_unittest.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
SAVEDMODEL_FILENAME = "saved_model.pb"
1010

11+
1112
def is_savedmodel_written(args_list):
1213
out_savedmodel = "/tmp/savedmodel"
1314
base_args = ["--logdir", "/tmp/logdir",
@@ -25,51 +26,52 @@ def is_savedmodel_written(args_list):
2526

2627

2728
OS2_TFREC_PTH = "baseline/TFRecord/CRGA"
28-
OS2_ALL_BANDS_TFREC_PTH = "/baseline/TFRecord/CRGA_all_bands"
29-
MERANER_ALL_BANDS_TFREC_PTH = "/baseline/TFRecord/CRGA_all_bands"
29+
OS2_ALL_BANDS_TFREC_PTH = "baseline/TFRecord/CRGA_all_bands"
30+
MERANER_ALL_BANDS_TFREC_PTH = "baseline/TFRecord/CRGA_all_bands"
31+
ERRMSG = f"File {SAVEDMODEL_FILENAME} not found !"
3032

3133

3234
class TrainFromTFRecordsTest(DecloudTest):
3335

3436
def test_trainFromTFRecords_os1_unet(self):
3537
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_TFREC_PTH),
3638
"--model", "crga_os1_unet"]),
37-
"File {} not found !".format(SAVEDMODEL_FILENAME))
39+
ERRMSG)
3840

3941
def test_trainFromTFRecords_os2_david(self):
4042
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_TFREC_PTH),
4143
"--model", "crga_os2_david"]),
42-
"File {} not found !".format(SAVEDMODEL_FILENAME))
44+
ERRMSG)
4345

4446
def test_trainFromTFRecords_os2_unet(self):
4547
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_TFREC_PTH),
4648
"--model", "crga_os2_unet"]),
47-
"File {} not found !".format(SAVEDMODEL_FILENAME))
49+
ERRMSG)
4850

4951
def test_trainFromTFRecords_os1_unet_all_bands(self):
5052
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_ALL_BANDS_TFREC_PTH),
5153
"--model", "crga_os1_unet_all_bands"]),
52-
"File {} not found !".format(SAVEDMODEL_FILENAME))
54+
ERRMSG)
5355

5456
def test_trainFromTFRecords_os2_david_all_bands(self):
5557
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_ALL_BANDS_TFREC_PTH),
5658
"--model", "crga_os2_david_all_bands"]),
57-
"File {} not found !".format(SAVEDMODEL_FILENAME))
59+
ERRMSG)
5860

5961
def test_trainFromTFRecords_os2_unet_all_bands(self):
6062
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(OS2_ALL_BANDS_TFREC_PTH),
6163
"--model", "crga_os2_unet_all_bands"]),
62-
"File {} not found !".format(SAVEDMODEL_FILENAME))
64+
ERRMSG)
6365

6466
def test_trainFromTFRecords_meraner_unet(self):
6567
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(MERANER_ALL_BANDS_TFREC_PTH),
6668
"--model", "meraner_unet"]),
67-
"File {} not found !".format(SAVEDMODEL_FILENAME))
69+
ERRMSG)
6870

6971
def test_trainFromTFRecords_meraner_unet_all_bands(self):
7072
self.assertTrue(is_savedmodel_written(["--training_record", self.get_path(MERANER_ALL_BANDS_TFREC_PTH),
7173
"--model", "meraner_unet_all_bands"]),
72-
"File {} not found !".format(SAVEDMODEL_FILENAME))
74+
ERRMSG)
7375

7476

7577
if __name__ == '__main__':

0 commit comments

Comments
 (0)