瀏覽代碼

HUE-5295 [desktop] Avoid microsecond comparison for last_modified field
MySQL < 5.6 doesn't support microsecond precision. https://code.djangoproject.com/ticket/19716

krish 9 年之前
父節點
當前提交
ff8ba65cc2
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      desktop/core/src/desktop/converter_tests.py

+ 7 - 3
desktop/core/src/desktop/converter_tests.py

@@ -16,6 +16,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from datetime import datetime
 import json
 
 from nose.tools import assert_equal, assert_false, assert_true
@@ -68,6 +69,10 @@ class TestDocumentConverter(object):
     )
     doc = Document.objects.link(query, owner=query.owner, extra=query.type, name=query.name, description=query.desc)
 
+    # Setting doc.last_modified to older date
+    Document.objects.filter(id=doc.id).update(last_modified=datetime.strptime('2000-01-01T00:00:00Z', '%Y-%m-%dT%H:%M:%SZ'))
+    doc = Document.objects.get(id=doc.id)
+
     query2 = SavedQuery.objects.create(
         type=SavedQuery.TYPES_MAPPING['hql'],
         owner=self.user,
@@ -113,8 +118,7 @@ class TestDocumentConverter(object):
 
       # Verify default properties
       assert_true(doc2.data_dict['isSaved'])
-      assert_false(doc.last_modified == doc2.last_modified)
-
+      assert_false(doc.last_modified.strftime('%Y-%m-%dT%H:%M:%S') == doc2.last_modified.strftime('%Y-%m-%dT%H:%M:%S'))
 
       #
       # Query History
@@ -124,7 +128,7 @@ class TestDocumentConverter(object):
       # Verify Document2 attributes
       assert_equal(doch.name, doc2.data_dict['name'])
       assert_equal(doch.description, doc2.data_dict['description'])
-      assert_equal(doch.last_modified, doc2.last_modified)
+      assert_equal(doch.last_modified.strftime('%Y-%m-%dT%H:%M:%S'), doc2.last_modified.strftime('%Y-%m-%dT%H:%M:%S'))
 
       # Verify session type
       assert_equal('hive', doc2.data_dict['sessions'][0]['type'])