コード例 #1
0
    def setUp(self):
        user = "******"
        password = "******"
        database = "darkhan_update_final"
        host = "localhost"
        port = "5432"

        SessionHandler().create_session(user, password, host, port, database)
        self.session = SessionHandler().session_instance()
コード例 #2
0
    def setUp(self):

        self.app = QApplication(sys.argv)
        user = "******"
        password = "******"
        database = "darkhan_2808"
        host = "localhost"
        port = "5432"

        SessionHandler().create_session(user, password, host, port, database)
        self.session = SessionHandler().session_instance()

        #self.app = QgsApplication.setPrefixPath("/usr/local", True)
        #QgsApplication.initQgis()
        #if len(QgsProviderRegistry.instance().providerList()) == 0:
        #    raise RuntimeError('No data providers available.')

        #QgsApplication.exitQgis()

        application = CtApplication()
        self.application_dialog = ApplicationsDialog(application,
                                                     self.navigator, False)
コード例 #3
0
class test_BsPerson(unittest.TestCase):
    def setUp(self):
        user = "******"
        password = "******"
        database = "darkhan_update_final"
        host = "localhost"
        port = "5432"

        SessionHandler().create_session(user, password, host, port, database)
        self.session = SessionHandler().session_instance()

    def test_create(self):
        person = BsPerson()
        person.id = 123
        type = self.session.query(ClPersonType).first()
        bank = self.session.query(ClBank).first()
        person.type_ref = type
        person.name = "Sherman"
        person.middle_name = " the greatest"
        person.first_name = "Gary"
        dateTimeString = QDateTime.currentDateTime().toString(
            Constants.DATABASE_DATETIME_FORMAT)
        person.date_of_birth = datetime.strptime(
            str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)
        person.person_id = "AC123456001"
        person.bank_account_no = "12121212"
        person.bank_ref = bank
        person.phone = 234567890
        person.mobile_phone = 12345678
        person.gender_ref = self.session.query(ClGender).first()
        person.address_au_level1_ref = self.session.query(AuLevel1).first()
        person.address_au_level2_ref = self.session.query(AuLevel2).first()
        person.address_au_level3_ref = self.session.query(AuLevel3).first()
        person.address_au_khoroolol_ref = self.session.query(AuKhoroolol).first

        self.session.add(person)
        self.session.commit()

    def test_udpate(self):

        person = self.session.query(BsPerson).filter_by(id=123).one()
        person.id = 1234
        person.address_au_level1_ref = self.session.query(AuLevel1).filter_by(
            "045").one()
        person.address_au_level2_ref = self.session.query(AuLevel2).filter_by(
            "04510").one()

    def test_delete(self):

        self.session.query(BsPerson).filter_by(id=1234).delete()
        self.session.commit()
コード例 #4
0
ファイル: test_CtApplication.py プロジェクト: teamlm2/lm2
class test_CtApplication(unittest.TestCase):
    def setUp(self):

        user = "******"
        password = "******"
        database = "darkhan_update_final"
        host = "localhost"
        port = "5432"

        SessionHandler().create_session(user, password, host, port, database)
        self.session = SessionHandler().session_instance()

    def test_create(self):

        try:
            ct_application = PluginUtils.create_new_application("123")
            self.session.add(ct_application)
            self.session.commit()

        except SQLAlchemyError:
            self.assertRaises(SQLAlchemyError)

    def test_update(self):

        try:
            ct_application = self.session.query(CtApplication).filter_by(
                app_no="123").one()

            ct_application.app_no = "1234"
            ct_application.approved_duration = 10
            ct_application.remarks = "Unit tests class"

            #Add ApplicationStatus
            set_role = self.session.query(SetRole).filter_by(
                username="******").one()
            status = CtApplicationStatus()
            status.next_officer_in_charge_ref = set_role
            status.officer_in_charge_ref = set_role
            dateTimeString = QDateTime.currentDateTime().toString(
                Constants.DATABASE_DATETIME_FORMAT)
            status.status_date = datetime.strptime(
                str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)
            status_ref = self.session.query(ClApplicationStatus).first()
            status.status_ref = status_ref
            ct_application.statuse.append(status)

            #Add ApplicationPersonRole instance
            person = self.session.query(BsPerson).filter_by(id=1).one()
            role_ref = self.session.query(ClPersonRole).first()
            person_role = CtApplicationPersonRole()
            person_role.person = 1
            person_role.person_ref = person
            person_role.role = role_ref.code
            person_role.role_ref = role_ref
            ct_application.stakeholders.append(person_role)

            #Add DocumentPersonRole
            doc_role = self.session.query(ClDocumentRole).first()
            ct_document_role = CtApplicationDocument()
            ct_document = CtDocument()
            ct_document = "test.doc"
            currentFile = QFile(
                "/Users/anna/Documents/Projects/Mongolia/Orga/LandManager 2.pdf"
            )
            if not currentFile.open(QIODevice.ReadOnly):
                self.assertRaises("")
            byteArray = currentFile.readAll()
            ct_document.content = bytes(byteArray)
            ct_document_role.document_ref = ct_document
            ct_document_role.person_ref = person
            ct_document_role.role_ref = doc_role

            #app1Ext
            app_1_Ext = CtApp1Ext()
            app_1_Ext.applicant_has_paid = True
            app_1_Ext.excess_area = 123
            app_1_Ext.price_to_be_paid = 12.12
            ct_application.app1ext = app_1_Ext

            #app8Ext
            app_8_Ext = CtApp8Ext()
            app_8_Ext_type = self.session.query(ClMortgageType).first()
            app_8_Ext.end_mortgage_period = datetime.strptime(
                str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)
            app_8_Ext.start_mortgage_period = datetime.strptime(
                str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)
            app_8_Ext.mortgage_type_ref = app_8_Ext_type
            ct_application.app8ext = app_8_Ext

            #app15Ext
            app_15_ext = CtApp15Ext()
            transfer_type = self.session.query(ClTransferType).first()
            app_15_ext.transfer_type_ref = transfer_type
            ct_application.app15ext = app_15_ext

            self.session.commit()

        except SQLAlchemyError, e:
            self.assertRaises(SQLAlchemyError)
