示例#1
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_exif_invalid():
    assert get_date("Foo.jpg", {
        "Create Date": "Invalid"
    }) == {
        "date": None,
        "subseconds": ""
    }
示例#2
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_exif_subseconds():
    assert get_date("Foo.jpg", {
        "Create Date": "2017-01-01 01:01:01.123"
    }) == {
        "date": datetime(2017, 1, 1, 1, 1, 1),
        "subseconds": "123"
    }
示例#3
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_exif_colon():
    assert get_date("Foo.jpg", {
        "Create Date": "2017:01:01 01:01:01"
    }) == {
        "date": datetime(2017, 1, 1, 1, 1, 1),
        "subseconds": ""
    }
示例#4
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_exif_strip_timezone():
    assert get_date("Foo.jpg", {
        "Create Date": "2017-01-01 01:01:01-02:00"
    }) == {
        "date": datetime(2017, 1, 1, 1, 1, 1),
        "subseconds": ""
    }
示例#5
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_custom_regex_no_match():
    """
    A valid regex with a non-matching filename.
    """
    date_regex = re.compile("(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})[_-]?(?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2})")
    filename = "Foo.jpg"
    assert get_date(filename, {}, date_regex) is None
示例#6
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_custom_regex_invalid():
    """
    A valid regex with a matching filename.
    Return none because there is not enougth information in the filename.
    """
    date_regex = re.compile("(?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2})")
    filename = "19.20.00.jpg"
    assert get_date(filename, {}, date_regex) is None
示例#7
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_custom_regex():
    """
    A valid regex with a matching filename. Returns a datetime.
    """
    date_regex = re.compile("(?P<day>\d{2})\.(?P<month>\d{2})\.(?P<year>\d{4})[_-]?(?P<hour>\d{2})\.(?P<minute>\d{2})\.(?P<second>\d{2})")
    filename = "IMG_27.01.2015-19.20.00.jpg"
    assert get_date(filename, {}, date_regex) == {
        "date": datetime(2015, 1, 27, 19, 20, 00),
        "subseconds": ""
    }
示例#8
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_none_on_no_error():
    assert get_date("IMG_2017_01.jpg", {}) is None
示例#9
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_none_on_no_info():
    assert get_date("Foo.jpg", {}) is None
示例#10
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_filename_invalid():
    assert get_date("IMG_20170101_999999.jpg", {}) is None
示例#11
0
文件: tests.py 项目: bshomar/phockup
def test_get_date_filename():
    assert get_date("IMG_20170101_010101.jpg", {}) == {
        "date": datetime(2017, 1, 1, 1, 1, 1),
        "subseconds": ""
    }