From 29b14fe6933e4ab858a48c0e1fbf87c1fe70bc90 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 26 Nov 2014 15:02:39 +0000 Subject: [PATCH 1/3] added test for applicable_from and created --- test/unit/library/test_dimension.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/test/unit/library/test_dimension.py b/test/unit/library/test_dimension.py index bb2ff10..d0670ad 100644 --- a/test/unit/library/test_dimension.py +++ b/test/unit/library/test_dimension.py @@ -32,7 +32,7 @@ def null_store(): return obj -class TestEvolvingDimensions(object): +class __TestEvolvingDimensions(object): def _fetch_store_row_count(self): connection = Warehouse.get() @@ -95,3 +95,28 @@ def test_null_values(self, empty_warehouse, store, null_store): Store.insert(store) Store.insert(null_store) assert self._fetch_store_row_count() == 2 + + +class TestAutoTimeStamp(): + """ + The `applicable_from` and `created` columns in the dimension tables default + to the current datetime. This was implemented using triggers. These + tests make sure they're working properly (especially useful for running + these tests across multiple MySQL versions). + + """ + + def test_success(self, empty_warehouse, store): + """ Just check that applicable_from == created_at. + """ + Warehouse.use(empty_warehouse) + Store.build() + Store.insert(store) + connection = Warehouse.get() + with closing(connection.cursor(dictionary=True)) as cursor: + cursor.execute( + "SELECT applicable_from, created FROM %s" % Store.__tablename__ + ) + rows = cursor.fetchall() + assert rows[0]['created'] + assert rows[0]['created'] == rows[0]['applicable_from'] From b23dabf5c82bb72e2459b651bc2f655b2e5cb4f8 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 26 Nov 2014 15:12:42 +0000 Subject: [PATCH 2/3] added documentation about mysql configuration --- docs/getting-started/index.rst | 6 ++++++ docs/getting-started/mysql_configuration.rst | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 docs/getting-started/mysql_configuration.rst diff --git a/docs/getting-started/index.rst b/docs/getting-started/index.rst index c6e632c..016f28a 100644 --- a/docs/getting-started/index.rst +++ b/docs/getting-started/index.rst @@ -2,3 +2,9 @@ Getting Started =============== Pylytics v1.0 is significantly improved from v0.7. New documentation will follow shortly. + +.. toctree:: + :maxdepth: 2 + :numbered: + + mysql-configuration diff --git a/docs/getting-started/mysql_configuration.rst b/docs/getting-started/mysql_configuration.rst new file mode 100644 index 0000000..0f0f902 --- /dev/null +++ b/docs/getting-started/mysql_configuration.rst @@ -0,0 +1,10 @@ +MySQL Configuration +=================== + +Pylytics is tested against MySQL 5.5 and 5.6. + +If you are running MySQL 5.6, make sure the server is configured as following:: + + explicit_defaults_for_timestamp=OFF + +This is the default setting for MySQL 5.6, however some cloud providers have it set differently. From 49d0ab32d57ae060ff196e19e3098a7d06803dbf Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 26 Nov 2014 15:15:45 +0000 Subject: [PATCH 3/3] adding test back --- test/unit/library/test_dimension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/library/test_dimension.py b/test/unit/library/test_dimension.py index d0670ad..d875415 100644 --- a/test/unit/library/test_dimension.py +++ b/test/unit/library/test_dimension.py @@ -32,7 +32,7 @@ def null_store(): return obj -class __TestEvolvingDimensions(object): +class TestEvolvingDimensions(object): def _fetch_store_row_count(self): connection = Warehouse.get()