Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix tests
Roland Geidere561af456fb9
diff --git a/wger/exercises/tests/test_sync.py b/wger/exercises/tests/test_sync.pyindex 534ee3095..2f991f3cc 100644--- a/wger/exercises/tests/test_sync.py+++ b/wger/exercises/tests/test_sync.py@@ -88,13 +88,13 @@ class MockLicenseResponse:def __init__(self):self.status_code = 200- self.content = b'1234'+ self.content = b''# yapf: disable@staticmethoddef json():return {- "count": 24,+ "count": 4,"next": None,"previous": None,"results": [@@ -110,6 +110,12 @@ class MockLicenseResponse:"short_name": "ACL 2.1","url": "https://another-cool-license.org/acl-2.1"},+ {+ "id": 5,+ "url": "https://another-cool-license.org/acl-2.2",+ "full_name": "Another cool license 2.2",+ "short_name": "ACL 2.2"+ },{"id": 3,"full_name": "Creative Commons Attribution Share Alike 4",@@ -544,7 +550,7 @@ class TestSyncMethods(WgerTestCase):@patch('requests.get', return_value=MockLicenseResponse())def test_license_sync(self, mock_request):- self.assertEqual(License.objects.count(), 2)+ self.assertEqual(License.objects.count(), 3)self.assertEqual(License.objects.get(pk=1).url, '')sync_licenses(lambda x: x)@@ -553,12 +559,14 @@ class TestSyncMethods(WgerTestCase):headers=wger_headers(),)self.assertEqual(- License.objects.get(pk=1).url, 'http://creativecommons.org/licenses/aca/fl/4.0/'+ License.objects.get(pk=1).url,+ 'http://creativecommons.org/licenses/aca/fl/4.0/',)self.assertEqual(- License.objects.get(pk=3).full_name, 'Creative Commons Attribution Share Alike 4'+ License.objects.get(pk=6).full_name,+ 'Creative Commons Attribution Share Alike 4',)- self.assertEqual(License.objects.count(), 3)+ self.assertEqual(License.objects.count(), 4)@patch('requests.get', return_value=MockCategoryResponse())def test_categories_sync(self, mock_request):diff --git a/wger/nutrition/api/views.py b/wger/nutrition/api/views.pyindex 3a9f333ad..4e32466aa 100644--- a/wger/nutrition/api/views.py+++ b/wger/nutrition/api/views.py@@ -90,6 +90,7 @@ class IngredientViewSet(viewsets.ReadOnlyModelViewSet):'carbohydrates','carbohydrates_sugar','creation_date',+ 'update_date','energy','fat','fat_saturated',diff --git a/wger/nutrition/fixtures/test-ingredients.json b/wger/nutrition/fixtures/test-ingredients.jsonindex 40f596202..7df5a3cc1 100644--- a/wger/nutrition/fixtures/test-ingredients.json+++ b/wger/nutrition/fixtures/test-ingredients.json@@ -6,8 +6,8 @@"uuid": "7908c204-907f-4b1e-ad4e-f482e9769ade","status": "2","license_author": "wger test",- "update_date": "2013-02-12",- "creation_date": "2013-01-01",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-01-01T10:23:00+01:00","name": "Test ingredient 1","language": 2,"sodium": "0.549",@@ -34,8 +34,8 @@"status": "2","license_author": "wger test","name": "Ingredient, test, 2, organic, raw",- "update_date": "2013-02-12",- "creation_date": "2013-01-01",+ "update_date": "2013-02-12T15:12:00+01:00",+ "creation_date": "2013-01-01T23:54:11+02:00","language": 2,"sodium": "0.1","energy": 300,@@ -60,8 +60,8 @@"uuid": "f28c8a68-ecda-42db-a9c4-781ee2aee472","status": "2","license_author": "wger test",- "update_date": "2013-03-22",- "creation_date": "2013-02-03",+ "update_date": "2013-03-22T18:32:15+01:00",+ "creation_date": "2013-02-03T16:16:50+01:00","name": "Bachelor chow, now with flavour!","language": 2,"sodium": "0.1",@@ -87,8 +87,8 @@"uuid": "fdd662aa-696c-46c6-acae-b192ccc25f11","status": "2","license_author": "wger test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T12:17:45+01:00",+ "creation_date": "2013-04-05T12:12:12+01:00","name": "Slurm","language": 2,"sodium": "0.1",@@ -114,8 +114,8 @@"uuid": "293957df-b5bb-4ca6-b883-2234185c5372","status": "2","license_author": "wger test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T14:14:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Another tasty ingredient","language": 2,"sodium": "2.1",@@ -141,8 +141,8 @@"uuid": "dfc5c622-027b-4f17-8141-dadd1ce7e3f1","status": "2","license_author": "wger test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Raw ingredient","language": 2,"sodium": "2.1",@@ -168,8 +168,8 @@"uuid": "42a41805-2caf-4c7e-9ff3-decbfee5f695","status": "1","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Pending ingredient","language": 2,"sodium": "2.1",@@ -195,8 +195,8 @@"uuid": "db9e0502-2a54-472d-97e2-3761d1b286ee","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -222,8 +222,8 @@"uuid": "7164629a-9f58-450b-8316-ad7954564171","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -249,8 +249,8 @@"uuid": "9d53cf0e-5100-480f-a320-2de51c70603b","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -276,8 +276,8 @@"uuid": "0187406a-7290-4199-a4dc-ccceb8cb55ea","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -303,8 +303,8 @@"uuid": "16ade127-00b0-4bcf-906e-dd9730f5ade1","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -330,8 +330,8 @@"uuid": "59a73b2c-ead1-4001-b6a0-355c9cb366a7","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",@@ -357,8 +357,8 @@"uuid": "a18665d0-24e3-4255-88aa-92f2831d568a","status": "2","license_author": "test",- "update_date": "2013-02-12",- "creation_date": "2013-04-05",+ "update_date": "2013-02-12T01:00:00+01:00",+ "creation_date": "2013-04-05T01:00:00+01:00","name": "Needed for guest user","language": 2,"sodium": "2.1",diff --git a/wger/nutrition/tests/test_ingredient.py b/wger/nutrition/tests/test_ingredient.pyindex 791031209..ca86d2d2b 100644--- a/wger/nutrition/tests/test_ingredient.py+++ b/wger/nutrition/tests/test_ingredient.py@@ -98,7 +98,10 @@ class EditIngredientTestCase(WgerEditTestCase):"""if self.current_user == 'admin':ingredient = Ingredient.objects.get(pk=1)- self.assertEqual(ingredient.update_date, datetime.date.today())+ self.assertEqual(+ ingredient.update_date.replace(microsecond=0),+ datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0)+ )class AddIngredientTestCase(WgerAddTestCase):@@ -129,7 +132,10 @@ class AddIngredientTestCase(WgerAddTestCase):"""if self.current_user == 'admin':ingredient = Ingredient.objects.get(pk=self.pk_after)- self.assertEqual(ingredient.creation_date, datetime.date.today())+ self.assertEqual(+ ingredient.creation_date.replace(microsecond=0),+ datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0)+ )self.assertEqual(ingredient.status, Ingredient.STATUS_ACCEPTED)elif self.current_user == 'test':ingredient = Ingredient.objects.get(pk=self.pk_after)