Example #1
0
    def test_get_resource_url(self):
        """ Get object resource url """

        enterprise = Enterprise()
        enterprise.id = 4
        self.assertEquals(enterprise.get_resource_url(), 'https://vsd:8443/api/v3_2/enterprises/4')

        enterprise.id = None
        self.assertEquals(enterprise.get_resource_url(), 'https://vsd:8443/api/v3_2/enterprises')
Example #2
0
def get_valid_enterprise(id, name):
    """ Returns a valid enterprise object """

    enterprise = Enterprise()
    enterprise.id = id
    enterprise.name = name

    return enterprise
Example #3
0
    def test_get_resource_base_url(self):
        """ Get object resource base url """

        enterprise = Enterprise()
        enterprise.id = 4
        self.assertEquals(
            enterprise.get_resource_url_for_child_type(Enterprise),
            'https://vsd:8443/api/v3_2/enterprises/4/enterprises')
Example #4
0
def get_valid_enterprise(id, name):
    """ Returns a valid enterprise object """

    enterprise = Enterprise()
    enterprise.id = id
    enterprise.name = name

    return enterprise
Example #5
0
    def test_genealogy_contains_id(self):
        """
        """
        enterprise1 = Enterprise(id='4', name='enterprise')
        enterprise1.id = '1'
        employee = Employee()
        employee.id = '2'
        employee.parent_object = enterprise1

        self.assertTrue(employee.genealogy_contains_id('1'))
Example #6
0
    def test_genealogic_ids(self):
        """
        """
        enterprise1 = Enterprise(id='4', name='enterprise')
        enterprise1.id = '1'
        employee = Employee()
        employee.id = '2'
        employee.parent_object = enterprise1

        self.assertEquals(employee.genealogic_ids(), ['2', '1'])
Example #7
0
    def test_to_dict(self):
        """ Get object as dictionary """

        enterprise = Enterprise()
        enterprise.id = 3
        enterprise.name ="NewEnterprise"

        # List of objects
        admingroup = Group()
        admingroup.name = "Admins"
        othergroup = Group()
        othergroup.name = "Others"
        enterprise.groups = [admingroup, othergroup]

        # Object
        ceo = User()
        ceo.firstname = 'John'
        ceo.lastname = 'Doe'
        enterprise.ceo = ceo

        to_dict = enterprise.to_dict()


        self.assertEquals(sorted(to_dict.keys()), sorted(['groups', 'token', 'lastUpdatedDate', 'allowedForwardingClasses', 'name', 'ceo', 'parentType', 'parentID', 'owner', 'creationDate', 'ID', 'description']))
        self.assertEquals(to_dict['name'], 'NewEnterprise')
        self.assertEquals(to_dict['ID'], 3)
        #self.assertEquals(to_dict['externalID'], None)
        #self.assertEquals(to_dict['localID'], None)
        self.assertEquals(to_dict['parentID'], None)
        self.assertEquals(to_dict['parentType'], None)
        self.assertEquals(to_dict['owner'], None)
        self.assertEquals(to_dict['creationDate'], None)
        self.assertEquals(to_dict['ceo'], {
                                            'APIKey': None,
                                            'APIKeyExpiry': None,
                                            'ID': None,
                                            'avatarData': None,
                                            'avatarType': None,
                                            'creationDate': None,
                                            'email': None,
                                            'enterpriseID': None,
                                            'enterpriseName': None,
                                            'firstName': 'John',
                                            'lastName': 'Doe',
                                            'owner': None,
                                            'parentID': None,
                                            'parentType': None,
                                            'password': None,
                                            'role': None,
                                            'userName': None,
                                            'lastUpdatedDate': None
                                        })
        self.assertEquals(to_dict['groups'], [{
                                                'ID': None,
                                                 'creationDate': None,
                                                 'lastUpdatedDate': None,
                                                 'name': 'Admins',
                                                 'owner': None,
                                                 'parentID': None,
                                                 'parentType': None
                                             },
                                             {
                                                'ID': None,
                                                'creationDate': None,
                                                'lastUpdatedDate': None,
                                                'name': 'Others',
                                                'owner': None,
                                                'parentID': None,
                                                'parentType': None
                                            }])
Example #8
0
    def test_get_resource_base_url(self):
        """ Get object resource base url """

        enterprise = Enterprise()
        enterprise.id = 4
        self.assertEquals(enterprise.get_resource_url_for_child_type(Enterprise), 'https://vsd:8443/api/v3_2/enterprises/4/enterprises')