Exemplo n.º 1
0
def person_read(account_id, identifier):
    try:
        dao = PersonDao(content, account_id)
        person = dao.retrieve(identifier)
        return dao.get_schema().dumps(person, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))
Exemplo n.º 2
0
def person_list(account_id):
    try:
        dao = PersonDao(content, account_id)
        people = dao.find_all()
        return dao.get_schema().dumps(people, many=True, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))
Exemplo n.º 3
0
 def setUp(self):
     os.system("rm -rf ./test_content/*")
     self.account_dao = AccountDao(Path("./test_content"))
     trilogy = self.account_dao.load({
         'identifier': 1,
         'name': 'Trilogy Partners',
         'email': '*****@*****.**'
     })
     self.person_dao = PersonDao(Path("./test_content"), trilogy.identifier)
     self.account_dao.create(trilogy)
Exemplo n.º 4
0
def person_create(account_id):
    try:
        dao = PersonDao(content, account_id)
        person = dao.from_json(request.data)
        dao.create(person)
        person = dao.retrieve(person.identifier)
        return dao.get_schema().dumps(person, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))
Exemplo n.º 5
0
class TestPerson(unittest.TestCase):
    def setUp(self):
        os.system("rm -rf ./test_content/*")
        self.account_dao = AccountDao(Path("./test_content"))
        trilogy = self.account_dao.load({
            'identifier': 1,
            'name': 'Trilogy Partners',
            'email': '*****@*****.**'
        })
        self.person_dao = PersonDao(Path("./test_content"), trilogy.identifier)
        self.account_dao.create(trilogy)

    def test_create(self):
        fred = self.person_dao.load({
            'account_id': 1,
            'identifier': "fas",
            'surname': 'Smith',
            'first_names': 'Frederick Alexander',
            'address': '17 Constitution Ave, Canberra, ACT 2612',
            'email': '*****@*****.**',
            'phone': '+61234567273',
            'gender': 'MALE',
            'passport_no': 'P1234543212',
            'passport_country': 'Australia',
            'passport_issued': '2012-10-25',
            'passport_expiry': '2022-10-25',
            'skills': "",
            'blood_group': 'O+ve',
            'allergies': '',
            'medication': '',
            'quals': 'Yachtmaster, senior first aid'
            #      'nok_id=None,
            #      'nok_relationship=None,
            #      'next_flight_in=None,
            #      'next_flight_out=None,
        })
        self.person_dao.create(fred)
        x = self.person_dao.retrieve('fas')
        self.assertEqual(type(x.identifier), type(fred.identifier))
        self.assertEqual(x.identifier, fred.identifier)
Exemplo n.º 6
0
def person_update(account_id, identifier):
    try:
        dao = PersonDao(content, account_id)
        person = dao.retrieve(identifier)
        new_person = dao.from_json(request.data)
        if new_person.identifier != person.identifier:
            raise ValueError("Cannot change idenitifier from {} to {}".format(
                person.identifier, new_person.identifier))
        dao.save(new_person)
        return dao.get_schema().dumps(new_person, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))