Add 1 seconds delay to avoid version revert tests failing on MySQL. This is because MySQL doesn't store milliseconds in the DB. Version revert uses timestamp as the original document and the new version are created within the same second the revert code doesn't work. This delay is a hack and a better solution to differentiate versions by serial or similar needs to be implemented.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import time
|
||||
|
||||
from json import loads
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
@@ -205,13 +207,16 @@ class DocumentAPITestCase(APITestCase):
|
||||
file_object=File(file_object),
|
||||
)
|
||||
|
||||
# Needed by MySQL as milliseconds value is not store in timestamp field
|
||||
time.sleep(1)
|
||||
|
||||
with open(TEST_DOCUMENT_PATH) as file_object:
|
||||
document.new_version(file_object=File(file_object))
|
||||
|
||||
document_version = document.versions.first()
|
||||
|
||||
self.assertEqual(document.versions.count(), 2)
|
||||
|
||||
document_version = document.versions.first()
|
||||
|
||||
self.client.post(
|
||||
reverse(
|
||||
'rest_api:documentversion-revert', args=(document_version.pk,)
|
||||
|
||||
Reference in New Issue
Block a user