fix date string lenght
This commit is contained in:
@@ -3,8 +3,14 @@ class ExifData:
|
||||
def __init__(self, data:dict) -> None:
|
||||
self.path:str = str(data['image_path'])
|
||||
self.name:str = str(data['image_name'])
|
||||
self.day:int = int(data['day'])
|
||||
self.month:int = int(data['month'])
|
||||
self.year:int = int(data['year'])
|
||||
self.day:str = str(data['day'])
|
||||
self.month:str = str(data['month'])
|
||||
self.year:str = str(data['year'])
|
||||
self.time:str = str(data['time'])
|
||||
self.make:str = str(data['make'])
|
||||
|
||||
# fix date strings so they are always 2 chars long
|
||||
if len(self.day) < 2: self.day = "0" + self.day
|
||||
if len(self.month) < 2: self.month = "0" + self.month
|
||||
if len(self.year) < 2: self.year = "0" + self.year
|
||||
|
||||
@@ -16,6 +16,8 @@ class TestExifData(unittest.TestCase):
|
||||
exif_data = ExifData(exif_data_dict)
|
||||
|
||||
assert exif_data.make == "CAMERA"
|
||||
assert exif_data.year == 2222
|
||||
assert exif_data.year == "2222"
|
||||
assert exif_data.time == "10:10:10"
|
||||
|
||||
assert exif_data.day == "02"
|
||||
assert exif_data.month == "02"
|
||||
assert exif_data.year == "2222"
|
||||
|
||||
@@ -16,14 +16,14 @@ class TestSamsung(unittest.TestCase):
|
||||
assert image.make == "samsung"
|
||||
|
||||
image = next((image for image in meta_data if image.name == "samsung_a54_001.jpg"), None)
|
||||
assert image.day == 2
|
||||
assert image.month == 12
|
||||
assert image.year == 2023
|
||||
assert image.day == "02"
|
||||
assert image.month == "12"
|
||||
assert image.year == "2023"
|
||||
|
||||
image = next((image for image in meta_data if image.name == "samsung_a54_003.jpg"), None)
|
||||
assert image.day == 8
|
||||
assert image.month == 12
|
||||
assert image.year == 2023
|
||||
assert image.day == "08"
|
||||
assert image.month == "12"
|
||||
assert image.year == "2023"
|
||||
|
||||
@unittest.skip("")
|
||||
def test_a52s(self):
|
||||
|
||||
Reference in New Issue
Block a user