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.19.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRut committed Aug 14, 2020
2 parents f346bdb + ca1a055 commit 67c0a44
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

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

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

**Merged pull requests:**

- Add endpoint for adding generic entity [\#115](https://github.com/SebRut/pygrocy/pull/115) ([isabellaalstrom](https://github.com/isabellaalstrom))

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

[Full Changelog](https://github.com/SebRut/pygrocy/compare/v0.17.0...v0.18.0)
Expand Down
3 changes: 3 additions & 0 deletions pygrocy/grocy.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,6 @@ def recipe(self, recipe_id: int) -> RecipeItem:
recipe = self._api_client.get_recipe(recipe_id)
if recipe:
return RecipeItem(recipe)

def add_generic(self, entity_type, data):
return self._api_client.add_generic(entity_type, data)
3 changes: 3 additions & 0 deletions pygrocy/grocy_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,6 @@ def get_recipe(self, object_id: int) -> RecipeDetailsResponse:
parsed_json = self._do_get_request(f"objects/recipes/{object_id}")
if parsed_json:
return RecipeDetailsResponse(parsed_json)

def add_generic(self, entity_type: str, data: object):
self._do_post_request(f"objects/{entity_type}", data)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pygrocy",
version="0.18.0",
version="0.19.0",
author="Sebastian Rutofski",
author_email="[email protected]",
description="",
Expand Down
17 changes: 17 additions & 0 deletions test/test_grocy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def setUp(self):
)
self.base_url = f"{CONST_BASE_URL}:{CONST_PORT}/api"
self.date_test = datetime.strptime("2019-05-04 11:31:04", "%Y-%m-%d %H:%M:%S")
self.add_generic_data = {"name": "This is a task"}

def test_init(self):
self.assertIsInstance(self.grocy, Grocy)
Expand Down Expand Up @@ -432,6 +433,22 @@ def test_add_product_error(self):
HTTPError, self.grocy.add_product, 1, 1.3, 2.44, self.date_test
)

@responses.activate
def test_add_generic_valid(self):
responses.add(
responses.POST, f"{self.base_url}/objects/tasks", status=200
)
self.assertIsNone(self.grocy.add_generic("tasks", self.add_generic_data))

@responses.activate
def test_add_generic_error(self):
responses.add(
responses.POST, f"{self.base_url}/objects/tasks", status=400
)
self.assertRaises(
HTTPError, self.grocy.add_generic, "tasks", self.add_generic_data
)

@responses.activate
def test_consume_product_valid(self):
responses.add(
Expand Down

0 comments on commit 67c0a44

Please sign in to comment.