Example #1
0
    def test_concurentedit(self):
        user1 = add_user("user1")
        user1.is_superuser = True
        user1.save()
        grp = LucteriosGroup.objects.create(name="mygroup")
        grp.save()

        self.calljson('/CORE/authentification', {'username': '******', 'password': '******'})
        self.assert_observer('core.auth', 'CORE', 'authentification')
        self.assert_json_equal('', '', 'OK')

        self.calljson('/CORE/groupsEdit', {'group': '1'})
        self.assert_observer('core.custom', 'CORE', 'groupsEdit')
        self.assert_action_equal(self.response_json['close'], ('unlock', None, "CORE", "unlock", 1, 1, 1))
        self.assertEqual(len(self.json_context), 2)
        self.assertEqual(self.json_context["group"], '1')
        self.assertEqual(self.json_context["LOCK_IDENT"], 'lucterios.CORE.models-LucteriosGroup-1')

        new_test = LucteriosTest("setUp")
        new_test.setUp()
        new_test.calljson('/CORE/authentification', {'username': '******', 'password': '******'})
        new_test.assert_observer('core.auth', 'CORE', 'authentification')
        new_test.assert_json_equal('', '', 'OK')

        new_test.calljson('/CORE/groupsEdit', {'group': '1'})
        new_test.assert_observer('core.exception', 'CORE', 'groupsEdit')
        new_test.assert_json_equal('', 'message', six.text_type("Enregistrement verrouillé par 'admin'!"))
        new_test.assert_json_equal('', 'code', '3')

        self.calljson('/CORE/exitConnection', {})

        new_test.calljson('/CORE/groupsEdit', {'group': '1'})
        new_test.assert_observer('core.custom', 'CORE', 'groupsEdit')
Example #2
0
    def test_concurentedit(self):
        user1 = add_user("user1")
        user1.is_superuser = True
        user1.save()

        self.calljson('/CORE/authentification', {'username': '******', 'password': '******'})
        self.assert_observer('core.auth', 'CORE', 'authentification')
        self.assert_json_equal('', '', 'OK')

        self.calljson('/CORE/usersEdit', {'user_actif': '3'})
        self.assert_observer('core.custom', 'CORE', 'usersEdit')
        self.assertEqual(len(self.json_actions), 3)
        self.assert_action_equal(self.response_json['close'], ('unlock', None, "CORE", "unlock", 1, 1, 1))
        self.assertEqual(len(self.json_context), 2)
        self.assertEqual(self.json_context["user_actif"], '3')
        self.assertEqual(self.json_context["LOCK_IDENT"], 'lucterios.CORE.models-LucteriosUser-3')

        new_test = LucteriosTest("setUp")
        new_test.setUp()
        new_test.calljson('/CORE/authentification', {'username': '******', 'password': '******'})
        new_test.assert_observer('core.auth', 'CORE', 'authentification')
        new_test.assert_json_equal('', '', 'OK')

        new_test.calljson('/CORE/usersEdit', {'user_actif': '3'})
        new_test.assert_observer('core.exception', 'CORE', 'usersEdit')
        new_test.assert_json_equal('', 'message', six.text_type("Enregistrement verrouillé par 'admin'!"))
        new_test.assert_json_equal('', 'code', '3')

        self.calljson('/CORE/unlock', {'user_actif': '3', "LOCK_IDENT": 'lucterios.CORE.models-LucteriosUser-3'})
        self.assert_observer('core.acknowledge', 'CORE', 'unlock')

        new_test.calljson('/CORE/usersEdit', {'user_actif': '3'})
        new_test.assert_observer('core.custom', 'CORE', 'usersEdit')