From 7b41e2ad0a95b8f2bbf7db560d20e8b7c540f0af Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Fri, 12 Feb 2021 16:56:28 -0300 Subject: [PATCH 1/9] fixing create mapping and style ref #35 --- examples/ex-01.py | 6 +++--- lccs/cli.py | 29 ++++++++++++------------- lccs/lccs.py | 54 +++++++++++++++++++++++++++++------------------ 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/examples/ex-01.py b/examples/ex-01.py index 7cf0e0d..c5a827e 100644 --- a/examples/ex-01.py +++ b/examples/ex-01.py @@ -12,11 +12,11 @@ print(lccs.__version__) -url = os.environ.get('LCCS_SERVER_URL', 'https://brazildatacube.dpi.inpe.br/dev/lccs/') +url = os.environ.get('LCCS_SERVER_URL', 'https://brazildatacube.dpi.inpe.br/lccs/') -service = lccs.LCCS('http://127.0.0.1:5000/') +service = lccs.LCCS(url) -print("Return all classificaton systems available in service") +print("Return all classification systems available in service") print(service.classification_systems) # The examples presented in this code vary depending on the database used. Check the parameters informed. diff --git a/lccs/cli.py b/lccs/cli.py index 8b1961d..9276a8a 100644 --- a/lccs/cli.py +++ b/lccs/cli.py @@ -174,46 +174,45 @@ def mappings(config: Config, system_name_source, system_name_target, verbose): @cli.command() -@click.option('--system_id_source', type=click.STRING, required=True, help='The classification system source.') -@click.option('--system_id_target', type=click.STRING, required=True, default=None, +@click.option('--system_name_source', type=click.STRING, required=True, help='The classification system source.') +@click.option('--system_name_target', type=click.STRING, required=True, default=None, help='The classification system target.') @click.option('--mappings_path', type=click.Path(exists=True), required=True, help='File path with the mapping') @click.option('-v', '--verbose', is_flag=True, default=False) @pass_config -def add_mapping(config: Config, system_id_source, system_id_target, mappings_path, verbose): +def add_mapping(config: Config, system_name_source, system_name_target, mappings_path, verbose): """Add a mapping between classification systems.""" if verbose: click.secho(f'Server: {config.url}', bold=True, fg='black') click.secho('\tAdding new mapping ... ', bold=False, fg='black') - retval = config.service.add_mapping(system_id_source=system_id_source, system_id_target=system_id_target, - mappings_path=mappings_path) + config.service.add_mapping(system_name_source=system_name_source, + system_name_target=system_name_target, + mappings=mappings_path) - click.secho(f'Added Mapping between {retval["source_classification_system"]} and ' - f'{retval["target_classification_system"]}', bold=True, fg='green') + click.secho(f'Added Mapping between {system_name_source} and ' + f'{system_name_target}', bold=True, fg='green') if verbose: click.secho('\tFinished!', bold=False, fg='black') @cli.command() -@click.option('--system_id', type=click.STRING, required=True, help='The classification system source.') -@click.option('--style_format', type=click.STRING, required=True, default=None, +@click.option('--system_name', type=click.STRING, required=True, help='The classification system source.') +@click.option('--style_format_name', type=click.STRING, required=True, default=None, help='The style file format.') @click.option('--style_path', type=click.Path(exists=True), required=True, help='The style file path.') -@click.option('--extension', type=click.STRING, required=True, help='The style extension type.') @click.option('-v', '--verbose', is_flag=True, default=False) @pass_config -def add_style(config: Config, system_id, style_format, style_path, extension, verbose): +def add_style(config: Config, system_name, style_format_name, style_path, verbose): """Add a classification system style.""" if verbose: click.secho(f'Server: {config.url}', bold=True, fg='black') click.secho('\tAdding new classification system style ... ', bold=False, fg='black') - retval = config.service.add_style(system_id=system_id, style_format=style_format, style_path=style_path, - extension=extension) - - click.secho(f'{retval}', bold=True, fg='green') + config.service.add_style(system_name=system_name, + format_name=style_format_name, + style_path=style_path) if verbose: click.secho('\tFinished!', bold=False, fg='black') diff --git a/lccs/lccs.py b/lccs/lccs.py index 1399e75..2f27632 100644 --- a/lccs/lccs.py +++ b/lccs/lccs.py @@ -10,6 +10,7 @@ from .mappings import MappingGroup, Mapping from .style_formats import StyleFormats from .utils import Utils +import json class LCCS: @@ -216,45 +217,56 @@ def add_classification_system(self, name: str, authority_name: str, description: return retval - def add_style(self, system_id: str, style_format: str, style_path: str, extension: str): + def add_style(self, system_name: str, format_name: str, style_path: str): """Add a new style format system.""" - url = f'{self._url}/classification_system/{system_id}/styles{self._access_token}' + _format_id = self._get_format_identifier(format_name) + + _system_source_id = self._id(system_name) + + url = f'{self._url}/classification_systems/{_system_source_id.id}/styles{self._access_token}' try: - style = {'style': (f'style_{system_id}_{style_format}.{extension}', open(style_path, 'rb'), - 'application/octet-stream')} + style = {'style': open(style_path, 'rb')} except RuntimeError: raise ValueError(f'Could not open style file {style_path}.') data = dict() - data["style_format"] = style_format - + data["style_format_id"] = _format_id['id'] + try: retval = Utils._post(url, data=data, files=style) except RuntimeError: raise ValueError('Could not insert style!') - return retval['message'] + return retval - def add_mapping(self, system_id_source: str, system_id_target: str, mappings_path: str): + def add_mapping(self, system_name_source: str, system_name_target: str, mappings): """Add new classification system mapping.""" - url = f'{self._url}/mappings/{system_id_source}/{system_id_target}{self._access_token}' - - try: - mapping = {'mappings': ('mappings.json', open(mappings_path, 'rb'), 'application/json')} - except RuntimeError: - raise ValueError(f'Could not open mapping file {mappings_path}. It is a json file ?') + def get_id_by_name(name, classes): + """Get id of class.""" + return list(filter(lambda x: x.name == name, classes))[0]['id'] + + _system_source_id = self._id(system_name_source) + _system_target_id = self._id(system_name_target) + url = f'{self._url}/mappings/{_system_source_id.id}/{_system_target_id.id}{self._access_token}' + + if type(mappings) == str: + with open(mappings) as file: + mappings = json.load(file) + + for i in mappings: + if type(i['source_class_id']) != str: + break + i['source_class_id'] = get_id_by_name(i['source_class_id'], _system_source_id.classes) + i['target_class_id'] = get_id_by_name(i['target_class_id'], _system_target_id.classes) + try: - retval = Utils._post(url, json=mapping) + retval = Utils._post(url, json=mappings) except RuntimeError: raise ValueError('Could not insert mappings!') - - retval['source_classification_system'] = system_id_source - - retval['target_classification_system'] = system_id_target - - return MappingGroup(retval, self._validate) + + return retval @property def url(self): From 006f23bbc9f0990f79a021101e6cf159aea58322 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Fri, 12 Feb 2021 18:15:08 -0300 Subject: [PATCH 2/9] add mapping templates --- examples/{mappings.py => available_mappings.py} | 0 lccs/lccs.py | 15 +++++++-------- lccs/mappings.py | 14 ++++++++++++++ lccs/templates/classification_system.html | 2 +- lccs/templates/mapping.html | 16 ++++------------ 5 files changed, 26 insertions(+), 21 deletions(-) rename examples/{mappings.py => available_mappings.py} (100%) diff --git a/examples/mappings.py b/examples/available_mappings.py similarity index 100% rename from examples/mappings.py rename to examples/available_mappings.py diff --git a/lccs/lccs.py b/lccs/lccs.py index 2f27632..48a5a58 100644 --- a/lccs/lccs.py +++ b/lccs/lccs.py @@ -122,7 +122,7 @@ def available_mappings(self, system_source_name: str) -> list: return result - def mappings(self, system_name_source: str, system_name_target: str) -> list: + def mappings(self, system_name_source: str, system_name_target: str) -> MappingGroup: """Return the given classification_system. :param system_name_source: A classification system name. @@ -135,18 +135,17 @@ def mappings(self, system_name_source: str, system_name_target: str) -> list: """ _system_source_id = self._id(system_name_source) _system_target_id = self._id(system_name_target) - - result = list() - + try: data = Utils._get(f'{self._url}/mappings/{_system_source_id.id}/{_system_target_id.id}') except Exception: raise KeyError('Could not retrieve mappings for {} and {}'.format(system_name_source, system_name_target)) - [result.append(Mapping(mapping, self._validate)) for mapping in data] - - return result - + data_result = dict() + data_result['mappings'] = data + + return MappingGroup(data_result, self._validate) + def style_formats(self, system_source_name) -> list: """Fetch styles of the a giving classification system. diff --git a/lccs/mappings.py b/lccs/mappings.py index 090a704..b77a78e 100644 --- a/lccs/mappings.py +++ b/lccs/mappings.py @@ -36,6 +36,20 @@ def _repr_html_(self): """HTML repr.""" return Utils.render_html('mapping.html', mappings=self) + def __repr__(self): + """Return the string representation of a mapping group object.""" + text = '' + for i in self.mapping: + text += f'\n\t{i}' + return text + + def __str__(self): + """Return the string representation of a mapping group object.""" + text = '' + for i in self.mapping: + text += f'\n\t{i}' + return text + class Mapping(dict): """Mapping.""" diff --git a/lccs/templates/classification_system.html b/lccs/templates/classification_system.html index 36470a9..6b6f7de 100644 --- a/lccs/templates/classification_system.html +++ b/lccs/templates/classification_system.html @@ -26,7 +26,7 @@ id class_parent_name - {% for class in classification_system.classes()%} + {% for class in classification_system.classes%} {{class['name']}} {{class['description']}} diff --git a/lccs/templates/mapping.html b/lccs/templates/mapping.html index 43b74cc..9d4f29e 100644 --- a/lccs/templates/mapping.html +++ b/lccs/templates/mapping.html @@ -1,28 +1,20 @@ Classes Mappings -
- Classification System Source: {{mappings.source_classification_system}} - Classification System Target: {{mappings.target_classification_system}} -
- - {% for mp in mappings.mapping%} - - - - - - + + + + {% endfor %}
source_classsource_id target_classtarget_id description degree_of_similarity
{{mp['source_class']}}{{mp['source_id']}}{{mp['target_class']}}{{mp['target_id']}}{{mp['description']}}{{mp['degree_of_similarity']}}{{mp.source_class.name}}{{mp.source_class.name}}{{mp.description}}{{mp.degree_of_similarity}}
From ca23ac0d6717d5951ed988724e551ba8666bc6d2 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Fri, 12 Feb 2021 18:16:10 -0300 Subject: [PATCH 3/9] fixing examples --- docs/sphinx/examples.rst | 2 +- examples/available_mappings.py | 4 ++-- examples/class_metadata.py | 4 ++-- examples/classes.py | 7 ++++--- examples/classification_system_metadata.py | 4 ++-- examples/classification_systems.py | 2 +- examples/ex-01.py | 5 ++--- examples/mapping.py | 9 +++------ examples/style.py | 4 ++-- examples/styles.py | 4 ++-- lccs/templates/mapping-item.html | 5 +++++ 11 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 lccs/templates/mapping-item.html diff --git a/docs/sphinx/examples.rst b/docs/sphinx/examples.rst index 3728cd1..30aa150 100644 --- a/docs/sphinx/examples.rst +++ b/docs/sphinx/examples.rst @@ -53,7 +53,7 @@ Mappings This example shows the list of available mappings in service of a specific classification system: -.. literalinclude:: ../../examples/mappings.py +.. literalinclude:: ../../examples/available_mappings.py :language: python :lines: 10- diff --git a/examples/available_mappings.py b/examples/available_mappings.py index 08f0cce..7fa4b38 100644 --- a/examples/available_mappings.py +++ b/examples/available_mappings.py @@ -10,9 +10,9 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("'https://brazildatacube.dpi.inpe.br/lccs/") # Return the list of available clasification system for mapping -available_mappings = service.available_mappings(system_id_source='TerraClass_AMZ') +available_mappings = service.available_mappings('PRODES-1.0') print(available_mappings) diff --git a/examples/class_metadata.py b/examples/class_metadata.py index 8ea7fb5..65f8c2c 100644 --- a/examples/class_metadata.py +++ b/examples/class_metadata.py @@ -14,10 +14,10 @@ # Get a specific classification system # Make sure the classification system is available in service -classification_system = service.classification_system(system_id='TerraClass_AMZ') +classification_system = service.classification_system('PRODES-1.0') # Return the metadata of a specific class -class_metadata = classification_system.classes(class_id='Desflorestamento') +class_metadata = classification_system.get_class('Desflorestamento') print(class_metadata) # You can access specific attributes diff --git a/examples/classes.py b/examples/classes.py index b56a294..463635b 100644 --- a/examples/classes.py +++ b/examples/classes.py @@ -10,12 +10,13 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Get a specific classification system # Make sure the classification system is available in service -classification_system = service.classification_system(system_id='TerraClass_AMZ') +classification_system = service.classification_system('PRODES-1.0') # Returns all classes belonging to a specific classification system. -classes = classification_system.classes() +classes = classification_system.classes print(classes) + diff --git a/examples/classification_system_metadata.py b/examples/classification_system_metadata.py index 5541fec..d5b295f 100644 --- a/examples/classification_system_metadata.py +++ b/examples/classification_system_metadata.py @@ -10,11 +10,11 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("http://brazildatacube.dpi.inpe.br/lccs/") # Return the metadata of a specific classification system # Make sure the classification system is available in service -classification_system = service.classification_system(system_id='TerraClass_AMZ') +classification_system = service.classification_system('PRODES-1.0') print(classification_system) # You can access specific attributes diff --git a/examples/classification_systems.py b/examples/classification_systems.py index 051d20c..c928bc4 100644 --- a/examples/classification_systems.py +++ b/examples/classification_systems.py @@ -10,7 +10,7 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("http://brazildatacube.dpi.inpe.br/lccs/") # Returns the list of classification system available on the service print(service.classification_systems) diff --git a/examples/ex-01.py b/examples/ex-01.py index c5a827e..d6aef36 100644 --- a/examples/ex-01.py +++ b/examples/ex-01.py @@ -42,10 +42,9 @@ # Get mapping mapping = service.mappings(system_name_source='PRODES-1.0', system_name_target='TerraClass_AMZ-1.0') -print(f"\nMapping PRODES-1.0 to TerraClass_AMZ-1.0: \n") +print(f"\nMapping PRODES-1.0 to TerraClass_AMZ-1.0:") -for mp in mapping: - print(mp) +print(mapping) # Get all styles available for a specific classification system style_formats = service.style_formats(system_source_name='PRODES-1.0') diff --git a/examples/mapping.py b/examples/mapping.py index 1caedb6..af96c13 100644 --- a/examples/mapping.py +++ b/examples/mapping.py @@ -10,13 +10,10 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Returns the mapping between two classification systems. # Make sure the classification system is available in service -mappings = service.mappings(system_id_source='TerraClass_AMZ', system_id_target='PRODES') - -for mp in mappings.mapping: - print("Source Class: {} ID: {} | Target Class: {} ID: {}".format(mp.source_class, mp.source_class_id, - mp.target_class, mp.target_class_id)) +mapping = service.mappings(system_name_source='PRODES-1.0', system_name_target='TerraClass_AMZ-1.0') +print(mapping) \ No newline at end of file diff --git a/examples/style.py b/examples/style.py index 3e60d7c..c1ad6c2 100644 --- a/examples/style.py +++ b/examples/style.py @@ -13,7 +13,7 @@ service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") # Save Style File -service.get_styles(system_id='MapBiomas5', format_id='QGIS') +service.get_style(system_name='PRODES-1.0', format_name='QGIS') # Save Style File passing the path directory -service.get_styles(system_id='MapBiomas5', format_id='QGIS', path='/home/user/Downloads/') +service.get_style(system_name='PRODES-1.0', format_name='QGIS', path='/home/user/Downloads/') diff --git a/examples/styles.py b/examples/styles.py index 363f555..8584203 100644 --- a/examples/styles.py +++ b/examples/styles.py @@ -10,9 +10,9 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Get all styles available for a specific classification system -styles = service.styles(system_id='MapBiomas5') +styles = service.style_formats('PRODES-1.0') print(styles) diff --git a/lccs/templates/mapping-item.html b/lccs/templates/mapping-item.html new file mode 100644 index 0000000..e15f8c5 --- /dev/null +++ b/lccs/templates/mapping-item.html @@ -0,0 +1,5 @@ +
+ Source Class: {{mapping-item.source_class.name}} + Target Class: {{mapping-item.target_class.name}} + Degree of Similarity: {{mapping-item.degree_of_similarity}} +
\ No newline at end of file From 3eb65667c247e1fe101359fd73735ba74a3762c1 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Fri, 12 Feb 2021 18:17:41 -0300 Subject: [PATCH 4/9] remove spaces --- lccs/lccs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lccs/lccs.py b/lccs/lccs.py index 48a5a58..ea00db9 100644 --- a/lccs/lccs.py +++ b/lccs/lccs.py @@ -84,7 +84,6 @@ def classification_system(self, system_name: str) -> ClassificationSystem: :returns: A ClassificationSystem. :rtype: dict """ - if system_name in self._classification_systems.keys() and self._classification_systems[system_name] is not None: return self._classification_systems[system_name] From 6b82cdd58ef0df89d454d4fa7e29650d38fb31c3 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Thu, 18 Feb 2021 10:54:22 -0300 Subject: [PATCH 5/9] fixing url inn examples --- examples/available_mappings.py | 2 +- examples/classification_system_metadata.py | 2 +- examples/classification_systems.py | 2 +- examples/ex-01.py | 4 ++-- examples/style.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/available_mappings.py b/examples/available_mappings.py index 7fa4b38..157c9bf 100644 --- a/examples/available_mappings.py +++ b/examples/available_mappings.py @@ -10,7 +10,7 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("'https://brazildatacube.dpi.inpe.br/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Return the list of available clasification system for mapping available_mappings = service.available_mappings('PRODES-1.0') diff --git a/examples/classification_system_metadata.py b/examples/classification_system_metadata.py index d5b295f..cf2479b 100644 --- a/examples/classification_system_metadata.py +++ b/examples/classification_system_metadata.py @@ -10,7 +10,7 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Return the metadata of a specific classification system # Make sure the classification system is available in service diff --git a/examples/classification_systems.py b/examples/classification_systems.py index c928bc4..f074ed0 100644 --- a/examples/classification_systems.py +++ b/examples/classification_systems.py @@ -10,7 +10,7 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/") # Returns the list of classification system available on the service print(service.classification_systems) diff --git a/examples/ex-01.py b/examples/ex-01.py index d6aef36..275cd7d 100644 --- a/examples/ex-01.py +++ b/examples/ex-01.py @@ -12,9 +12,9 @@ print(lccs.__version__) -url = os.environ.get('LCCS_SERVER_URL', 'https://brazildatacube.dpi.inpe.br/lccs/') +server_url = os.environ.get('LCCS_SERVER_URL', 'https://brazildatacube.dpi.inpe.br/lccs/') -service = lccs.LCCS(url) +service = lccs.LCCS(server_url) print("Return all classification systems available in service") print(service.classification_systems) diff --git a/examples/style.py b/examples/style.py index c1ad6c2..e0f92d1 100644 --- a/examples/style.py +++ b/examples/style.py @@ -10,7 +10,7 @@ from lccs import LCCS # Change to the LCCS-WS URL you want to use. -service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/") +service = LCCS("https://brazildatacube.dpi.inpe.br/dev/lccs/") # Save Style File service.get_style(system_name='PRODES-1.0', format_name='QGIS') From 483b26d5e19a7fb0ab32cc36a807da373a88a5f2 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Thu, 18 Feb 2021 10:55:56 -0300 Subject: [PATCH 6/9] fixing tests ref #38 --- lccs/class_system.py | 7 +- tests/tests_lccs/jsons/class.json | 11 +- tests/tests_lccs/jsons/classes.json | 126 +++-- .../jsons/classification_system.json | 18 +- .../jsons/classification_systems.json | 78 +-- tests/tests_lccs/jsons/mapping.json | 500 +++++------------- tests/tests_lccs/jsons/mappings.json | 42 +- tests/tests_lccs/test_lccs.py | 90 ++-- 8 files changed, 303 insertions(+), 569 deletions(-) diff --git a/lccs/class_system.py b/lccs/class_system.py index 0a33420..513fe97 100644 --- a/lccs/class_system.py +++ b/lccs/class_system.py @@ -72,9 +72,10 @@ def _get_classes(self, filter=None): for link in self['links']: if link['rel'] == 'classes': data = Utils._get(link['href'], params=filter) - [classes.append(ClassificationSystemClass(Utils._get(i['href'], self._validate), self._validate)) for i in data if i['rel'] == 'child'] - self['classes'] = classes - return ClassificationSystemClass({}) + for i in data: + if 'rel' in i and i['rel'] == 'child': + classes.append(ClassificationSystemClass(Utils._get(i['href'], self._validate), self._validate)) + self['classes'] = classes def _repr_html_(self): """HTML repr.""" diff --git a/tests/tests_lccs/jsons/class.json b/tests/tests_lccs/jsons/class.json index 7bc3e06..9b48565 100644 --- a/tests/tests_lccs/jsons/class.json +++ b/tests/tests_lccs/jsons/class.json @@ -1,19 +1,16 @@ { - "class_parent": null, - "classification_system_id": 4, - "classification_system_name": "PRODES", "code": "FLORESTA", "description": "", - "id": 176, + "id": 2, "links": [ { - "href": "http://localhost:5000/classification_system/PRODES/classes/Floresta", + "href": "http://localhost:5000/classification_systems/1/classes/2", "rel": "self", "title": "Link to this document", "type": "application/json" }, { - "href": "http://localhost:5000/classification_systemPRODES/classes", + "href": "http://localhost:5000/classification_systems1/classes", "rel": "parent", "title": "Link to this document", "type": "application/json" @@ -32,4 +29,4 @@ } ], "name": "Floresta" -} +} \ No newline at end of file diff --git a/tests/tests_lccs/jsons/classes.json b/tests/tests_lccs/jsons/classes.json index d20dbfc..af3d9af 100644 --- a/tests/tests_lccs/jsons/classes.json +++ b/tests/tests_lccs/jsons/classes.json @@ -1,64 +1,62 @@ -{ - "links": [ - { - "href": "http://localhost:5000/classification_system/PRODES/classes", - "rel": "self", - "title": "Classes of the classification system PRODES", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES", - "rel": "parent", - "title": "Link to classification system", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_systems", - "rel": "parent", - "title": "Link to classification systems", - "type": "application/json" - }, - { - "href": "http://localhost:5000/", - "rel": "root", - "title": "API landing page", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Floresta", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Hidrografia", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Não Floresta", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Nuvem", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Resíduo", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes/Desmatamento", - "rel": "child", - "title": "Classification System Classes", - "type": "application/json" - } - ] -} \ No newline at end of file +[ + { + "href": "http://localhost:5000/classification_systems/1/classes", + "rel": "self", + "title": "Classes of the classification system 1", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1", + "rel": "parent", + "title": "Link to classification system", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems", + "rel": "parent", + "title": "Link to classification systems", + "type": "application/json" + }, + { + "href": "http://localhost:5000/", + "rel": "root", + "title": "API landing page", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/1", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/2", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/3", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/4", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/5", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes/6", + "rel": "child", + "title": "Classification System Classes", + "type": "application/json" + } +] \ No newline at end of file diff --git a/tests/tests_lccs/jsons/classification_system.json b/tests/tests_lccs/jsons/classification_system.json index 84f8a37..526cd8c 100644 --- a/tests/tests_lccs/jsons/classification_system.json +++ b/tests/tests_lccs/jsons/classification_system.json @@ -4,27 +4,33 @@ "id": 1, "links": [ { - "href": "http://localhost:5000/classification_system", + "href": "http://localhost:5000/classification_systems", "rel": "parent", "title": "Link to this document", "type": "application/json" }, { - "href": "http://localhost:5000/classification_system/PRODES", + "href": "http://localhost:5000/classification_systems/1", "rel": "self", "title": "The classification_system", "type": "application/json" }, { - "href": "http://localhost:5000/classification_system/PRODES/classes", + "href": "http://localhost:5000/classification_systems/1/classes", "rel": "classes", "title": "The classes related to this item", "type": "application/json" }, { - "href": "http://localhost:5000/classification_system/PRODES/styles", - "rel": "styles", - "title": "The styles related to this item", + "href": "http://localhost:5000/classification_systems/1/style_formats", + "rel": "styles_formats", + "title": "The styles formats related to this item", + "type": "application/json" + }, + { + "href": "http://localhost:5000/mappings/1", + "rel": "mappings", + "title": "The classification system mappings", "type": "application/json" }, { diff --git a/tests/tests_lccs/jsons/classification_systems.json b/tests/tests_lccs/jsons/classification_systems.json index f2a2f29..1f683a5 100644 --- a/tests/tests_lccs/jsons/classification_systems.json +++ b/tests/tests_lccs/jsons/classification_systems.json @@ -1,37 +1,41 @@ -{ - "classification_systems": [ - { - "authority_name": "INPE", - "description": "Sistema de Classificação Anual de Desmatamento", - "id": 1, - "links": [ - { - "href": "http://localhost:5000/classification_system/PRODES", - "rel": "child", - "title": "Link to Classification System", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/PRODES/classes", - "rel": "child", - "title": "Link to Classification System Classes", - "type": "application/json" - }, - { - "href": "http://localhost:5000/mappings/PRODES", - "rel": "child", - "title": "Link to Classification Mappings", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_systems", - "rel": "self", - "title": "Link to this document", - "type": "application/json" - } - ], - "name": "PRODES", - "version": "1.0" - } - ] -} \ No newline at end of file +[ + { + "authority_name": "INPE", + "description": "Sistema de Classificação Anual de Desmatamento", + "id": 1, + "links": [ + { + "href": "http://localhost:5000/classification_systems/1", + "rel": "classification_system", + "title": "Link to Classification System", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/classes", + "rel": "classes", + "title": "Link to Classification System Classes", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/1/style_formats", + "rel": "style_formats", + "title": "Link to Available Style Formats", + "type": "application/json" + }, + { + "href": "http://localhost:5000/mappings/1", + "rel": "mappings", + "title": "Link to Classification Mappings", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems", + "rel": "self", + "title": "Link to this document", + "type": "application/json" + } + ], + "name": "PRODES", + "version": "1.0" + } +] \ No newline at end of file diff --git a/tests/tests_lccs/jsons/mapping.json b/tests/tests_lccs/jsons/mapping.json index 5d6ed8a..c421759 100644 --- a/tests/tests_lccs/jsons/mapping.json +++ b/tests/tests_lccs/jsons/mapping.json @@ -1,378 +1,122 @@ -{ - "mappings": [ - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Agricultura Anual", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Agricultura Anual", - "source_id": 85, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Área Não Observada", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Nuvem", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Área Não Observada", - "source_id": 86, - "target": "Nuvem", - "target_id": 179 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Área sem Informação", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Área sem Informação", - "source_id": 87, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Área Urbana", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Não Floresta", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Área Urbana", - "source_id": 88, - "target": "Não Floresta", - "target_id": 178 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desflorestamento", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Desflorestamento", - "source_id": 89, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Mosaico de Ocupações", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Mosaico de Ocupações", - "source_id": 90, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Outros", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Outros", - "source_id": 91, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Pasto com Solo Exposto", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Pasto com Solo Exposto", - "source_id": 92, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Pasto Limpo", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Pasto Limpo", - "source_id": 93, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Pasto Sujo", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Pasto Sujo", - "source_id": 94, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Reflorestamento", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Reflorestamento", - "source_id": 95, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Regeneração com Pasto", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Regeneração com Pasto", - "source_id": 96, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Vegetação Secundária", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Vegetação Secundária", - "source_id": 97, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Floresta", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Floresta", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Floresta", - "source_id": 125, - "target": "Floresta", - "target_id": 176 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Hidrografia", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Hidrografia", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Hidrografia", - "source_id": 126, - "target": "Hidrografia", - "target_id": 177 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Mineração", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Desmatamento", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Mineração", - "source_id": 127, - "target": "Desmatamento", - "target_id": 175 - }, - { - "degree_of_similarity": 1, - "description": "", - "links": [ - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Não Floresta", - "rel": "item", - "title": "Link to the source class", - "type": "application/json" - }, - { - "href": "http://localhost:5000/classification_system/TerraClass_AMZ/classes/Não Floresta", - "rel": "item", - "title": "Link to target class", - "type": "application/json" - } - ], - "source": "Não Floresta", - "source_id": 128, - "target": "Não Floresta", - "target_id": 178 - } - ] -} \ No newline at end of file +[ + { + "degree_of_similarity": 0, + "description": "alguma descricao", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/3", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/31", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 3, + "target_class_id": 31 + }, + { + "degree_of_similarity": 0, + "description": "alguma descricaong", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/4", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/32", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 4, + "target_class_id": 32 + }, + { + "degree_of_similarity": 0, + "description": "alguma descricao", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/1", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/33", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 1, + "target_class_id": 33 + }, + { + "degree_of_similarity": 0, + "description": "alguma descricao", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/2", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/34", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 2, + "target_class_id": 34 + }, + { + "degree_of_similarity": 0, + "description": "alguma descricao", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/3", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/35", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 3, + "target_class_id": 35 + }, + { + "degree_of_similarity": 0, + "description": "alguma descricao", + "links": [ + { + "href": "http://localhost:5000/classification_systems/1/classes/3", + "rel": "item", + "title": "Link to source class", + "type": "application/json" + }, + { + "href": "http://localhost:5000/classification_systems/3/classes/36", + "rel": "item", + "title": "Link to target class", + "type": "application/json" + } + ], + "source_class_id": 3, + "target_class_id": 36 + } +] \ No newline at end of file diff --git a/tests/tests_lccs/jsons/mappings.json b/tests/tests_lccs/jsons/mappings.json index 7e4d805..e0cadc7 100644 --- a/tests/tests_lccs/jsons/mappings.json +++ b/tests/tests_lccs/jsons/mappings.json @@ -1,22 +1,20 @@ -{ - "links": [ - { - "href": "http://localhost:5000/classification_systems", - "rel": "parent", - "title": "Link to classification systems", - "type": "application/json" - }, - { - "href": "http://localhost:5000/", - "rel": "root", - "title": "API landing page", - "type": "application/json" - }, - { - "href": "http://localhost:5000/mappings/TerraClass_AMZ/PRODES", - "rel": "child", - "title": "PRODES", - "type": "application/json" - } - ] -} \ No newline at end of file +[ + { + "href": "http://localhost:5000/classification_systems", + "rel": "parent", + "title": "Link to classification systems", + "type": "application/json" + }, + { + "href": "http://localhost:5000/", + "rel": "root", + "title": "API landing page", + "type": "application/json" + }, + { + "href": "http://localhost:5000/mappings/1/3", + "rel": "child", + "title": "Mapping", + "type": "application/json" + } +] \ No newline at end of file diff --git a/tests/tests_lccs/test_lccs.py b/tests/tests_lccs/test_lccs.py index 6b59783..e72bc6a 100644 --- a/tests/tests_lccs/test_lccs.py +++ b/tests/tests_lccs/test_lccs.py @@ -21,12 +21,9 @@ url = os.environ.get('LCCS_SERVER_URL', 'http://localhost:5000') match_url = re.compile(url) - - -@pytest.fixture -def requests_mock(requests_mock): - requests_mock.get(re.compile('https://geojson.org/'), real_http=True) - yield requests_mock +match_url_system = re.compile(url + '/1') +match_url_class = re.compile(url + '/1/classes') +match_url_mappings = re.compile(url + '/mappings') @pytest.fixture(scope='session') @@ -52,8 +49,32 @@ def lccs_object(): class TestLCCS: - - def test_lccs(self): + + def _setup_lccs(self, mock, json_systems=None, json_class=None, json_system=None, json_mappings=None): + if json_systems is not None: + mock.get(match_url, json=json_systems, + status_code=200, + headers={'content-type': 'application/json'}) + if json_system is not None: + mock.get(match_url_system, json=json_system, + status_code=200, + headers={'content-type': 'application/json'}) + if json_class is not None: + mock.get(match_url_class, json=json_class, + status_code=200, + headers={'content-type': 'application/json'}) + if json_mappings is not None: + mock.get(match_url_mappings, json=json_mappings, + status_code=200, + headers={'content-type': 'application/json'}) + + def test_lccs(self, requests_mock): + requests_mock.get(match_url, json=dict(lccs_version='0.6.0', links=list()), + status_code=200, + headers={'content-type': 'application/json'}) + + self._setup_lccs(requests_mock, list(), list()) + service = lccs.LCCS(url) assert service.url == url assert repr(service) == 'lccs("{}")'.format(url) @@ -61,27 +82,24 @@ def test_lccs(self): def test_classification_systems(self, lccs_object, requests_mock): for k in lccs_object: - service = lccs.LCCS(url, True) + self._setup_lccs(requests_mock, json_systems=lccs_object[k]['classification_systems.json'], + json_class=lccs_object[k]['classes.json']) - requests_mock.get(match_url, json=lccs_object[k]['classification_systems.json'], - status_code=200, - headers={'content-type': 'application/json'}) + service = lccs.LCCS(url, True) response = service.classification_systems - assert list(response) == ['PRODES'] + assert response == ['PRODES-1.0'] def test_classification_system(self, lccs_object, requests_mock): for k in lccs_object: - service = lccs.LCCS(url, True) - - requests_mock.get(match_url, json=lccs_object[k]['classification_system.json'], - status_code=200, - headers={'content-type': 'application/json'}) + self._setup_lccs(requests_mock, json_systems=lccs_object[k]['classification_systems.json'], + json_class=lccs_object[k]['classes.json'], + json_system=lccs_object[k]['classification_system.json']) - class_system = service.classification_system(system_id='PRODES') + service = lccs.LCCS(url, True) - assert class_system == lccs_object[k]['classification_system.json'] + class_system = service.classification_system('PRODES-1.0') assert class_system.id assert class_system.name @@ -90,38 +108,6 @@ def test_classification_system(self, lccs_object, requests_mock): assert class_system.links[0].href assert class_system.links[0].rel - def teste_mappings(self, lccs_object, requests_mock): - for k in lccs_object: - service = lccs.LCCS(url, True) - - requests_mock.get(match_url, json=lccs_object[k]['mappings.json'], - status_code=200, - headers={'content-type': 'application/json'}) - - available_mappings = service.available_mappings(system_id_source='TerraClass_AMZ') - - assert list(available_mappings) == ['PRODES'] - - def teste_mapping(self, lccs_object, requests_mock): - for k in lccs_object: - service = lccs.LCCS(url, True) - - requests_mock.get(match_url, json=lccs_object[k]['mapping.json'], - status_code=200, - headers={'content-type': 'application/json'}) - - mp = service.mappings(system_id_source='TerraClass_AMZ', system_id_target='PRODES') - - assert 'TerraClass_AMZ' == mp.source_classification_system - assert 'PRODES' == mp.target_classification_system - assert 'degree_of_similarity' in mp.mapping[0] - assert 'description' in mp.mapping[0] - assert 'links' in mp.mapping[0] - assert 'source' in mp.mapping[0] - assert 'source_id' in mp.mapping[0] - assert 'target' in mp.mapping[0] - assert 'target_id' in mp.mapping[0] - if __name__ == '__main__': pytest.main(['--color=auto', '--no-cov']) From c22a79c400d7e832e0c680a999e5c207a017e118 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Thu, 18 Feb 2021 11:06:03 -0300 Subject: [PATCH 7/9] fixing tests ref #38 --- .drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index ac95732..fb13510 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,10 +7,8 @@ steps: commands: - pip install --upgrade pip - pip install --upgrade setuptools - - pip install -e .[tests,docs] + - pip install -e .[all] - ./run-tests.sh - environment: - LCCS_SERVER_URL: http://brazildatacube.dpi.inpe.br/dev/lccs - name: coverage image: plugins/codecov From 6dee499f3254a11617bfd7978c8ce89836a08f53 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Thu, 18 Feb 2021 11:08:18 -0300 Subject: [PATCH 8/9] adding discord notify --- .drone.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.drone.yml b/.drone.yml index fb13510..98a88d8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,3 +22,12 @@ steps: event: - push +- name: discord-notify + image: brazildatacube/bdc-drone-discord + settings: + webhook: + from_secret: discord_webhook + when: + status: + - failure + - success From da6921a71f2cb6f1eeb4dfcd81ebe421f1727689 Mon Sep 17 00:00:00 2001 From: Fabiana Zioti Date: Thu, 18 Feb 2021 11:13:08 -0300 Subject: [PATCH 9/9] fixing href in class --- tests/tests_lccs/jsons/class.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_lccs/jsons/class.json b/tests/tests_lccs/jsons/class.json index 9b48565..bdd8455 100644 --- a/tests/tests_lccs/jsons/class.json +++ b/tests/tests_lccs/jsons/class.json @@ -10,7 +10,7 @@ "type": "application/json" }, { - "href": "http://localhost:5000/classification_systems1/classes", + "href": "http://localhost:5000/classification_systems/1/classes", "rel": "parent", "title": "Link to this document", "type": "application/json"