Ejemplo n.º 1
0
    def test_bulk_update_multiple_singletons_from_dict(self):
        patient = Patient.objects.create()
        famous_last_words = [
            {"words": "so long and thanks for all the fish"},
            {"words": "A towel is the most important item"},
        ]

        with self.assertRaises(ValueError):
            FamousLastWords.bulk_update_from_dicts(
                patient, famous_last_words, self.user
            )
Ejemplo n.º 2
0
    def test_bulk_update_singleton(self):
        patient = Patient.objects.create()
        famous_model = FamousLastWords.objects.get()
        famous_model.set_consistency_token()
        famous_model.save()

        famous_last_words = [
            {"words": "A towel is the most important item"},
        ]

        with self.assertRaises(exceptions.MissingConsistencyTokenError):
            FamousLastWords.bulk_update_from_dicts(
                patient, famous_last_words, self.user
            )
Ejemplo n.º 3
0
    def test_bulk_update_singleton_with_force(self):
        patient = Patient.objects.create()
        famous_model = FamousLastWords.objects.get()
        famous_model.set_consistency_token()
        famous_model.save()

        famous_last_words = [
            {"words": "A towel is the most important item"},
        ]

        FamousLastWords.bulk_update_from_dicts(
            patient, famous_last_words, self.user, force=True
        )

        result = FamousLastWords.objects.get()
        self.assertEqual(result.words, list(famous_last_words[0].values())[0])