def test_more(self):
        srd = Search_Result_DataService()
        resd = Resource_DAO()
        rep = RepairResource_DAO()
        reqeust = ResourceRequest_DAO()

        count_for_test = run_sql_string_statement(
            "select count(*) from Resource")
        count = int(count_for_test[0][0])

        a = count + 1
        b = count + 2

        resd.insert_resource(a, "123Name", "dummy", "not available", 14.56,
                             33.12, "james", 120.4, 3, "hour", "tom",
                             "2015-03-02", "2016-07-03")

        resd.insert_resource(b, "123Name", "dummy", "in repair", 14.56, 33.12,
                             "james", 120.4, 3, "hour", "tom", "2015-03-02",
                             "2016-07-03")

        rep.insert_records(b,
                           rep.get_count() + 1, "james", "2015-03-02",
                           "2016-07-03")
        reqeust.insert_record(1, reqeust.get_count() + 1, "2015-03-02", a)

        ma = srd.populate_table_data("a", "2# aaa", 1000000, "(6) testinci")
        assert isinstance(ma, list)
        print ma
    def test_insert_record(self):
        rsd = Resource_DAO()

        count_for_test = run_sql_string_statement(
            "select count(*) from Resource")
        count = int(count_for_test[0][0])

        rsd.insert_resource(count + 1, "123Name", "dummy", "available", 14.56,
                            33.12, "james", 120.4, 3, "hour", "tom",
                            "2015-03-02", "2016-07-03")
Esempio n. 3
0
        unit = "hour"
        addi = [1, 2, 3, 4, 5, 6, 7]
        cap = ["capa", "capb"]
    if count / 5 == 0:
        status = "in repair"
        unit = "time"
        addi = [14, 13, 5, 6, 7]
        cap = ["capa", "capb", "capc"]
    else:
        status = "not available"
        unit = "km"
        addi = [11, 12, 8]
        cap = ["capx"]

    rsd.insert_resource(count + 1, "ResName" + str(count), "dummymodel",
                        status, 44.44, 55.55, usernmae, 250.24, count % 14 + 1,
                        unit, "tomcompany" + str(i - 1), "2015-03-02",
                        "2016-07-03")

    Additional_DAO(count + 1).insert_additional_esf_list(addi)
    Capability_DAO(count + 1).insert_capability(cap)

for i in range(1, 50):
    usernmae = "tomgov" + str(i)
    rsd = Resource_DAO()
    count = rsd.get_count_as_int() + 1

    if count / 3 == 0:
        status = "available"
        unit = "hour"
        addi = [1, 2, 3, 4, 5, 6, 7]
        cap = ["capa", "capb"]
Esempio n. 4
0
class Add_Resource_DataService():
    def __init__(self, username):
        logging.info("start the Add_Resource_DataService")
        self.resource_dao = Resource_DAO()
        self.new_generated_resource_id = self.resource_dao.get_count_as_int() + 100000
        self.capability_dao = Capability_DAO(self.new_generated_resource_id)
        self.additional_esf_dao = Additional_DAO(self.new_generated_resource_id)
        self.username = username
        self.esf_list_dao = ESF_DAO()
        self.usertype_dao = UserType_DAO()
        self.costunitdao = CostUnit_DAO()

    def get_new_generated_resource_id(self):
        '''
        @rtype: int
        '''
        return self.new_generated_resource_id

    def submit_form_for_new_resource(self, ResourceName, model, Latitude, Longitude,
                                     CostPerValue, EsfID, CostUnit, additionalESFList, capabilitiesList):
        '''
        @rtype: bool
        '''

        assert isinstance(self.new_generated_resource_id, int)
        assert isinstance(ResourceName, str)
        assert isinstance(model, str)
        # assert isinstance(CurrentStatus, str)
        assert isinstance(Latitude, float)
        assert isinstance(Longitude, float)
        # assert isinstance(Owner, str)
        assert isinstance(CostPerValue, float)
        assert isinstance(EsfID, int)
        assert isinstance(CostUnit, str)
        # assert isinstance(CurrentUser, str)
        # assert isinstance(StartDate, str)
        # assert isinstance(DueDate, str)

        assert isinstance(additionalESFList, list)
        assert isinstance(capabilitiesList, list)

        STATUS = ["available", "not available", "in repair"]

        # insert into the resource table
        self.resource_dao.insert_resource(self.new_generated_resource_id,
                                          ResourceName,
                                          model,
                                          STATUS[0],
                                          Latitude,
                                          Longitude,
                                          self.username,
                                          CostPerValue,
                                          EsfID,
                                          CostUnit,
                                          self.username,
                                          time.strftime("%y-%m-%d"),
                                          time.strftime("%y-%m-%d"))

        # insert into the additional esf table
        add_esf_dao = Additional_DAO(self.new_generated_resource_id)
        add_esf_dao.insert_additional_esf_list(additionalESFList)

        # insert into the cap table
        capdao = Capability_DAO(self.new_generated_resource_id)
        capdao.insert_capability(capabilitiesList)

    def populate_owner_title(self):
        '''
        @rtype: str
        '''
        usertype = self.usertype_dao.get_user_type_by_username(self.username)

        MUNICIPALITIES = "municipalities"
        GOVERNMENT_AGENCIES = "government_agencies"
        COMPANIES = "companies"
        INDIVIDUALS = "individuals"

        if usertype == MUNICIPALITIES:
            return self.usertype_dao.get_title_info_from_municipalities(self.username)

        if usertype == GOVERNMENT_AGENCIES:
            return self.usertype_dao.get_title_info_from_government(self.username)

        if usertype == COMPANIES:
            return self.usertype_dao.get_title_info_from_company(self.username)

        if usertype == INDIVIDUALS:
            return self.usertype_dao.get_title_info_from_individuals(self.username)[0]

        return ""

    def populate_esf_list(self):
        '''
        @rtype: dict
        '''
        return self.esf_list_dao.get_all_esf_records()

    def populate_costunit_list(self):
        return self.costunitdao.get_all_CostUnits()