Beispiel #1
0
 def test_save_same_record_twice(self):
     start = KennelDataModel('kennel1',
                             name=self.name,
                             acronym=self.acronym)
     start.save()
     start.save()
     self.assertTrue(KennelDataModel.record_exists(start))
Beispiel #2
0
 def test_matching_record_not_filtering_self(self):
     kennel = KennelDataModel(self.kennel_id,
                              name=self.name,
                              acronym=self.acronym)
     kennel.save()
     self.assertListEqual(KennelDataModel.matching_records(kennel, False),
                          [kennel])
Beispiel #3
0
 def test_matching_record_by_name(self):
     kennel = KennelDataModel(self.kennel_id,
                              name=self.name,
                              acronym=self.acronym)
     kennel.save()
     kennel2 = KennelDataModel('new_id', name=self.name, acronym='ABCH3')
     with self.assertRaises(AlreadyExists):
         kennel2.save()
Beispiel #4
0
 def test_timestamps(self):
     time = datetime.now(timezone.utc)
     with freeze_time(time):
         kennel = KennelDataModel(self.kennel_id,
                                  name=self.name,
                                  acronym=self.acronym)
         kennel.save()
         self.assertEqual(kennel.modified_at, time)
         self.assertEqual(kennel.created_at, time)
Beispiel #5
0
 def test_on_save_searchable_acronym(self):
     k = KennelDataModel(self.kennel_id,
                         name=self.name,
                         acronym=self.acronym)
     new_acronym = 'CKH3'
     k.acronym = new_acronym
     k.save()
     k.refresh()
     self.assertEqual(k.searchable_acronym, k.searchable_value(new_acronym))
Beispiel #6
0
 def test_on_save_searchable_name(self):
     k = KennelDataModel(self.kennel_id,
                         name=self.name,
                         acronym=self.acronym)
     new_name = 'Cheese'
     k.name = new_name
     k.save()
     k.refresh()
     self.assertEqual(k.searchable_name, k.searchable_value(new_name))
Beispiel #7
0
 def test_update_searchable_acronym(self):
     k = KennelDataModel(self.kennel_id,
                         name=self.name,
                         acronym=self.acronym)
     k.save()
     new_acronym = 'CHEH3'
     k.add_update_action('acronym', 'set', new_acronym)
     k.update()
     k.refresh()
     self.assertEqual(k.searchable_acronym, k.searchable_value(new_acronym))
Beispiel #8
0
 def test_update_searchable_name(self):
     k = KennelDataModel(self.kennel_id,
                         name=self.name,
                         acronym=self.acronym)
     k.save()
     new_name = 'Cheese'
     k.add_update_action('name', 'set', new_name)
     k.update()
     k.refresh()
     self.assertEqual(k.searchable_name, k.searchable_value(new_name))
Beispiel #9
0
 def test_matching_records_multiple_close_matches(self):
     KennelDataModel(self.kennel_id, name=self.name,
                     acronym=self.acronym).save()
     kennel = KennelDataModel('different_id',
                              name='Thinking Kennel',
                              acronym=self.acronym)
     kennel.save()
     KennelDataModel('different_id_2',
                     name='Throwing Kennel',
                     acronym=self.acronym).save()
     match = KennelDataModel('match_kennel',
                             name='Thinking Kennel',
                             acronym=self.acronym)
     x = KennelDataModel.matching_records(match)
     self.assertListEqual(x, [kennel])
Beispiel #10
0
 def test_record_exists(self):
     kennel = KennelDataModel(self.kennel_id,
                              name=self.name,
                              acronym=self.acronym)
     kennel.save()
     self.assertTrue(KennelDataModel.record_exists(kennel))
Beispiel #11
0
 def test_id_required(self):
     kennel = KennelDataModel(name=self.name, acronym=self.acronym)
     with self.assertRaises(ValueError):
         kennel.save()