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 )
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 )
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])
def test_get_get_subrecord_from_api_name(self): hatwearer_api_name = HatWearer.get_api_name() famous_api_name = FamousLastWords.get_api_name() self.assertEqual( HatWearer, subrecords.get_subrecord_from_api_name(hatwearer_api_name)) self.assertEqual( FamousLastWords, subrecords.get_subrecord_from_api_name(famous_api_name))
def test_verbose_name(self): only_words = FamousLastWords._get_field_title("words") self.assertEqual(only_words, "Only Words")