def test_auditlog_user(self): LucteriosAuditlogModelRegistry.set_state_packages(['CORE']) self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 0) self.factory.xfer = GroupsList() self.calljson('/CORE/groupsList', {}, False) self.assert_count_equal('group', 0) self.factory.xfer = GroupsEdit() self.calljson('/CORE/groupsEdit', { 'SAVE': 'YES', 'name': 'truc', 'permissions': '7;9;13' }, False) self.assert_observer('core.acknowledge', 'CORE', 'groupsEdit') self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosuser'}, False) self.assert_count_equal('lucterioslogentry', 1) self.factory.xfer = GroupsDelete() self.calljson('/CORE/groupsDelete', { 'group': '1', "CONFIRME": 'YES' }, False) self.assert_observer('core.acknowledge', 'CORE', 'groupsDelete') self.factory.xfer = AudiLogConfig() self.calljson('/CORE/audiLogConfig', {'type_selected': 'CORE.lucteriosgroup'}, False) self.assert_count_equal('lucterioslogentry', 2) self.assert_json_equal('', 'lucterioslogentry/@0/action', 2) self.assert_json_equal('', 'lucterioslogentry/@0/object_repr', "truc") self.assert_json_equal('', 'lucterioslogentry/@1/action', 0) self.assert_json_equal('', 'lucterioslogentry/@1/object_repr', "truc")
def test_useraddsave(self): groups = LucteriosGroup.objects.all() self.assertEqual(len(groups), 0) self.factory.xfer = GroupsEdit() self.calljson('/CORE/groupsEdit', { 'SAVE': 'YES', 'name': 'newgroup', "permissions": '1;3;5;7' }, False) self.assert_observer('core.acknowledge', 'CORE', 'groupsEdit') self.assertEqual(len(self.json_context), 2) self.assertEqual(self.json_context["name"], 'newgroup') self.assertEqual(self.json_context["permissions"], '1;3;5;7') groups = LucteriosGroup.objects.all() self.assertEqual(len(groups), 1) self.assertEqual(groups[0].name, "newgroup") perm = groups[0].permissions.all().order_by('id') self.assertEqual(len(perm), 4) self.assertEqual(perm[0].id, 1) self.assertEqual(perm[1].id, 3) self.assertEqual(perm[2].id, 5) self.assertEqual(perm[3].id, 7)
def test_groupedit_notexist(self): self.factory.xfer = GroupsEdit() self.calljson('/CORE/groupsEdit', {'group': '50'}, False) self.assert_observer('core.exception', 'CORE', 'groupsEdit') self.assert_json_equal('', 'message', six.text_type("Cet enregistrement n'existe pas!\nVeuillez rafraichir votre application.")) self.assert_json_equal('', 'code', '3')