Commit 72539dd1 authored by Felix Delattre's avatar Felix Delattre
Browse files

Added tests for file_handler

parent 458cdc50
Pipeline #29745 passed with stage
in 1 minute and 27 seconds
#!/usr/bin/env python3
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import pytest
from spearhead.configure import Configuration
@pytest.fixture()
def config():
yield Configuration("./tests/config.yml")
#!/usr/bin/env python3
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import logging
import os
import pytest
from spearhead.file_handler import FileHandler
logger = logging.getLogger()
@pytest.fixture
def file_handler(config):
return FileHandler(config)
def test_file_handler_init(config):
file_handler = FileHandler(config)
assert file_handler
@pytest.mark.asyncio
async def test_read_state_file(file_handler):
state_number = await file_handler.read_state_file()
assert state_number == 4749548
@pytest.mark.asyncio
async def test_update_state_file(file_handler):
await file_handler.update_state_file("4749545")
state_number = await file_handler.read_state_file()
assert state_number == 4749545
await file_handler.update_state_file("4749548")
state_number = await file_handler.read_state_file()
assert state_number == 4749548
@pytest.mark.asyncio
async def test_write_diff_report(file_handler):
await file_handler.write_diff_report("4749545", ["337202175", "17837838", "-387388722"])
os.remove(file_handler.config.filepath + "augmented-diff-4749545.txt")
Supports Markdown
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