Commit ba7410cd authored by Luc Yriarte's avatar Luc Yriarte
Browse files

Merge branch 'slb_code_push-wip' into 'master'

Slb code push

See merge request !4
parents 14654201 b8e1a932
Pipeline #23271 passed with stage
in 37 seconds
default:
image: python:3.7-slim-buster
stages:
- test
- deploy
build:
stage: test
script:
- echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
- apt update
- apt install -y --no-install-recommends git
- echo ---- ---- ---- BUILD IMAGE ---- ---- ----
- pip3 install -r requirements.txt
- pip3 install -r requirements_opengroup.txt
- pip3 install -r requirements_dev.txt
- echo ---- ---- ---- UNIT TESTS ---- ---- ----
- pytest tests --junitxml=report.xml
artifacts:
when: always
reports:
junit: report.xml
# This job only runs on master, and it creates the lib and push it to the feed
deploylib:
stage: deploy
script:
- echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
- apt update
- apt install -y --no-install-recommends git
- echo ---- ---- ---- BUILD IMAGE ---- ---- ----
- pip3 install -r requirements.txt
- pip3 install -r requirements_opengroup.txt
- pip3 install twine
- python3 setup.py sdist bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=${CI_REGISTRY_USER} python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
rules:
- if: $CI_COMMIT_BRANCH == 'master'
# osdu core lib main python
osdu-core-lib-python>=0.4.0, <0.5
# osdu-core-lib-python>=0.4.0, <0.5
# for google provider
aiohttp
cryptography
......
git+https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/lib/wellbore-core/wellbore-core-lib.git@slb-code-push#egg=osdu-core-lib-python
......@@ -19,114 +19,6 @@ TEST_DATA = {
}
# test local and gcp storage
@pytest.fixture(params=['GCloudAioStorage'])
async def storage_client(request):
client_name = request.param
if client_name == 'GCloudAioStorage':
session = aiohttp.ClientSession()
yield GCloudAioStorage(session=session, service_account_file=_TESTING_CFG.credentials)
await session.close()
@pytest.fixture
async def test_tenant():
return Tenant(project_id=TESTING_GCP_DATA_PROJECT_ID, bucket_name='testing-osdu-core', data_partition_id='testing-partition-name')
@pytest.fixture
async def temp_directory() -> str:
tmpdir = tempfile.mkdtemp()
yield tmpdir
# teardown - recursively delete the tmp directory
shutil.rmtree(tmpdir, ignore_errors=True)
@pytest.mark.asyncio
async def test_list_objects(storage_client, test_tenant):
result = await storage_client.list_objects(test_tenant)
for file_name, _ in TEST_DATA['initial_files']:
assert file_name in result
@pytest.mark.asyncio
async def test_download(storage_client, test_tenant):
name, expected_content = TEST_DATA['initial_files'][0]
data = await storage_client.download(test_tenant, name)
result = data.decode('utf-8')
assert result == expected_content
@pytest.mark.asyncio
async def test_upload_check_delete(storage_client, test_tenant):
name = str(uuid.uuid4())
content = str(uuid.uuid4())
# upload
await storage_client.upload(test_tenant, name, content, content_type='text/plain')
# check single object with this name
result = await storage_client.list_objects(test_tenant, prefix=name)
assert result == [name]
# check its content
data = await storage_client.download(test_tenant, name)
assert data.decode('utf-8') == content
# delete it
await storage_client.delete(test_tenant, name)
# check nothing remains
result = await storage_client.list_objects(test_tenant, prefix=name)
assert len(result) == 0
@pytest.mark.asyncio
async def test_upload_file_bin_input(storage_client, temp_directory, test_tenant):
file_c = temp_directory + '\\testing.file'
with open(file_c, 'w') as f:
f.write('expected content 123456789')
content_bin = b'expected content 123456789'
with open(file_c, 'rb') as file_bin_input:
await storage_client.upload(test_tenant, 'file_bin_input', file_bin_input)
assert await storage_client.download(test_tenant, 'file_bin_input') == content_bin
@pytest.mark.asyncio
async def test_upload_file_txt_input(storage_client, temp_directory, test_tenant):
file_c = temp_directory + '\\testing.file'
with open(file_c, 'w') as f:
f.write('expected content 123456789')
content_bin = b'expected content 123456789'
with open(file_c, 'r') as file_txt_input:
await storage_client.upload(test_tenant, 'file_txt_input', file_txt_input)
assert await storage_client.download(test_tenant, 'file_txt_input') == content_bin
@pytest.mark.asyncio
async def test_upload_str_input(storage_client, test_tenant):
content_bin = b'expected content 123456789'
content_str = content_bin.decode('utf-8')
await storage_client.upload(test_tenant, 'str_input', content_str)
assert await storage_client.download(test_tenant, 'str_input') == content_bin
@pytest.mark.asyncio
async def test_upload_bin_input(storage_client, test_tenant):
content_bin = b'expected content 123456789'
await storage_client.upload(test_tenant, 'bin_input', content_bin)
assert await storage_client.download(test_tenant, 'bin_input') == content_bin
@pytest.mark.asyncio
async def test_upload_empty_input(storage_client, test_tenant):
await storage_client.upload(test_tenant, 'empty_input', None)
actual_data = await storage_client.download(test_tenant, 'empty_input')
assert len(actual_data) == 0
@pytest.mark.asyncio
async def test_upload_int_input(storage_client, test_tenant):
with pytest.raises(TypeError):
await storage_client.upload(test_tenant, 'int_input', 123456)
def test_dummy():
assert(True)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment