-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from openeemeter/feature/make_real_warnings
created EEWeatherWarning
- Loading branch information
Showing
7 changed files
with
182 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
__title__ = 'eeweather' | ||
__description__ = 'Weather for Open Energy Efficiency Meter' | ||
__url__ = 'https://github.com/openeemeter/eeweather' | ||
__version__ = '0.3.3' | ||
__version__ = '0.3.4' | ||
__author__ = 'Phil Ngo' | ||
__author_email__ = '[email protected]' | ||
__license__ = 'Apache 2.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class EEWeatherWarning(object): | ||
''' An object representing a warning and data associated with it. | ||
Attributes | ||
---------- | ||
qualified_name : :any:`str` | ||
Qualified name, e.g., `'eeweather.method_abc.missing_data'`. | ||
description : :any:`str` | ||
Prose describing the nature of the warning. | ||
data : :any:`dict` | ||
Data that reproducibly shows why the warning was issued. | ||
''' | ||
|
||
def __init__(self, qualified_name, description, data): | ||
self.qualified_name = qualified_name | ||
self.description = description | ||
self.data = data | ||
|
||
def __repr__(self): | ||
return 'EEWeatherWarning(qualified_name={})'.format(self.qualified_name) | ||
|
||
def json(self): | ||
''' Return a JSON-serializable representation of this result. | ||
The output of this function can be converted to a serialized string | ||
with :any:`json.dumps`. | ||
''' | ||
return { | ||
'qualified_name': self.qualified_name, | ||
'description': self.description, | ||
'data': self.data, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pytest | ||
|
||
from eeweather.warnings import EEWeatherWarning | ||
|
||
|
||
@pytest.fixture | ||
def generic_eeweather_warning(): | ||
return EEWeatherWarning( | ||
qualified_name='qualified_name', | ||
description='description', | ||
data={} | ||
) | ||
|
||
|
||
def test_str_repr(generic_eeweather_warning): | ||
assert str(generic_eeweather_warning) == ( | ||
'EEWeatherWarning(qualified_name=qualified_name)' | ||
) | ||
|
||
|
||
def test_json_repr(generic_eeweather_warning): | ||
assert generic_eeweather_warning.json() == { | ||
'qualified_name': 'qualified_name', | ||
'description': 'description', | ||
'data': {}, | ||
} |