def setUp(self):
     self.testDict['name'] = Name(self.testName)
     self.testDict['address'] = Location(self.testLocation)
     self.testDict['contact'] = Contact(self.testContact)
     self.testDict['otherContact'] = OtherContact(self.testOtherContact)
     self.testDict['otherInfo'] = OtherInfo(self.testOtherInfo)
     self.testDict['login'] = LoginInfo(self.testLoginInfo)
     self.customerFromDict = Customer(self.testDict)
     self.customerDefaults = Customer()
     self.maxDiff = None
 def setUp(self):
     custBooking = {
         'customerKey':
         '00000000',
         'customerName':
         Name(self.testCustName),
         'customerAddr':
         Location(self.testCustLocation),
         'customerContact':
         Contact(self.testCustContact),
         'custParty': [
             CustParty({
                 'name': Name(self.testCustPartyName1),
                 'other': OtherInfo(self.testOtherInfo1)
             }),
             CustParty({
                 'name': Name(self.testCustPartyName2),
                 'other': OtherInfo(self.testOtherInfo2)
             })
         ]
     }
     propBooking = {
         'propertyKey': 'ZZZZ9999',
         'propertyName': 'The Slate Resort',
         'propertyAddr': Location(self.testPropLocation),
         'propertyContact': Contact(self.testPropContact),
     }
     self.testDict = {
         'bookingKey': '20190501AAAA1111',
         'customer': custBooking,
         'property': propBooking,
         'bookingInfo': BookingInfo(self.testBookingInfo),
         'rooms': [RoomBooking(self.testRoomBooking)],
         'totalPrice': 999.99
     }
     self.bookingFromDict = Booking(self.testDict)
     self.bookingDefaults = Booking()
     self.maxDiff = None
class TestCustomer(unittest.TestCase):

    customerFromDict = None
    customerDefaults = None

    testDict = {
        'customerKey': '00000000',
        'name': Name(),
        'address': Location(),
        'contact': Contact(),
        'otherContact': OtherContact(),
        'otherInfo': OtherInfo(),
        'login': LoginInfo(),
        'totalBooked': 100,
        'discount': 0.05
    }

    testLocation = {
        'streetAddress': '123 Main Street',
        'buildingName': '',
        'floor': '',
        'roomAptCondoFlat': '',
        'city': 'Bedrock',
        'stateProvince': 'ZZ',
        'locality': 'Unknown',
        'country': 'None',
        'postalCode': '00000',
        'latitude': '+111.111',
        'longitude': '-111.111'
    }

    testName = {
        'title': 'Mr',
        'first': 'Fred',
        'middle': 'Folsom',
        'last': 'Flintstone',
        'suffix': 'CM'
    }

    testContact = {
        'email': '*****@*****.**',
        'phone': '+0-000-000-0000',
        'socMedia': {
            'google': '*****@*****.**'
        }
    }

    testOtherContact = {
        'emails': ['*****@*****.**', '*****@*****.**'],
        'phoneNumbers': [{
            'home': '000-000-0000'
        }, {
            'work': '111-111-1111'
        }],
        'socMedias': [{
            'google': '*****@*****.**'
        }, {
            'skype': 'fflintstone'
        }]
    }

    testOtherInfo = {'gender': 'M', 'dateOfBirth': '0000-01-01'}

    testLoginInfo = {
        'username': '******',
        'oauth2': '*****@*****.**',
        'password': '******'
    }

    testJson = '''{
        "customerKey"  : "00000000",
        "address"     : {
            "streetAddress"    : "123 Main Street",
            "buildingName"     : "",
            "floor"            : "",
            "roomAptCondoFlat" : "",
            "city"             : "Bedrock",
            "stateProvince"    : "ZZ",
            "locality"         : "Unknown",
            "country"          : "None",
            "postalCode"       : "00000",
            "latitude"         : "+111.111",
            "longitude"        : "-111.111"
        },
        "name" : {
            "title"  : "Mr",
            "first"  : "Fred",
            "middle" : "Folsom",
            "last"   : "Flintstone",
            "suffix" : "CM"
        },
        "contact" : {
            "email"    : "*****@*****.**",
            "phone"    : "+0-000-000-0000",
            "socMedia" : {"google" : "*****@*****.**"}
        },
        "otherContact" : {
            "emails"       : ["*****@*****.**", "*****@*****.**"],
            "phoneNumbers" : [{"home" : "000-000-0000"}, {"work" : "111-111-1111"}],
            "socMedias"    : [{"google" : "*****@*****.**"}, {"skype" : "fflintstone"}]
        },
        "otherInfo" : {
            "gender"      : "M",
            "dateOfBirth" : "0000-01-01"
        },
        "login" : {
            "username" : "fred",
            "oauth2"   : "*****@*****.**",
            "password" : "abcdefghijklmnopqrstuvwxyz"
        },
        "totalBooked"  : 100,
        "discount"     : 0.05
    }'''

    def setUp(self):
        self.testDict['name'] = Name(self.testName)
        self.testDict['address'] = Location(self.testLocation)
        self.testDict['contact'] = Contact(self.testContact)
        self.testDict['otherContact'] = OtherContact(self.testOtherContact)
        self.testDict['otherInfo'] = OtherInfo(self.testOtherInfo)
        self.testDict['login'] = LoginInfo(self.testLoginInfo)
        self.customerFromDict = Customer(self.testDict)
        self.customerDefaults = Customer()
        self.maxDiff = None

    def test_customer_key(self):
        expected = '00000000'
        actual = self.customerFromDict.getKey()
        self.assertEqual(expected, actual)

    def test_customer_from_dict(self):
        expected = 'Flintstone'
        name = self.customerFromDict.get('name')
        actual = name.get('last')
        self.assertEqual(expected, actual)

    def test_customer_from_blank(self):
        expected = True
        actual = isinstance(self.customerDefaults.get('address'), Location)
        self.assertEqual(expected, actual)

    def test_customer_from_dict_to_json(self):
        expected = json.loads(self.testJson)
        actual = json.loads(self.customerFromDict.toJson())
        self.assertEqual(expected, actual)
