Code Duplication    Length = 48-48 lines in 2 locations

backend/tracim_backend/tests/functional/test_user.py 2 locations

@@ 3226-3273 (lines=48) @@
3223
            params=params,
3224
        )
3225
3226
    def test_api__create_user__err_403__other_user(self):
3227
        dbsession = get_tm_session(self.session_factory, transaction.manager)
3228
        admin = dbsession.query(models.User) \
3229
            .filter(models.User.email == '[email protected]') \
3230
            .one()
3231
        uapi = UserApi(
3232
            current_user=admin,
3233
            session=dbsession,
3234
            config=self.app_config,
3235
        )
3236
        gapi = GroupApi(
3237
            current_user=admin,
3238
            session=dbsession,
3239
            config=self.app_config,
3240
        )
3241
        groups = [gapi.get_one_with_name('users')]
3242
        test_user = uapi.create_user(
3243
            email='[email protected]',
3244
            password='pass',
3245
            name='bob',
3246
            groups=groups,
3247
            timezone='Europe/Paris',
3248
            lang='fr',
3249
            do_save=True,
3250
            do_notify=False,
3251
        )
3252
        uapi.save(test_user)
3253
        transaction.commit()
3254
        self.testapp.authorization = (
3255
            'Basic',
3256
            (
3257
                '[email protected]',
3258
                'pass',
3259
            )
3260
        )
3261
        params = {
3262
            'email': '[email protected]',
3263
            'password': 'mysuperpassword',
3264
            'profile': 'users',
3265
            'timezone': 'Europe/Paris',
3266
            'public_name': 'test user',
3267
            'lang': 'fr',
3268
            'email_notification': False,
3269
        }
3270
        res = self.testapp.post_json(
3271
            '/api/v2/users',
3272
            status=403,
3273
            params=params,
3274
        )
3275
3276
@@ 3176-3223 (lines=48) @@
3173
        assert user.email == '[email protected]'
3174
        assert user.password
3175
3176
    def test_api__create_user__err_400__email_already_in_db(self):
3177
        dbsession = get_tm_session(self.session_factory, transaction.manager)
3178
        admin = dbsession.query(models.User) \
3179
            .filter(models.User.email == '[email protected]') \
3180
            .one()
3181
        uapi = UserApi(
3182
            current_user=admin,
3183
            session=dbsession,
3184
            config=self.app_config,
3185
        )
3186
        gapi = GroupApi(
3187
            current_user=admin,
3188
            session=dbsession,
3189
            config=self.app_config,
3190
        )
3191
        groups = [gapi.get_one_with_name('users')]
3192
        test_user = uapi.create_user(
3193
            email='[email protected]',
3194
            password='pass',
3195
            name='bob',
3196
            groups=groups,
3197
            timezone='Europe/Paris',
3198
            lang='fr',
3199
            do_save=True,
3200
            do_notify=False,
3201
        )
3202
        uapi.save(test_user)
3203
        transaction.commit()
3204
        self.testapp.authorization = (
3205
            'Basic',
3206
            (
3207
                '[email protected]',
3208
                '[email protected]'
3209
            )
3210
        )
3211
        params = {
3212
            'email': '[email protected]',
3213
            'password': 'mysuperpassword',
3214
            'profile': 'users',
3215
            'timezone': 'Europe/Paris',
3216
            'lang': 'fr',
3217
            'public_name': 'test user',
3218
            'email_notification': False,
3219
        }
3220
        res = self.testapp.post_json(
3221
            '/api/v2/users',
3222
            status=400,
3223
            params=params,
3224
        )
3225
3226
    def test_api__create_user__err_403__other_user(self):