Skip to content

Commit 0c73b6a

Browse files
authored
Merge pull request #5 from jpstroop/badge
add CI badge
2 parents 3908c33 + 5b7bf2a commit 0c73b6a

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Fitbit Client
44

5-
[![CI](https://github.com/jpstroop/fitbit-client/actions/workflows/ci.yml/badge.svg)](https://github.com/jpstroop/fitbit-client/actions/workflows/ci.yml)
5+
[![CI](https://github.com/jpstroop/fitbit-client-python/actions/workflows/ci.yml/badge.svg)](https://github.com/jpstroop/fitbit-client-python/actions/workflows/ci.yml)
66
[![codecov](https://codecov.io/gh/jpstroop/fitbit-client-python/graph/badge.svg?token=DM0JD8VKZ4)](https://codecov.io/gh/jpstroop/fitbit-client-python)
77
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
88
[![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/release/python-3130/)

tests/resources/nutrition/test_create_food.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,43 @@ def test_create_food_calories_from_fat_must_be_integer(nutrition_resource):
102102
assert exc_info.value.error_type == "client_validation"
103103
assert exc_info.value.field_name == "CALORIES_FROM_FAT"
104104
assert "Calories from fat must be an integer" in str(exc_info.value)
105+
106+
107+
def test_create_food_with_calories_from_fat(nutrition_resource, mock_response):
108+
"""Test creating food with calories from fat as an integer"""
109+
mock_response.json.return_value = {"foodId": 12345, "name": "Test Food", "calories": 100}
110+
nutrition_resource.oauth.request.return_value = mock_response
111+
112+
result = nutrition_resource.create_food(
113+
name="Test Food",
114+
default_food_measurement_unit_id=147,
115+
default_serving_size=100.0,
116+
calories=100,
117+
description="Test food description",
118+
form_type=FoodFormType.DRY,
119+
nutritional_values={
120+
NutritionalValue.CALORIES_FROM_FAT: 20, # Integer value should work fine
121+
NutritionalValue.PROTEIN: 20.0,
122+
NutritionalValue.TOTAL_CARBOHYDRATE: 0.0,
123+
},
124+
)
125+
126+
assert result == mock_response.json.return_value
127+
nutrition_resource.oauth.request.assert_called_once_with(
128+
"POST",
129+
"https://api.fitbit.com/1/user/-/foods.json",
130+
data=None,
131+
json=None,
132+
params={
133+
"name": "Test Food",
134+
"defaultFoodMeasurementUnitId": 147,
135+
"defaultServingSize": 100.0,
136+
"calories": 100,
137+
"description": "Test food description",
138+
"formType": "DRY",
139+
"caloriesFromFat": 20, # Should be passed as an integer
140+
"protein": 20.0,
141+
"totalCarbohydrate": 0.0,
142+
},
143+
headers={"Accept-Locale": "en_US", "Accept-Language": "en_US"},
144+
)

0 commit comments

Comments
 (0)