Output message if no data files are found for date (#21)
This commit is contained in:
Родитель
3476d8a0e0
Коммит
0f967c4b81
|
@ -3,6 +3,7 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Set
|
||||
|
@ -81,6 +82,13 @@ class LeanplumExporter(object):
|
|||
**continuation_token,
|
||||
**max_keys,
|
||||
)
|
||||
|
||||
try:
|
||||
assert object_list["KeyCount"] > 0
|
||||
except AssertionError:
|
||||
print(f"Error: No data files found for date {date}", file=sys.stderr)
|
||||
raise
|
||||
|
||||
data_file_keys.extend([content["Key"] for content in object_list["Contents"]
|
||||
if filename_re.fullmatch(content["Key"])])
|
||||
|
||||
|
|
|
@ -298,6 +298,21 @@ class TestStreamingExporter(object):
|
|||
}
|
||||
assert expected == set(retrieved_keys)
|
||||
|
||||
@mock_s3
|
||||
def test_get_files_no_files(self):
|
||||
# can't use fixture because it's instantiated before moto3e
|
||||
exporter = LeanplumExporter("projectId")
|
||||
|
||||
bucket_name = "bucket"
|
||||
date = "20200601"
|
||||
prefix = "firefox"
|
||||
|
||||
s3_client = boto3.client("s3")
|
||||
s3_client.create_bucket(Bucket=bucket_name)
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
exporter.get_files(date, bucket_name, prefix)
|
||||
|
||||
@mock_s3
|
||||
def test_get_files_pagination(self):
|
||||
# can't use fixture because it's instantiated before moto
|
||||
|
|
Загрузка…
Ссылка в новой задаче