def test_person_model_get_all_objects(self):
     person1 = self.person.copy()
     person2 = self.person.copy()
     del person1['uuid']
     del person2['uuid']
     Person.load(**person1).save()
     Person.load(**person2).save()
     self.assertEqual(len(Person.get_all()), 2)
 def test_person_model_refresh_object(self):
     person = Person.load(**self.person)
     person.save()
     person.name = 'Tom'
     self.assertEqual(person.name, 'Tom')
     person.refresh()
     self.assertEqual(person.name, self.person['name'])
 def test_person_model_load_object(self):
     person = Person.load(**self.person)
     self.assertEqual(person.uuid, self.person['uuid'])
     self.assertEqual(person.age, self.person['age'])
     self.assertEqual(person.sex, self.person['sex'])
     self.assertEqual(person.fare, self.person['fare'])
     self.assertEqual(person.name, self.person['name'])
     self.assertEqual(person.survived, self.person['survived'])
     self.assertEqual(person.passenger_class, self.person['passengerClass'])
     self.assertEqual(person.siblings_or_spouses_aboard,
                      self.person['siblingsOrSpousesAboard'])
     self.assertEqual(person.parents_or_children_aboard,
                      self.person['parentsOrChildrenAboard'])
 def test_person_model_validate_name(self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_name('name', None)
 def test_person_model_validate_passenger_class_incorrect_value(self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_passenger_class('passenger_class', '1')
 def test_person_model_validate_passenger_class_with_none(self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_passenger_class('passenger_class', None)
 def test_person_model_str_representation(self):
     person = Person.load(**self.person)
     self.assertEqual(str(person), person.name)
 def test_person_model_repr_representation(self):
     person = Person.load(**self.person)
     self.assertEqual(repr(person), f'<Person {person.name}>')
 def test_person_model_dump_object(self):
     p = Person.load(**self.person)
     data = p.dump()
     self.assertDictContainsSubset(data, self.person)
 def test_person_model_delete_object(self):
     person = Person.load(**self.person)
     person.save()
     self.assertEqual(Person.query.count(), 1)
     person.delete()
     self.assertEqual(Person.query.count(), 0)
 def test_person_model_update_object_bad_value(self):
     person = Person.load(**self.person)
     person.update(**{'surname': 'Bombs'})
     self.assertFalse(hasattr(person, 'surname'))
 def test_person_model_update_object(self):
     person = Person.load(**self.person)
     person.update(**{'name': 'Alex'})
     self.assertEqual(person.name, 'Alex')
 def test_person_model_validate_fare_incorrect_value(self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_fare('fare', 1)
 def test_person_model_validate_parents_or_children_aboard_incorrect_value(
         self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_parents_or_children_aboard(
             'parents_or_children_aboard', '1')
 def test_person_model_validate_siblings_or_spouses_aboard_incorrect_value(
         self):
     person = Person.load(**self.person)
     with self.assertRaises(AssertionError):
         person.validate_siblings_or_spouses_aboard(
             'siblings_or_spouses_aboard', '1')