add files for public distribution
based on internal repository 0a462b6 2017-11-22 14:41:39 +0100
This commit is contained in:
104
tests/test_files.py
Normal file
104
tests/test_files.py
Normal file
@ -0,0 +1,104 @@
|
||||
"""
|
||||
@package tests.test_files
|
||||
unit tests for pmsco.files
|
||||
|
||||
the purpose of these tests is to help debugging the code.
|
||||
|
||||
to run the tests, change to the directory which contains the tests directory, and execute =nosetests=.
|
||||
|
||||
@pre nose must be installed (python-nose package on Debian).
|
||||
|
||||
@author Matthias Muntwiler, matthias.muntwiler@psi.ch
|
||||
|
||||
@copyright (c) 2015 by Paul Scherrer Institut @n
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); @n
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import mock
|
||||
import pmsco.files as files
|
||||
|
||||
|
||||
class TestFileTracker(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# before each test method
|
||||
self.files = files.FileTracker()
|
||||
self.files.keep_rfac = 1
|
||||
self.files._os_delete_file = mock.Mock(return_value=None)
|
||||
|
||||
self.files.add_file("model 1 file 1 cluster K", 1, 'cluster')
|
||||
self.files.add_file("model 1 file 2 output D", 1, 'output')
|
||||
self.files.add_file("model 2 file 1 cluster K", 2, 'cluster')
|
||||
self.files.add_file("model 2 file 2 output D", 2, 'output')
|
||||
self.files.add_file("model 3 file 1 cluster K", 3, 'cluster')
|
||||
self.files.add_file("model 3 file 2 output D", 3, 'output')
|
||||
self.files.add_file("model 4 file 1 cluster K", 4, 'cluster')
|
||||
self.files.add_file("model 4 file 2 output D", 4, 'output')
|
||||
self.files.add_file("model 5 file 1 cluster K", 5, 'cluster')
|
||||
self.files.add_file("model 5 file 2 output D", 5, 'output')
|
||||
|
||||
self.files.update_model_rfac(2, 0.0)
|
||||
self.files.update_model_rfac(3, 0.1)
|
||||
self.files.update_model_rfac(4, 0.3)
|
||||
self.files.update_model_rfac(1, 0.5)
|
||||
self.files.update_model_rfac(5, 0.6)
|
||||
|
||||
self.files.set_model_complete(1, True)
|
||||
self.files.set_model_complete(2, True)
|
||||
self.files.set_model_complete(3, False)
|
||||
self.files.set_model_complete(5, True)
|
||||
|
||||
def tearDown(self):
|
||||
# after each test method
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
# before any methods in this class
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def teardown_class(cls):
|
||||
# teardown_class() after any methods in this class
|
||||
pass
|
||||
|
||||
def test_add_file(self):
|
||||
pass
|
||||
|
||||
def test_rename_file(self):
|
||||
pass
|
||||
|
||||
def test_remove_file(self):
|
||||
pass
|
||||
|
||||
def test_update_model_rfac(self):
|
||||
pass
|
||||
|
||||
def test_delete_files(self):
|
||||
self.files.keep_rfac = 10
|
||||
self.files.delete_files()
|
||||
self.files._os_delete_file.assert_any_call("model 1 file 2 output D")
|
||||
self.files._os_delete_file.assert_any_call("model 2 file 2 output D")
|
||||
self.files._os_delete_file.assert_any_call("model 5 file 2 output D")
|
||||
self.assertEqual(len(self.files._id_by_path), 5+2)
|
||||
self.assertEqual(len(self.files._path_by_id), 5+2)
|
||||
self.assertEqual(len(self.files._model_by_id), 5+2)
|
||||
self.assertEqual(len(self.files._category_by_id), 5+2)
|
||||
|
||||
def test_delete_file(self):
|
||||
pass
|
||||
|
||||
def test_delete_bad_rfac(self):
|
||||
self.files.delete_bad_rfac(keep=2, force_delete=True)
|
||||
self.files._os_delete_file.assert_any_call("model 1 file 1 cluster K")
|
||||
self.files._os_delete_file.assert_any_call("model 5 file 1 cluster K")
|
||||
self.assertEqual(len(self.files._id_by_path), 6)
|
||||
self.assertEqual(len(self.files._path_by_id), 6)
|
||||
self.assertEqual(len(self.files._model_by_id), 6)
|
||||
self.assertEqual(len(self.files._category_by_id), 6)
|
||||
|
||||
def test_delete_category(self):
|
||||
pass
|
Reference in New Issue
Block a user