예제 #1
0
class ResourcesTest(unittest.TestCase):
    def setUp(self):
        self.kwargs = {
            '1': 'one',
            'dummy': DummyObject(1, 2)
        }
        self.resources = Resources(**self.kwargs)
        self.output_dir = tempfile.mkdtemp()

    def test_save_with_keys(self):
        keys = list(self.kwargs.keys())
        self.resources.save(keys=keys, output_dir=self.output_dir)

        new_resources = Resources()
        new_resources.load(keys=keys, path=self.output_dir)

        self.assertEqual(new_resources._resources, self.resources._resources)

    def test_save_without_keys(self):
        self.resources.save(output_dir=self.output_dir)

        new_resources = Resources()
        keys = list(self.kwargs.keys())
        new_resources.load(keys=keys, path=self.output_dir)

        self.assertEqual(new_resources._resources, self.resources._resources)

    def tearDown(self) -> None:
        shutil.rmtree(self.output_dir)
예제 #2
0
class ResourcesTest(unittest.TestCase):
    def setUp(self):
        self.kwargs = {
            '1': 'one',
            'dummy': DummyObject(1, 2)
        }
        self.resources = Resources(**self.kwargs)
        self.output_dir = './'

    def test_save_with_keys(self):
        keys = list(self.kwargs.keys())
        self.resources.save(keys=keys, output_dir=self.output_dir)

        new_resources = Resources()
        new_resources.load(keys=keys, path=self.output_dir)

        self.assertEqual(new_resources.resources, self.resources.resources)

    def test_save_without_keys(self):
        self.resources.save(output_dir=self.output_dir)

        new_resources = Resources()
        keys = list(self.kwargs.keys())
        new_resources.load(keys=keys, path=self.output_dir)

        self.assertEqual(new_resources.resources, self.resources.resources)