rmm commited on
Commit
d87ef07
·
1 Parent(s): 6af1379

test: implemented test on datetime extraction, and included test data

Browse files
tests/data/cakes.jpg ADDED
tests/data/cakes_no_exif_datetime.jpg ADDED
tests/data/cakes_no_exif_gps.jpg ADDED
tests/test_input_handling.py CHANGED
@@ -1,7 +1,7 @@
1
  import pytest
 
2
 
3
- from input_handling import is_valid_email
4
- from input_handling import is_valid_number
5
 
6
  # generate tests for is_valid_email
7
  # - test with valid email
@@ -105,4 +105,32 @@ def test_is_valid_number_invalid():
105
  assert not is_valid_number("123.456.789")
106
  assert not is_valid_number("123,456")
107
  assert not is_valid_number("123-456")
108
- assert not is_valid_number("123+456")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import pytest
2
+ from pathlib import Path
3
 
4
+ from input_handling import is_valid_email, is_valid_number, get_image_datetime
 
5
 
6
  # generate tests for is_valid_email
7
  # - test with valid email
 
105
  assert not is_valid_number("123.456.789")
106
  assert not is_valid_number("123,456")
107
  assert not is_valid_number("123-456")
108
+ assert not is_valid_number("123+456")
109
+
110
+
111
+
112
+ # tests for get_image_datetime
113
+ # - testing with a valid image with complete, valid metadata
114
+ # - testing with a valid image with incomplete metadata (missing datetime info -- that's a legitimate case we should handle)
115
+ # - testing with a valid image with incomplete metadata (missing GPS info -- should not affect the datetime extraction)
116
+ # - testing with a valid image with no metadata
117
+ # - timezones too
118
+
119
+
120
+ test_data_pth = Path('tests/data/')
121
+ def test_get_image_datetime():
122
+
123
+ # this image has lat, lon, and datetime
124
+ f1 = test_data_pth / 'cakes.jpg'
125
+ assert get_image_datetime(f1) == "2024:10:24 15:59:45"
126
+ #"+02:00"
127
+ # hmm, the full datetime requires timezone, which is called OffsetTimeOriginal
128
+
129
+ # missing GPS loc: this should not interfere with the datetime
130
+ f2 = test_data_pth / 'cakes_no_exif_gps.jpg'
131
+ assert get_image_datetime(f2) == "2024:10:24 15:59:45"
132
+
133
+ # missng datetime -> expect None
134
+ f3 = test_data_pth / 'cakes_no_exif_datetime.jpg'
135
+ assert get_image_datetime(f3) == None
136
+