Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/sentinel-hub/eo-learn in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
AleksMat committed Apr 23, 2021
2 parents 83bcd16 + 2a0d2b3 commit e6abfa6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ before_install:

install:
- pip install -r requirements-dev.txt --upgrade
- FORCE_CYTHON=1 pip install cartopy # temporal fix for cartopy==0.19.0
- if [ $TRAVIS_PYTHON_VERSION == '3.6' ]; then
python install_all.py -e;
else
Expand Down
23 changes: 4 additions & 19 deletions io/eolearn/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import os

import boto3
import botocore.exceptions

from botocore.exceptions import ClientError, NoCredentialsError
import pytest
from moto import mock_s3

from sentinelhub import SHConfig

Expand Down Expand Up @@ -45,10 +43,11 @@ def s3_gpkg_example_file_fixture(config):

try:
client.head_bucket(Bucket='eolearn-io')
return 's3://eolearn-io/import-gpkg-test.gpkg'
except botocore.exceptions.ClientError:
except (ClientError, NoCredentialsError):
return pytest.skip(msg='No access to the bucket.')

return 's3://eolearn-io/import-gpkg-test.gpkg'


@pytest.fixture(name='geodb_client')
def geodb_client_fixture():
Expand All @@ -66,17 +65,3 @@ def geodb_client_fixture():
client_id=client_id,
client_secret=client_secret
)


@mock_s3
def _create_s3_bucket(bucket_name):
s3resource = boto3.resource('s3', region_name='eu-central-1')
bucket = s3resource.Bucket(bucket_name)

if bucket.creation_date: # If bucket already exists
for key in bucket.objects.all():
key.delete()
bucket.delete()

s3resource.create_bucket(Bucket=bucket_name,
CreateBucketConfiguration={'LocationConstraint': 'eu-central-1'})
4 changes: 0 additions & 4 deletions io/eolearn/tests/test_geometry_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
This source code is licensed under the MIT license found in the LICENSE
file in the root directory of this source tree.
"""
import logging

import pytest

from eolearn.core import FeatureType
from eolearn.io import GeoDBVectorImportTask, GeopediaVectorImportTask, VectorImportTask
from sentinelhub import BBox, CRS

logging.basicConfig(level=logging.DEBUG)


@pytest.mark.parametrize(
argnames='reproject, clip, n_features, bbox, crs',
Expand Down
16 changes: 15 additions & 1 deletion io/eolearn/tests/test_local_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,33 @@
import unittest
from unittest.mock import patch

import boto3
import numpy as np
from fs.errors import ResourceNotFound
from moto import mock_s3

from eolearn.core import EOPatch, FeatureType
from eolearn.io import ExportToTiff, ImportFromTiff
from eolearn.tests.conftest import _create_s3_bucket
from sentinelhub import read_data
from sentinelhub.time_utils import serialize_time

logging.basicConfig(level=logging.DEBUG)


@mock_s3
def _create_s3_bucket(bucket_name):
s3resource = boto3.resource('s3', region_name='eu-central-1')
bucket = s3resource.Bucket(bucket_name)

if bucket.creation_date: # If bucket already exists
for key in bucket.objects.all():
key.delete()
bucket.delete()

s3resource.create_bucket(Bucket=bucket_name,
CreateBucketConfiguration={'LocationConstraint': 'eu-central-1'})


class TestExportAndImportTiff(unittest.TestCase):
""" Testing if export and then import of the data preserves the data
"""
Expand Down

0 comments on commit e6abfa6

Please sign in to comment.