From 4ae67e1d36ca73512031824d994799936f345c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Wed, 15 Oct 2014 22:38:29 -0300 Subject: [PATCH 1/5] Now using appengine-fixture-loader installed from GitHub --- Makefile | 2 - resources/lib/testable_appengine/__init__.py | 0 resources/lib/testable_appengine/loader.py | 54 -------------------- resources/requirements.txt | 1 + tests/sanity_test.py | 2 +- 5 files changed, 2 insertions(+), 57 deletions(-) delete mode 100644 resources/lib/testable_appengine/__init__.py delete mode 100644 resources/lib/testable_appengine/loader.py diff --git a/Makefile b/Makefile index fd5e863..5baa27a 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,6 @@ libraries: requirements appenginesdk cp $(CURDIR)/resources/autogenerated $(CURDIR)/$(VENV)/lib/python2.7/site-packages/gae.pth echo "$(CURDIR)/$(VENV)/lib/google_appengine/" >> $(CURDIR)/$(VENV)/lib/python2.7/site-packages/gae.pth echo "import dev_appserver; dev_appserver.fix_sys_path()" >> $(CURDIR)/$(VENV)/lib/python2.7/site-packages/gae.pth - cp $(CURDIR)/resources/autogenerated $(CURDIR)/$(VENV)/lib/python2.7/site-packages/utils.pth - echo "$(CURDIR)/resources/lib/" >> $(CURDIR)/$(VENV)/lib/python2.7/site-packages/utils.pth virtualenv: virtualenv $(CURDIR)/$(VENV) diff --git a/resources/lib/testable_appengine/__init__.py b/resources/lib/testable_appengine/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/resources/lib/testable_appengine/loader.py b/resources/lib/testable_appengine/loader.py deleted file mode 100644 index dd20219..0000000 --- a/resources/lib/testable_appengine/loader.py +++ /dev/null @@ -1,54 +0,0 @@ -""" -Tools to automate loading of test fixtures -""" - -import json - -from datetime import datetime, time, date - -from google.appengine.ext.ndb.model import (DateTimeProperty, DateProperty, - TimeProperty) - - -def _sensible_value(attribute_type, value): - if type(attribute_type) is DateTimeProperty: - retval = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S') - elif type(attribute_type) is TimeProperty: - try: - dt = datetime.strptime(value, '%H:%M:%S') - except ValueError: - dt = datetime.strptime(value, '%H:%M') - retval = time(dt.hour, dt.minute, dt.second) - elif type(attribute_type) is DateProperty: - dt = datetime.strptime(value, '%Y-%m-%d') - retval = date(dt.year, dt.month, dt.day) - else: - retval = value - - return retval - -def load_fixture(filename, cls, post_processor=None): - """ - Loads a file into entities of a given class, run the post_processor on each - instance before it's saved - """ - - def _loader(cls=cls): - "Create a loader for this type" - - def _load(od): - "Load the attributes defined in od into a cls and saves it" - obj = cls() - for attribute_name in od: - attribute_type = cls.__dict__[attribute_name] - attribute_value = _sensible_value(attribute_type, od[attribute_name]) - obj.__dict__['_values'][attribute_name] = attribute_value - if post_processor: - post_processor(obj) - obj.put() - return obj - - return _load - - data = json.load(open(filename), object_hook=_loader(cls)) - return data diff --git a/resources/requirements.txt b/resources/requirements.txt index 4d5119e..0ca0bac 100644 --- a/resources/requirements.txt +++ b/resources/requirements.txt @@ -3,3 +3,4 @@ nose pyflakes wsgiref WebTest +-e git+git@github.com:rbanffy/appengine-fixture-loader.git#egg=appengine_fixture_loader diff --git a/tests/sanity_test.py b/tests/sanity_test.py index bb324b7..490fe77 100644 --- a/tests/sanity_test.py +++ b/tests/sanity_test.py @@ -14,7 +14,7 @@ from google.appengine.ext import ndb from google.appengine.ext import testbed -from testable_appengine.loader import load_fixture +from appengine_fixture_loader.loader import load_fixture # If your project has a src/main.py file, it'll check if it imports try: From 867cafc744f78f06740ce711a1f362f6c09cf755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Sun, 19 Oct 2014 01:47:30 -0200 Subject: [PATCH 2/5] Google moved the SDK download to another location --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5baa27a..fc78368 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ directories: mkdir -p $(CURDIR)/build $(CURDIR)/cache appenginesdk: directories - wget -c http://commondatastorage.googleapis.com/appengine-sdks/featured/google_appengine_$(version).zip -O $(CURDIR)/cache/google_appengine_$(version).zip + wget -c https://storage.googleapis.com/appengine-sdks/featured/google_appengine_$(version).zip -O $(CURDIR)/cache/google_appengine_$(version).zip unzip -q -o $(CURDIR)/cache/google_appengine_$(version).zip -d $(CURDIR)/build requirements: From 0a5aae52640b9d016a53eb0aacf5f0badcba0e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Tue, 21 Oct 2014 08:29:37 -0200 Subject: [PATCH 3/5] Add a "test" target to the Makefile to make it easier to do CI --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index fc78368..6c07450 100644 --- a/Makefile +++ b/Makefile @@ -49,3 +49,6 @@ clean_cache: # Deletes the virtualenv clean_venv: clean_dirs rm -rf $(CURDIR)/$(VENV) + +test: venv + .env/bin/nosetests From 6d98cac984c6394ab03dee65b61135c094ed3e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Wed, 22 Oct 2014 15:09:28 -0200 Subject: [PATCH 4/5] SDK update --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6c07450..d257819 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -version=1.9.13 +version=1.9.14 # Override VENV if not defined VENV?=.env From 000a3846fd6dae8eefb7f6c17a83ffab1d59fca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20B=C3=A1nffy?= Date: Mon, 17 Nov 2014 15:51:59 -0200 Subject: [PATCH 5/5] SDK update --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d257819..c07201a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -version=1.9.14 +version=1.9.15 # Override VENV if not defined VENV?=.env