class TestBooking(unittest.TestCase):

    bookingFromDict = None
    bookingDefaults = None

    testDict = {
        'bookingKey': '20190501AAAA1111',
        'customer': CustBooking(),
        'property': PropBooking(),
        'bookingInfo': BookingInfo(),
        'rooms': [],
        'totalPrice': 999.99
    }

    testCustBooking = {
        'customerKey': '00000000',
        'customerName': Name(),
        'customerAddr': Location(),
        'customerContact': Contact(),
        'custParty': []
    }

    testCustName = {
        'title': 'Ms',
        'first': 'Wilma',
        'middle': 'Slaghoople',
        'last': 'Flintstone',
        'suffix': ''
    }

    testCustLocation = {
        'streetAddress': '345 Cave Stone Road',
        'buildingName': '',
        'floor': '',
        'roomAptCondoFlat': '',
        'city': 'Bedrock',
        'stateProvince': 'ZZ',
        'locality': 'Unknown',
        'country': 'None',
        'postalCode': '00000',
        'latitude': '+111.1111',
        'longitude': '-111.1111'
    }

    testCustContact = {
        'email': '*****@*****.**',
        'phone': '+0-000-000-0000',
        'socMedia': {
            'google': '*****@*****.**'
        }
    }

    testCustParty: [{
        'name': Name(),
        'other': OtherInfo()
    }, {
        'name': Name(),
        'other': OtherInfo()
    }]

    testCustPartyName1 = {
        'title': 'Mr',
        'first': 'Frederick',
        'middle': 'Joseph',
        'last': 'Flintstone',
        'suffix': 'Caveman'
    }

    testCustPartyName2 = {
        'title': 'Baby',
        'first': 'Bam',
        'middle': 'Bam',
        'last': 'Flintstone',
        'suffix': ''
    }

    testOtherInfo1 = {'gender': 'M', 'dateOfBirth': '0000-00-00'}

    testOtherInfo2 = {'gender': 'M', 'dateOfBirth': '0030-01-01'}

    testPropBooking = {
        'propertyKey': 'ZZZZ9999',
        'propertyName': 'The Slate Resort',
        'propertyAddr': Location(),
        'propertyContact': Contact()
    }

    testPropLocation = {
        'streetAddress': '140 Boulder Avenue',
        'buildingName': 'The Slate Resort',
        'floor': '',
        'roomAptCondoFlat': '',
        'city': 'Granite Town',
        'stateProvince': 'XX',
        'locality': 'Unknown',
        'country': 'None',
        'postalCode': '00001',
        'latitude': '+222.2222',
        'longitude': '-222.2222'
    }

    testPropContact = {
        'email': '*****@*****.**',
        'phone': '+0-000-000-0000',
        'socMedia': {
            'google': '*****@*****.**'
        }
    }

    testBookingInfo = {
        'arrivalDate': '0040-03-15',
        'departureDate': '0040-04-01',
        'checkoutTime': '12:00',
        'refundableUntil': '0040-03-28',
        'reservationStatus': 'pending',
        'paymentStatus': 'pending'
    }

    testRoomBooking = {
        'roomType': 'poolside',
        'roomTypeKey': '0001',
        'price': 99.99,
        'qty': 1
    }

    testJson = '''{
        "bookingKey" : "20190501AAAA1111",
        "customer"   : {
            "customerKey"    : "00000000",
            "customerName"   : {
                "title"  : "Ms",
                "first"  : "Wilma",
                "middle" : "Slaghoople",
                "last"   : "Flintstone",
                "suffix" : ""
            },
            "customerAddr"    : {
                "streetAddress"    : "345 Cave Stone Road",
                "buildingName"     : "",
                "floor"            : "",
                "roomAptCondoFlat" : "",
                "city"             : "Bedrock",
                "stateProvince"    : "ZZ",
                "locality"         : "Unknown",
                "country"          : "None",
                "postalCode"       : "00000",
                "latitude"         : "+111.1111",
                "longitude"        : "-111.1111"
            },
            "customerContact" : {
                "email"    : "*****@*****.**",
                "phone"    : "+0-000-000-0000",
                "socMedia" : {"google" : "*****@*****.**"}
            },
            "custParty"       : [
                {
                    "name"  : {
                        "title"  : "Mr",
                        "first"  : "Frederick",
                        "middle" : "Joseph",
                        "last"   : "Flintstone",
                        "suffix" : "Caveman"
                    },
                    "other" : {
                        "gender"      : "M",
                        "dateOfBirth" : "0000-00-00"
                    }
                },
                {
                    "name" : {
                            "title"  : "Baby",
                            "first"  : "Bam",
                            "middle" : "Bam",
                            "last"   : "Flintstone",
                            "suffix" : ""
                    },
                    "other" : {
                        "gender"      : "M",
                        "dateOfBirth" : "0030-01-01"
                    }
                }
            ]
        },
        "property" : {
            "propertyKey"  : "ZZZZ9999",
            "propertyName" : "The Slate Resort",
            "propertyAddr" : {
                "streetAddress"    : "140 Boulder Avenue",
                "buildingName"     : "The Slate Resort",
                "floor"            : "",
                "roomAptCondoFlat" : "",
                "city"             : "Granite Town",
                "stateProvince"    : "XX",
                "locality"         : "Unknown",
                "country"          : "None",
                "postalCode"       : "00001",
                "latitude"         : "+222.2222",
                "longitude"        : "-222.2222"
            },
            "propertyContact" : {
                "email"    : "*****@*****.**",
                "phone"    : "+0-000-000-0000",
                "socMedia" : {"google" : "*****@*****.**"}
            }
        },
        "bookingInfo"  : {
            "arrivalDate"       : "0040-03-15",
            "departureDate"     : "0040-04-01",
            "checkoutTime"      : "12:00",
            "refundableUntil"   : "0040-03-28",
            "reservationStatus" : "pending",
            "paymentStatus"     : "pending"
        },
        "rooms" : [
            {
                "roomType"    : "poolside",
                "roomTypeKey" : "0001",
                "price"       : 99.99,
                "qty"         : 1
            }
        ],
        "totalPrice" : 999.99
    }'''

    def setUp(self):
        custBooking = {
            'customerKey':
            '00000000',
            'customerName':
            Name(self.testCustName),
            'customerAddr':
            Location(self.testCustLocation),
            'customerContact':
            Contact(self.testCustContact),
            'custParty': [
                CustParty({
                    'name': Name(self.testCustPartyName1),
                    'other': OtherInfo(self.testOtherInfo1)
                }),
                CustParty({
                    'name': Name(self.testCustPartyName2),
                    'other': OtherInfo(self.testOtherInfo2)
                })
            ]
        }
        propBooking = {
            'propertyKey': 'ZZZZ9999',
            'propertyName': 'The Slate Resort',
            'propertyAddr': Location(self.testPropLocation),
            'propertyContact': Contact(self.testPropContact),
        }
        self.testDict = {
            'bookingKey': '20190501AAAA1111',
            'customer': custBooking,
            'property': propBooking,
            'bookingInfo': BookingInfo(self.testBookingInfo),
            'rooms': [RoomBooking(self.testRoomBooking)],
            'totalPrice': 999.99
        }
        self.bookingFromDict = Booking(self.testDict)
        self.bookingDefaults = Booking()
        self.maxDiff = None

    def test_booking_key(self):
        expected = '20190501AAAA1111'
        actual = self.bookingFromDict.getKey()
        self.assertEqual(expected, actual)

    def test_booking_from_dict(self):
        expected = 'Flintstone'
        custBook = self.bookingFromDict.get('customer')
        custName = custBook.get('customerName')
        actual = custName.get('last')
        self.assertEqual(expected, actual)

    def test_booking_from_blank(self):
        expected = True
        actual = isinstance(self.bookingDefaults.get('property'), PropBooking)
        self.assertEqual(expected, actual)

    def test_booking_from_dict_to_json(self):
        expected = json.loads(self.testJson)
        actual = json.loads(self.bookingFromDict.toJson())
        self.assertEqual(expected, actual)
