Esempio n. 1
0
 def test_results_exists(self):
     handler = ERDFileHandler([], self.elem_4he)
     self.assertFalse(handler.results_exist())
     handler.add_active_file(self.valid_erd_files[0])
     self.assertTrue(handler.results_exist())
     handler.update()
     self.assertTrue(handler.results_exist())
     handler.clear()
     self.assertFalse(handler.results_exist())
Esempio n. 2
0
    def test_max_seed(self):
        handler = ERDFileHandler([], self.elem_4he)

        self.assertEqual(None, handler.get_max_seed())

        handler.add_active_file(self.valid_erd_files[0])
        self.assertEqual(101, handler.get_max_seed())

        handler.add_active_file(self.valid_erd_files[1])
        self.assertEqual(102, handler.get_max_seed())
Esempio n. 3
0
    def test_len(self):
        """Tests for handler's __len__ function"""
        handler = ERDFileHandler([], self.elem_4he)
        self.assertEqual(0, len(handler))
        for f in self.valid_erd_files:
            handler.add_active_file(f)

        self.assertEqual(len(self.valid_erd_files), len(handler))
        handler.update()
        handler.add_active_file("4He-Default.103.erd")
        self.assertEqual(len(self.valid_erd_files) + 1, len(handler))
Esempio n. 4
0
    def test_erdfilehandler_add(self):
        handler = ERDFileHandler(self.valid_erd_files, self.elem_4he)

        # already existing files, or files belonging to another
        # recoil element cannot be added
        self.assertRaises(
            ValueError,
            lambda: handler.add_active_file(self.valid_erd_files[0]))
        self.assertRaises(ValueError,
                          lambda: handler.add_active_file("4He-New.101.erd"))

        # new file can be added, but only once
        new_file = Path("4He-Default.103.erd")
        handler.add_active_file(new_file)

        self.assertRaises(ValueError,
                          lambda: handler.add_active_file(new_file))

        # new file appears as the first element when iterating
        # over the handler and its status is active
        exp = [(new_file, 103, True)] + [(f, s, False)
                                         for f, s, in self.expected_values]

        self.assertEqual(exp, [f for f in handler])