feat: include can_inspect field in user configuration copy process and add corresponding test coverage
This commit is contained in:
parent
37500e1fbc
commit
1edfb85a0e
2 changed files with 30 additions and 3 deletions
|
|
@ -756,6 +756,7 @@ class UserConfigAdmin(admin.ModelAdmin):
|
||||||
can_view_assets=ut.can_view_assets,
|
can_view_assets=ut.can_view_assets,
|
||||||
can_edit_assets=ut.can_edit_assets,
|
can_edit_assets=ut.can_edit_assets,
|
||||||
can_validate_assets=ut.can_validate_assets,
|
can_validate_assets=ut.can_validate_assets,
|
||||||
|
can_inspect=ut.can_inspect,
|
||||||
can_view_interventions=ut.can_view_interventions,
|
can_view_interventions=ut.can_view_interventions,
|
||||||
can_edit_interventions=ut.can_edit_interventions,
|
can_edit_interventions=ut.can_edit_interventions,
|
||||||
can_edit_locations=ut.can_edit_locations,
|
can_edit_locations=ut.can_edit_locations,
|
||||||
|
|
@ -876,6 +877,7 @@ class UserConfigAdmin(admin.ModelAdmin):
|
||||||
can_view_assets=ut.can_view_assets,
|
can_view_assets=ut.can_view_assets,
|
||||||
can_edit_assets=ut.can_edit_assets,
|
can_edit_assets=ut.can_edit_assets,
|
||||||
can_validate_assets=ut.can_validate_assets,
|
can_validate_assets=ut.can_validate_assets,
|
||||||
|
can_inspect=ut.can_inspect,
|
||||||
can_view_interventions=ut.can_view_interventions,
|
can_view_interventions=ut.can_view_interventions,
|
||||||
can_edit_interventions=ut.can_edit_interventions,
|
can_edit_interventions=ut.can_edit_interventions,
|
||||||
can_edit_locations=ut.can_edit_locations,
|
can_edit_locations=ut.can_edit_locations,
|
||||||
|
|
|
||||||
|
|
@ -282,9 +282,34 @@ class AssetsIndexPreferencesTests(TestCase):
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertFalse(response.context["has_url_thematics"])
|
self.assertFalse(response.context["has_url_thematics"])
|
||||||
self.assertEqual(response.context["selected_thematics"], ["sign", "roads"])
|
self.assertEqual(response.context["selected_thematics"], ["sign", "roads"])
|
||||||
saved_prefs = json.loads(response.context["assets_index_prefs_json"])
|
|
||||||
self.assertEqual(saved_prefs["thematics"], ["sign", "roads"])
|
|
||||||
self.assertEqual(saved_prefs["validation_status_filters"], ["validated"])
|
|
||||||
|
class UserConfigCopyTests(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
from common.models import Thematic, UserThematics
|
||||||
|
self.user_source = User.objects.create_user(username="source_user", password="password123")
|
||||||
|
self.user_target = User.objects.create_user(username="target_user", password="password123")
|
||||||
|
self.config_source = UserConfig.objects.create(user=self.user_source)
|
||||||
|
self.config_target = UserConfig.objects.create(user=self.user_target)
|
||||||
|
self.thematic, _ = Thematic.objects.get_or_create(code="parking", defaults={"name_fr": "Stationnement"})
|
||||||
|
|
||||||
|
UserThematics.objects.create(
|
||||||
|
user_config=self.config_source,
|
||||||
|
thematic=self.thematic,
|
||||||
|
can_view_assets=True,
|
||||||
|
can_inspect=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_copy_config_copies_can_inspect(self):
|
||||||
|
from common.admin import UserConfigAdmin
|
||||||
|
from common.models import UserThematics
|
||||||
|
admin_obj = UserConfigAdmin(UserConfig, None)
|
||||||
|
admin_obj._copy_config(self.config_source, self.config_target)
|
||||||
|
|
||||||
|
target_ut = UserThematics.objects.get(user_config=self.config_target, thematic=self.thematic)
|
||||||
|
self.assertTrue(target_ut.can_inspect)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue