builder: remove from_path interface
The static method from_path is only used from one place and is simply joining a path; we can inline this and remove it for clarity. Change-Id: Iade6e024516bf9ce212491d6461e00affb5971a0
This commit is contained in:
parent
da8780526a
commit
e0a16431d3
|
@ -69,18 +69,12 @@ class DibImageFile(object):
|
|||
if self.extension:
|
||||
self.extension = self.extension.lstrip('.')
|
||||
|
||||
@staticmethod
|
||||
def from_path(path):
|
||||
if isinstance(path, str):
|
||||
path = Path(path)
|
||||
return DibImageFile(path.stem, path.suffix)
|
||||
|
||||
@staticmethod
|
||||
def from_image_id(images_dir, image_id):
|
||||
images = []
|
||||
for image_file in Path(images_dir).iterdir():
|
||||
if image_file.is_file():
|
||||
image = DibImageFile.from_path(image_file)
|
||||
image = DibImageFile(image_file.stem, image_file.suffix)
|
||||
if image.image_id == image_id:
|
||||
images.append(image)
|
||||
return images
|
||||
|
|
|
@ -19,8 +19,6 @@ import fixtures
|
|||
import mock
|
||||
import time
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from nodepool import builder, exceptions, tests
|
||||
from nodepool.driver.fake import provider as fakeprovider
|
||||
from nodepool import zk
|
||||
|
@ -29,18 +27,6 @@ from nodepool.nodeutils import iterate_timeout
|
|||
|
||||
|
||||
class TestNodepoolBuilderDibImage(tests.BaseTestCase):
|
||||
def test_from_path(self):
|
||||
image = builder.DibImageFile.from_path(
|
||||
'/foo/bar/myid1234.qcow2')
|
||||
self.assertEqual(image.image_id, 'myid1234')
|
||||
self.assertEqual(image.extension, 'qcow2')
|
||||
|
||||
def test_from_path_with_Path(self):
|
||||
image = builder.DibImageFile.from_path(
|
||||
Path('/foo/bar/myid1234.qcow2'))
|
||||
self.assertEqual(image.image_id, 'myid1234')
|
||||
self.assertEqual(image.extension, 'qcow2')
|
||||
|
||||
def test_from_image_id(self):
|
||||
tempdir = fixtures.TempDir()
|
||||
self.useFixture(tempdir)
|
||||
|
|
Loading…
Reference in New Issue