Skip to content

Commit

Permalink
Merge branch 'main' into rename-paid-column
Browse files Browse the repository at this point in the history
  • Loading branch information
Kandeel4411 authored Oct 2, 2020
2 parents 6771076 + ba92213 commit 45d3695
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/api/routes/resource_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def update_resource(id, json, db):
try:
logger.info(
f"Updating resource. Old data: {json_module.dumps(resource.serialize)}")
if json.get('languages'):
if json.get('languages') is not None:
resource.languages = langs
index_object['languages'] = resource.serialize['languages']
if json.get('category'):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_routes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def update_resource(client,
name="New name" if not name else name,
url="https://new.url" if not url else url,
category="New Category" if not category else category,
languages=["New language"] if not languages else languages,
languages=["New Lang"] if languages is None else languages,
free=False if not free else free,
notes="New notes" if not notes else notes),
headers={'x-apikey': apikey} if not headers else headers)
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_routes/test_resource_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def test_update_resource(
notes)
assert (response.status_code == 200)

# Empty languages list given removes all languages of resource
response = update_resource(client, apikey, languages=[])
assert (response.status_code == 200)
assert (response.json['resource'].get('languages') == [])

# Resource not found
response = client.put("/api/v1/resources/0",
json=dict(name="New name"),
Expand Down

0 comments on commit 45d3695

Please sign in to comment.