Ejemplo n.º 1
0
    def test_no_log_message_when_no_change(self):
        form = ScenerEditRealNameForm({
            'first_name': 'Matt', 'surname': 'Westcott',
            'real_name_note': "",
        }, instance=self.scener)
        self.assertTrue(form.is_valid())
        form.save()
        self.assertEqual(self.scener.surname, 'Westcott')

        form.log_edit(self.user)
        log_entry = Edit.objects.filter(
            action_type='edit_scener_real_name',
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=self.scener.id
        )
        self.assertFalse(log_entry)
Ejemplo n.º 2
0
    def test_edit(self):
        form = ScenerEditRealNameForm({
            'first_name': 'Matt', 'surname': 'Westcottski',
            'real_name_note': "he's feeling a bit shy",
        }, instance=self.scener)
        self.assertTrue(form.is_valid())
        form.save()
        self.assertEqual(self.scener.surname, 'Westcottski')

        form.log_edit(self.user)
        log_entry = Edit.objects.get(
            action_type='edit_scener_real_name',
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=self.scener.id
        )
        self.assertEqual(log_entry.user, self.user)
        self.assertEqual(log_entry.description, "Set real name")
Ejemplo n.º 3
0
    def test_log_message_when_name_unchanged(self):
        form = ScenerEditRealNameForm(
            {
                'first_name': 'Matt',
                'surname': 'Westcott',
                'show_first_name': 'true',
                'real_name_note': "he's feeling a bit shy",
            },
            instance=self.scener)
        self.assertTrue(form.is_valid())
        form.save()
        self.assertEqual(self.scener.surname, 'Westcott')
        self.assertFalse(self.scener.show_surname)

        form.log_edit(self.user)
        log_entry = Edit.objects.get(
            action_type='edit_scener_real_name',
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=self.scener.id)
        self.assertEqual(log_entry.user, self.user)
        self.assertEqual(log_entry.description,
                         "Updated visibility of real name")