rmm commited on
Commit
fc838b0
·
1 Parent(s): ec78796

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

Browse files
tests/data/cakes.jpg ADDED

Git LFS Details

  • SHA256: 7a95ce26c01605a3b108c44969dfc794228d15b521e6ff267cc9f2da81cf0587
  • Pointer size: 131 Bytes
  • Size of remote file: 111 kB
tests/data/cakes_no_exif_datetime.jpg ADDED

Git LFS Details

  • SHA256: e83b2d990031f5d1c5e7cbb85952827486c7f7c4a822a80c3f8402ba04ae06de
  • Pointer size: 130 Bytes
  • Size of remote file: 42.1 kB
tests/data/cakes_no_exif_gps.jpg ADDED

Git LFS Details

  • SHA256: f57d728b65fda52cb82aafaf1496f1897c483b2cf38c2e7a2804d6b634d9744f
  • Pointer size: 130 Bytes
  • Size of remote file: 42.1 kB
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
+