Example #5
0
class TestPartner(unittest.TestCase):

    partnerFromDict = None
    partnerDefaults = None

    testDict = {
        'partnerKey': '00000000',
        'businessName': 'Granite Town Quarrel and Gravel Company',
        'revenueSplit': 0.90,
        'acctBalance': 9999.99,
        'name': Name(),
        'address': Location(),
        'contact': Contact(),
        'otherContact': OtherContact(),
        'otherInfo': OtherInfo(),
        'login': LoginInfo()
    }

    testLocation = {
        'streetAddress': '140 Boulder Avenue',
        'buildingName': 'The Granite Building',
        'floor': '22',
        'roomAptCondoFlat': '',
        'city': 'Granite Town',
        'stateProvince': 'ZZ',
        'locality': 'Unknown',
        'country': 'None',
        'postalCode': '00000',
        'latitude': '+111.111',
        'longitude': '-111.111'
    }

    testName = {
        'title': 'Mr',
        'first': 'Rockhead',
        'middle': 'Sylvester',
        'last': 'Slate',
        'suffix': 'Boss'
    }

    testContact = {
        'email': '*****@*****.**',
        'phone': '+0-000-000-0000',
        'socMedia': {
            'google': '*****@*****.**'
        }
    }

    testOtherContact = {
        'emails': ['*****@*****.**', '*****@*****.**'],
        'phoneNumbers': [{
            'home': '000-000-0000'
        }, {
            'work': '111-111-1111'
        }],
        'socMedias': [{
            'google': '*****@*****.**'
        }, {
            'skype': 'fslate'
        }]
    }

    testOtherInfo = {'gender': 'M', 'dateOfBirth': '0000-01-01'}

    testLoginInfo = {
        'username': '******',
        'oauth2': '*****@*****.**',
        'password': '******'
    }

    testJson = '''{
        "partnerKey"   : "00000000",
        "businessName" : "Granite Town Quarrel and Gravel Company",
        "revenueSplit" : 0.90,
        "acctBalance"  : 9999.99,
        "address"      : {
            "streetAddress"    : "140 Boulder Avenue",
            "buildingName"     : "The Granite Building",
            "floor"            : "22",
            "roomAptCondoFlat" : "",
            "city"             : "Granite Town",
            "stateProvince"    : "ZZ",
            "locality"         : "Unknown",
            "country"          : "None",
            "postalCode"       : "00000",
            "latitude"         : "+111.111",
            "longitude"        : "-111.111"
        },
        "name" : {
            "title"  : "Mr",
            "first"  : "Rockhead",
            "middle" : "Sylvester",
            "last"   : "Slate",
            "suffix" : "Boss"
        },
        "contact" : {
            "email"    : "*****@*****.**",
            "phone"    : "+0-000-000-0000",
            "socMedia" : {"google" : "*****@*****.**"}
        },
        "otherContact" : {
            "emails"       : ["*****@*****.**", "*****@*****.**"],
            "phoneNumbers" : [{"home" : "000-000-0000"}, {"work" : "111-111-1111"}],
            "socMedias"    : [{"google" : "*****@*****.**"}, {"skype" : "fslate"}]
        },
        "otherInfo" : {
            "gender"      : "M",
            "dateOfBirth" : "0000-01-01"
        },
        "login" : {
            "username" : "rockhead",
            "oauth2"   : "*****@*****.**",
            "password" : "abcdefghijklmnopqrstuvwxyz"
        }
    }'''

    def setUp(self):
        self.testDict['name'] = Name(self.testName)
        self.testDict['address'] = Location(self.testLocation)
        self.testDict['contact'] = Contact(self.testContact)
        self.testDict['otherContact'] = OtherContact(self.testOtherContact)
        self.testDict['otherInfo'] = OtherInfo(self.testOtherInfo)
        self.testDict['login'] = LoginInfo(self.testLoginInfo)
        self.partnerFromDict = Partner(self.testDict)
        self.partnerDefaults = Partner()
        self.maxDiff = None

    def test_partner_key(self):
        expected = '00000000'
        actual = self.partnerFromDict.getKey()
        self.assertEqual(expected, actual)

    def test_partner_from_dict(self):
        expected = 'Slate'
        name = self.partnerFromDict.get('name')
        actual = name.get('last')
        self.assertEqual(expected, actual)

    def test_partner_from_blank(self):
        expected = True
        actual = isinstance(self.partnerDefaults.get('address'), Location)
        self.assertEqual(expected, actual)

    def test_partner_from_dict_to_json(self):
        expected = json.loads(self.testJson)
        actual = json.loads(self.partnerFromDict.toJson())
        self.assertEqual(expected, actual)
Example #6
0
class CustParty(Base) :
    fields = {
        'name'  : Name(),
        'other' : OtherInfo()
    }