Restructured entire code base to make it easier to maintain. Closes #16

This commit is contained in:
Rhet Turnbull
2019-12-21 08:06:25 -08:00
parent cd51782ef2
commit b794e226e3
14 changed files with 1814 additions and 1777 deletions

View File

@@ -50,8 +50,8 @@ def test_db_version():
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
@@ -170,4 +170,3 @@ def test_keyword_not_in_album():
photos3 = [p for p in photos2 if p not in photos1]
assert len(photos3) == 1
assert photos3[0].uuid() == "Pj99JmYjQkeezdY2OFuSaw"

View File

@@ -1,6 +1,6 @@
import pytest
from osxphotos import _UNKNOWN_PERSON
from osxphotos._constants import _UNKNOWN_PERSON
# TODO: put some of this code into a pre-function
@@ -109,7 +109,8 @@ def test_init5():
def bad_library():
return None
osxphotos.get_last_library_path = bad_library
# force get_last_library to return a bad path for testing
osxphotos.photosdb.get_last_library_path = bad_library
with pytest.raises(Exception):
assert osxphotos.PhotosDB()
@@ -126,8 +127,8 @@ def test_db_version():
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
@@ -735,4 +736,3 @@ def test_export_13():
with pytest.raises(Exception) as e:
assert photos[0].export(dest)
assert e.type == type(FileNotFoundError())

View File

@@ -1,6 +1,7 @@
import pytest
from osxphotos import _UNKNOWN_PERSON
from osxphotos._constants import _UNKNOWN_PERSON
from osxphotos.utils import dd_to_dms_str
# TODO: put some of this code into a pre-function
@@ -396,7 +397,7 @@ def test_export_13():
def test_dd_to_dms_str_1():
import osxphotos
lat_str, lon_str = osxphotos.dd_to_dms_str(
lat_str, lon_str = dd_to_dms_str(
34.559331096, 69.206499174
) # Kabul, 34°33'33.59" N 69°12'23.40" E
@@ -407,7 +408,7 @@ def test_dd_to_dms_str_1():
def test_dd_to_dms_str_2():
import osxphotos
lat_str, lon_str = osxphotos.dd_to_dms_str(
lat_str, lon_str = dd_to_dms_str(
-34.601997592, -58.375665164
) # Buenos Aires, 34°36'7.19" S 58°22'32.39" W
@@ -418,7 +419,7 @@ def test_dd_to_dms_str_2():
def test_dd_to_dms_str_3():
import osxphotos
lat_str, lon_str = osxphotos.dd_to_dms_str(
lat_str, lon_str = dd_to_dms_str(
-1.2666656, 36.7999968
) # Nairobi, 1°15'60.00" S 36°47'59.99" E
@@ -429,7 +430,7 @@ def test_dd_to_dms_str_3():
def test_dd_to_dms_str_4():
import osxphotos
lat_str, lon_str = osxphotos.dd_to_dms_str(
lat_str, lon_str = dd_to_dms_str(
38.889248, -77.050636
) # DC: 38° 53' 21.2928" N, 77° 3' 2.2896" W
@@ -469,4 +470,3 @@ def test_exiftool_json_sidecar():
assert item[0][1] == item[1][1]
# assert sorted(json_got[0].items()) == sorted(json_expected[0].items())

View File

@@ -1,6 +1,6 @@
import pytest
from osxphotos import _UNKNOWN_PERSON
from osxphotos._constants import _UNKNOWN_PERSON
# TODO: put some of this code into a pre-function
@@ -44,6 +44,7 @@ UUID_DICT = {
"location": "3Jn73XpSQQCluzRBMWRsMA",
}
def test_export_1():
# test basic export
# get an unedited image and export it using default filename
@@ -409,5 +410,3 @@ def test_exiftool_json_sidecar():
assert sorted(item[0][1]) == sorted(item[1][1])
else:
assert item[0][1] == item[1][1]
# assert sorted(json_got[0].items()) == sorted(json_expected[0].items())

View File

@@ -49,8 +49,8 @@ def test_db_version():
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
@@ -169,4 +169,3 @@ def test_keyword_not_in_album():
photos3 = [p for p in photos2 if p not in photos1]
assert len(photos3) == 1
assert photos3[0].uuid() == "6iAZJP7ZQ5iXxapoJb3ytA"

View File

@@ -49,8 +49,8 @@ def test_db_version():
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
@@ -169,4 +169,3 @@ def test_keyword_not_in_album():
photos3 = [p for p in photos2 if p not in photos1]
assert len(photos3) == 1
assert photos3[0].uuid() == "od0fmC7NQx+ayVr+%i06XA"

View File

@@ -45,15 +45,15 @@ def test_db_version():
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS
assert photosdb.get_db_version() in osxphotos._constants._TESTED_DB_VERSIONS
assert photosdb.get_db_version() == "4025"
def test_os_version():
import osxphotos
(_, major, _) = osxphotos._get_os_version()
assert major in osxphotos._TESTED_OS_VERSIONS
(_, major, _) = osxphotos.utils._get_os_version()
assert major in osxphotos._constants._TESTED_OS_VERSIONS
def test_persons():
@@ -324,4 +324,3 @@ def test_get_library_path():
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
lib_path = photosdb.get_library_path()
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)