Skip to content

Commit 1b7a04b

Browse files
author
BrunoSilvaAndrade
committed
Adding status badge of Test and pipy version
Creating action of report coverage
1 parent 554d441 commit 1b7a04b

5 files changed

Lines changed: 43 additions & 7 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Report Coverage
2+
3+
on:
4+
release:
5+
branches: ["master"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install pytest coverage coveralls
25+
- name: Report coverage
26+
env:
27+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
28+
run: |
29+
coverage run --source=./ -m pytest
30+
coveralls

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Python-config-parser
22
===
3+
---
4+
[![Tests](https://github.com/BrunoSilvaAndrade/python-config-parser/actions/workflows/tests.yml/badge.svg)](https://github.com/BrunoSilvaAndrade/python-config-parser/actions/workflows/tests.yml)
5+
[![PyPI version](https://badge.fury.io/py/python-config-parser.svg)](https://badge.fury.io/py/python-config-parser)
6+
37
This project was created to give you the possibility
48
of creating runtime configuration objects using json or yaml files.
59

parsers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
import yaml
33

44

5-
class ParseException(Exception):
5+
class ParseError(Exception):
66
pass
77

88

99
def json_parser(file_buff):
1010
try:
1111
return json.loads(file_buff)
1212
except json.JSONDecodeError as e:
13-
raise ParseException(f'Unable to decode config file using json', e)
13+
raise ParseError('Unable to decode config file using json', e)
1414

1515

1616
def yaml_parser(file_buff):
1717
try:
1818
return yaml.safe_load(file_buff)
1919
except yaml.YAMLError as e:
20-
raise ParseException(f'Unable to decode config file using yaml', e)
20+
raise ParseError('Unable to decode config file using yaml', e)

pyconfigparser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from parsers import ParseException, json_parser, yaml_parser
1+
from parsers import ParseError, json_parser, yaml_parser
22
from schema import Schema, SchemaError
33
from typing import Any
44
from os import path
@@ -78,6 +78,8 @@ def __create_new_instance(cls, schema, config_dir, file_name):
7878
try:
7979
config = cls.__validate_schema(schema, parser(file_buff))
8080
return cls.__dict_2_obj(config)
81+
except ParseError as e:
82+
raise ConfigError(e)
8183
except SchemaError as e:
8284
raise ConfigError('Schema validation error', e)
8385

test_configparser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pyconfigparser import Config, ConfigError, ConfigFileNotFoundError, ParseException
1+
from pyconfigparser import Config, ConfigError, ConfigFileNotFoundError
22
from config.schemas import SIMPLE_SCHEMA_CONFIG, UNSUPPORTED_OBJECT_KEYS_SCHEMA
33
import unittest
44
import os
@@ -56,8 +56,8 @@ def test_config_file_with_unsupported_extension(self):
5656
self.assertRaises(ConfigError, Config.get_config, SIMPLE_SCHEMA_CONFIG, file_name='config.bad_extension')
5757

5858
def test_bad_decoder_error(self):
59-
self.assertRaises(ParseException, Config.get_config, SIMPLE_SCHEMA_CONFIG, file_name='bad_content.json')
60-
self.assertRaises(ParseException, Config.get_config, SIMPLE_SCHEMA_CONFIG, file_name='bad_content.yaml')
59+
self.assertRaises(ConfigError, Config.get_config, SIMPLE_SCHEMA_CONFIG, file_name='bad_content.json')
60+
self.assertRaises(ConfigError, Config.get_config, SIMPLE_SCHEMA_CONFIG, file_name='bad_content.yaml')
6161

6262

6363
if __name__ == '__main__':

0 commit comments

Comments
 (0)