コード例 #5
0
class test_CtApplication(unittest.TestCase):
    def setUp(self):

        user = "******"
        password = "******"
        database = "darkhan_update_final"
        host = "localhost"
        port = "5432"

        SessionHandler().create_session(user, password, host, port, database)
        self.session = SessionHandler().session_instance()

    def test_create(self):

        try:
            set_role = SetRole()
            geometryString = "POLYGON((" + str(0) + " " + str(1) + "," + str(
                1) + " " + str(1) + "," + str(1) + " " + str(0) + ", " + str(
                    1) + " " + str(0) + "," + str(0) + " " + str(1) + "))"
            filter_bbox = WKTElement(geometryString, 4326)
            set_role.filter_bbox = filter_bbox
            set_role.first_name = "Gary"
            set_role.surname = "Sherman"
            set_role_user.user_name = "gary_the_sherman"
            set_role.position = "Programmer"
            set_role.phone = "1234567"
            set_role.mac_addresses = "12.12.12.12.12"
            set_role.restriction_au_level2_ref = self.session.query(
                AuLevel2).first()
            set_role.restriction_au_level1_ref = self.session.query(
                AuLevel1).order_by(AuLevel1.code.desc()).first()
            set_role.restriction_au_level3_ref = self.session.query(
                AuLevel3).order_by(AuLevel3.code.desc()).first()
            set_role.working_au_level1_ref = self.session.query(
                AuLevel1).order_by(AuLevel1.code.desc()).first()
            set_role.working_au_level2_ref = self.session.query(
                AuLevel2).order_by(AuLevel2.code.desc()).first()
            dateTimeString = QDateTime.currentDateTime().toString(
                Constants.DATABASE_DATETIME_FORMAT)
            set_role.pa_from = datetime.strptime(
                str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)
            set_role.set_role.pa_till = datetime.strptime(
                str(dateTimeString), Constants.PYTHON_DATETIME_FORMAT)

            self.session.add(set_role)
            self.session.commit()

        except SQLAlchemyError:
            self.assertRaises(SQLAlchemyError)

    def test_update(self):

        try:
            set_role = self.session.query(SetRole).filter_by(
                user_name="gary_the_sherman").one()

            set_role.restriction_au_level1 = self.session.query(
                AuLevel1).order_by(AuLevel1.code.asc()).first()
            set_role.restriction_au_level2 = self.session.query(
                AuLevel2).order_by(AuLevel2.code.asc()).first()
            set_role.working_au_level1_ref = self.session.query(
                AuLevel1).order_by(AuLevel1.code.asc()).first()
            set_role.working_au_level2_ref = self.session.query(
                AuLevel1).order_by(AuLevel2.code.asc()).first()

            self.session.commit()

        except SQLAlchemyError, e:
            self.assertRaises(SQLAlchemyError)