Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julien Jerphanion
Rex Dri
Commits
f9b7200e
Commit
f9b7200e
authored
Aug 28, 2018
by
Florent Chehab
Browse files
Orthographe : Versionning => versioning
parent
f3cbb6c7
Changes
7
Hide whitespace changes
Inline
Side-by-side
backend/migrations/0021_auto_20180828_2128.py
0 → 100644
View file @
f9b7200e
# Generated by Django 2.0.3 on 2018-08-28 19:28
from
django.conf
import
settings
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'backend'
,
'0020_auto_20180827_1026'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'ForTestingVersionning'
,
new_name
=
'ForTestingVersioning'
,
),
]
backend/models/my_model/__init__.py
View file @
f9b7200e
...
...
@@ -4,4 +4,4 @@ from .myModelViewSet import MyModelViewSet # noqa: F401
from
.pendingModeration
import
PendingModeration
,
PendingModerationSerializer
,
PendingModerationViewSet
# noqa: F401
from
.forTestingModeration
import
ForTestingModeration
,
ForTestingModerationSerializer
,
ForTestingModerationViewSet
# noqa: F401
from
.myModelVersionned
import
MyModelVersionned
,
MyModelVersionnedSerializer
,
MyModelVersionnedViewSet
,
VersionViewSet
# noqa: F401
from
.forTestingVersion
n
ing
import
ForTestingVersion
n
ing
,
ForTestingVersion
n
ingSerializer
,
ForTestingVersion
n
ingViewSet
# noqa: F401
from
.forTestingVersioning
import
ForTestingVersioning
,
ForTestingVersioningSerializer
,
ForTestingVersioningViewSet
# noqa: F401
backend/models/my_model/forTestingVersion
n
ing.py
→
backend/models/my_model/forTestingVersioning.py
View file @
f9b7200e
...
...
@@ -4,7 +4,7 @@ import reversion
@
reversion
.
register
()
class
ForTestingVersion
n
ing
(
MyModelVersionned
):
class
ForTestingVersioning
(
MyModelVersionned
):
"""
Simple model for testing purposes
"""
...
...
@@ -12,21 +12,21 @@ class ForTestingVersionning(MyModelVersionned):
@
classmethod
def
get_serializer
(
cls
):
return
ForTestingVersion
n
ingSerializer
return
ForTestingVersioningSerializer
class
ForTestingVersion
n
ingSerializer
(
MyModelVersionnedSerializer
):
class
ForTestingVersioningSerializer
(
MyModelVersionnedSerializer
):
"""
Same as above
"""
class
Meta
:
model
=
ForTestingVersion
n
ing
model
=
ForTestingVersioning
fields
=
'__all__'
class
ForTestingVersion
n
ingViewSet
(
MyModelVersionnedViewSet
):
class
ForTestingVersioningViewSet
(
MyModelVersionnedViewSet
):
"""
Same as above
"""
serializer_class
=
ForTestingVersion
n
ingSerializer
queryset
=
ForTestingVersion
n
ing
.
objects
.
all
()
serializer_class
=
ForTestingVersioningSerializer
queryset
=
ForTestingVersioning
.
objects
.
all
()
backend/models/my_model/myModelVersionned.py
View file @
f9b7200e
...
...
@@ -14,7 +14,7 @@ class MyModelVersionned(MyModel):
def
get_serializer
(
cls
):
"""
This function is required for handling
version
n
ing easily.
versioning easily.
You have to put the correct value in each subclass
"""
raise
Exception
(
"Get_serializer must be redifined in subclass"
)
...
...
backend/tests/test_squash_versions.py
View file @
f9b7200e
from
backend.models.my_model
import
ForTestingVersion
n
ing
from
backend.models.my_model
import
ForTestingVersioning
from
reversion.models
import
Version
from
backend.signals
import
squashRevisionByUser
import
reversion
...
...
@@ -9,7 +9,7 @@ import json
class
SquashVersionsTestCase
(
WithUserTestCase
):
def
setUp
(
self
):
self
.
obj
=
ForTestingVersion
n
ing
(
bbb
=
"v1"
)
self
.
obj
=
ForTestingVersioning
(
bbb
=
"v1"
)
with
reversion
.
create_revision
():
self
.
obj
.
save
()
reversion
.
set_user
(
self
.
authenticated_user
)
...
...
backend/tests/test_versionning.py
View file @
f9b7200e
from
.withUserTestCase
import
WithUserTestCase
from
backend.models.my_model
import
ForTestingVersion
n
ing
from
backend.models.my_model
import
ForTestingVersioning
from
django.conf
import
settings
from
reversion.models
import
Version
from
backend.signals
import
new_revision_saved
from
django.test
import
override_settings
class
Version
n
ingTestCase
(
WithUserTestCase
):
class
VersioningTestCase
(
WithUserTestCase
):
@
classmethod
def
setUpMoreTestData
(
cls
):
cls
.
testing_model
=
ForTestingVersion
n
ing
cls
.
api_version
n
ing
=
'/api/test/version
n
ing/'
cls
.
testing_model
=
ForTestingVersioning
cls
.
api_versioning
=
'/api/test/versioning/'
def
reset_signal_called
(
self
):
self
.
signal_was_called
=
False
...
...
@@ -23,7 +23,7 @@ class VersionningTestCase(WithUserTestCase):
def
_submit_put_test
(
self
,
client
,
data
,
pk
):
response
=
client
.
put
(
self
.
api_version
n
ing
+
str
(
pk
)
+
'/'
,
self
.
api_versioning
+
str
(
pk
)
+
'/'
,
data
,
format
=
'json'
)
...
...
@@ -40,9 +40,9 @@ class VersionningTestCase(WithUserTestCase):
####
@
override_settings
(
MODERATION_ACTIVATED
=
False
)
def
test_version
n
ing
(
self
):
def
test_versioning
(
self
):
"""
Test to check that version
n
ing is working
Test to check that versioning is working
We also check that new_revision_saved is called
"""
...
...
@@ -53,7 +53,7 @@ class VersionningTestCase(WithUserTestCase):
data_1
=
{
'bbb'
:
"Test 1"
}
response
=
self
.
authenticated_client
.
post
(
self
.
api_version
n
ing
,
self
.
api_versioning
,
data_1
,
format
=
'json'
)
...
...
@@ -67,7 +67,7 @@ class VersionningTestCase(WithUserTestCase):
data_2
=
{
'bbb'
:
"Test 2"
}
response
=
self
.
authenticated_client_2
.
put
(
self
.
api_version
n
ing
+
str
(
instance
.
pk
)
+
'/'
,
self
.
api_versioning
+
str
(
instance
.
pk
)
+
'/'
,
data_2
,
format
=
'json'
)
...
...
backend/urls.py
View file @
f9b7200e
...
...
@@ -68,9 +68,9 @@ router = routers.DefaultRouter()
if
settings
.
TESTING
:
from
backend.models.my_model
import
ForTestingModerationViewSet
from
backend.models.my_model
import
ForTestingVersion
n
ingViewSet
from
backend.models.my_model
import
ForTestingVersioningViewSet
router
.
register
(
r
'test/moderation'
,
ForTestingModerationViewSet
)
router
.
register
(
r
'test/version
n
ing'
,
ForTestingVersion
n
ingViewSet
)
router
.
register
(
r
'test/versioning'
,
ForTestingVersioningViewSet
)
router
.
register
(
r
'country'
,
CountryViewSet
)
router
.
register
(
r
'city'
,
CityViewSet
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment