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
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)
Пример #3
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)