def endpoint(): yield Endpoint.from_dict( "test", { "enabled": True, "version": "v10", "model": "api.models.WellHorizontal", "exclude": [], "normalize": False, "options": { "data_type": "Well", "template": "EnerdeqML Well", "criteria": { "hole_direction": "H" }, }, "tasks": { "endpoint_check": { "seconds": 60, "options": { "query_path": "well_by_api.xml", "matrix": { "sequoia": { "api": "42461409160000" } }, }, }, }, }, )
def endpoints(): yield Endpoint.load_from_config(conf)
def test_load_from_config_bad_endpoint(self): class Conf: endpoints = {None: None} Endpoint.load_from_config(Conf())
def test_load_from_empty_config(self): with pytest.raises(AttributeError): assert Endpoint.load_from_config({}) == {}
def test_load_from_config(self, conf): Endpoint.load_from_config(conf)
def test_create_endpoint(self): Endpoint("test", "well_horizontal")
# persist leftovers self.model.core_insert(rows) if __name__ == "__main__": from fracfocus import create_app, db from collector import Endpoint import requests from pathlib import Path import os app = create_app() app.app_context().push() endpoints = Endpoint.load_from_config(conf) endpoint = endpoints["registry"] c = FracFocusCollector(endpoint) paths = [ Path(os.path.join(conf.COLLECTOR_DOWNLOAD_PATH, x)) for x in os.listdir(conf.COLLECTOR_DOWNLOAD_PATH) ] paths row = { "upload_key": "68acaa3e-c788-45fb-8f08-b1dc81ccf0ca", "api14": "42127380120000", "state_no": 42,