Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.21.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Aug 18, 2020
2 parents cbefdbf + 4bd66ae commit 509d87a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release-from-tag.yml
@@ -0,0 +1,24 @@
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
23 changes: 23 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,28 @@
# Changelog

## [v0.21.0](https://github.com/SebRut/pygrocy/tree/v0.21.0) (2020-08-18)

[Full Changelog](https://github.com/SebRut/pygrocy/compare/v0.20.0...v0.21.0)

**Implemented enhancements:**

- consider using ciso8601 instead of iso8601 [\#84](https://github.com/SebRut/pygrocy/issues/84)

**Fixed bugs:**

- Not all fields of Product are set in all cases [\#122](https://github.com/SebRut/pygrocy/issues/122)

**Closed issues:**

- Task without due date gives error [\#119](https://github.com/SebRut/pygrocy/issues/119)

**Merged pull requests:**

- init all Product fields with None by default [\#123](https://github.com/SebRut/pygrocy/pull/123) ([SebRut](https://github.com/SebRut))
- Check for empty string in parse\_date [\#120](https://github.com/SebRut/pygrocy/pull/120) ([isabellaalstrom](https://github.com/isabellaalstrom))
- Update coveralls requirement from ~=2.1.1 to ~=2.1.2 [\#108](https://github.com/SebRut/pygrocy/pull/108) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- Update responses requirement from ~=0.10.15 to ~=0.10.16 [\#107](https://github.com/SebRut/pygrocy/pull/107) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))

## [v0.20.0](https://github.com/SebRut/pygrocy/tree/v0.20.0) (2020-08-16)

[Full Changelog](https://github.com/SebRut/pygrocy/compare/v0.19.0...v0.20.0)
Expand Down
19 changes: 13 additions & 6 deletions pygrocy/grocy.py
Expand Up @@ -24,19 +24,30 @@

class Product(DataModel):
def __init__(self, response):
self._init_empty()
if isinstance(response, CurrentStockResponse):
self._init_from_CurrentStockResponse(response)
elif isinstance(response, MissingProductResponse):
self._init_from_MissingProductResponse(response)
elif isinstance(response, ProductDetailsResponse):
self._init_from_ProductDetailsResponse(response)

def _init_empty(self):
self._name = None
self._id = None
self._amount_missing = None
self._is_partly_in_stock = None

self._available_amount = None
self._best_before_date = None

self._barcodes = None
self._product_group_id = None

def _init_from_CurrentStockResponse(self, response: CurrentStockResponse):
self._id = response.product_id
self._available_amount = response.amount
self._best_before_date = response.best_before_date
self._amount_missing = None
self._is_partly_in_stock = None
if response.product:
self._name = response.product.name
self._barcodes = response.product.barcodes
Expand All @@ -45,12 +56,8 @@ def _init_from_CurrentStockResponse(self, response: CurrentStockResponse):
def _init_from_MissingProductResponse(self, response: MissingProductResponse):
self._id = response.product_id
self._name = response.name
self._available_amount = None
self._best_before_date = None
self._amount_missing = response.amount_missing
self._is_partly_in_stock = response.is_partly_in_stock
self._barcodes = None
self._product_group_id = None

def _init_from_ProductDetailsResponse(self, response: ProductDetailsResponse):
self._id = response.product.id
Expand Down
2 changes: 1 addition & 1 deletion pygrocy/utils.py
Expand Up @@ -5,7 +5,7 @@


def parse_date(input_value):
if input_value is None:
if input_value is "" or input_value is None:
return None
return iso8601.parse_date(input_value)

Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
@@ -1,4 +1,4 @@
coveralls~=2.1.1
coveralls~=2.1.2
doctr~=1.8.0
pdoc3~=0.8.4
responses~=0.10.15
responses~=0.10.16
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pygrocy",
version="0.20.0",
version="0.21.0",
author="Sebastian Rutofski",
author_email="kontakt@sebastian-rutofski.de",
description="",
Expand Down
6 changes: 6 additions & 0 deletions test/test_utils.py
Expand Up @@ -16,7 +16,13 @@ def test_parse_date_no_data(self):
date_obj = utils.parse_date(date_str)

assert date_obj is None

def test_parse_date_empty_string(self):
date_str = ""
date_obj = utils.parse_date(date_str)

assert date_obj is None

def test_parse_int_valid(self):
int_str = "2"
int_number = utils.parse_int(int_str)
Expand Down

0 comments on commit 509d87a

Please sign in to comment.