示例#1
0
    def test_setting_model(self):
        from motionman.models import Setting

        setting_orig = Setting()
        setting_orig.id = 888
        setting_orig.name = u"setting1"
        setting_orig.value = u"setting value"
        setting_orig.valuex = u"long setting value"
        setting_orig.created_time = datetime.datetime.now()
        setting_orig.created_user = 3
        setting_orig.last_modified_time = datetime.datetime.now()
        setting_orig.last_modified_user = 3
        setting_orig.status = 2
        
        setting_new = copy.deepcopy(setting_orig)

        session = DBSession()
        session.add(setting_new)
        session.flush()
        transaction.commit()

        setting_load = session.query(Setting).filter(Setting.id==888).first()
        
        self.assertEqual(setting_load.name, setting_orig.name)
        self.assertEqual(setting_load.value, setting_orig.value)
        self.assertEqual(setting_load.valuex, setting_orig.valuex)
        self.assertEqual(setting_load.created_time, setting_orig.created_time)
        self.assertEqual(setting_load.created_user, setting_orig.created_user)
        self.assertEqual(setting_load.last_modified_time, setting_orig.last_modified_time)
        self.assertEqual(setting_load.last_modified_user, setting_orig.last_modified_user)
        self.assertEqual(setting_load.status, setting_orig.status)
        
        session.delete(setting_load)
        session.flush()
        transaction.commit()            
示例#2
0
    def test_setting_model(self):
        from motionman.models import Setting

        setting_orig = Setting()
        setting_orig.id = 888
        setting_orig.name = u"setting1"
        setting_orig.value = u"setting value"
        setting_orig.valuex = u"long setting value"
        setting_orig.created_time = datetime.datetime.now()
        setting_orig.created_user = 3
        setting_orig.last_modified_time = datetime.datetime.now()
        setting_orig.last_modified_user = 3
        setting_orig.status = 2

        setting_new = copy.deepcopy(setting_orig)

        session = DBSession()
        session.add(setting_new)
        session.flush()
        transaction.commit()

        setting_load = session.query(Setting).filter(Setting.id == 888).first()

        self.assertEqual(setting_load.name, setting_orig.name)
        self.assertEqual(setting_load.value, setting_orig.value)
        self.assertEqual(setting_load.valuex, setting_orig.valuex)
        self.assertEqual(setting_load.created_time, setting_orig.created_time)
        self.assertEqual(setting_load.created_user, setting_orig.created_user)
        self.assertEqual(setting_load.last_modified_time,
                         setting_orig.last_modified_time)
        self.assertEqual(setting_load.last_modified_user,
                         setting_orig.last_modified_user)
        self.assertEqual(setting_load.status, setting_orig.status)

        session.delete(setting_load)
        session.flush()
        transaction.commit()
示例#3
0
def init_data():
    from motionman.models import Setting

    session = DBSession()

    setting_orig = Setting()
    setting_orig.id = 1
    setting_orig.name = u"motion_id_prefix"
    setting_orig.value = u"mm"
    setting_orig.valuex = u""
    setting_orig.creator = 0
    setting_orig.create_time = datetime.datetime.now()
    setting_orig.last_modifier = 0
    setting_orig.last_modify_time = datetime.datetime.now()
    setting_orig.status = 1
        
    setting_1 = copy.deepcopy(setting_orig)

    try:
        session.add(setting_1)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()
        
    
    setting_2 = copy.deepcopy(setting_orig)

    setting_2.id = 2
    setting_2.name = u"admin_password"
    setting_2.value = u"123456"
    
    try:
        session.add(setting_2)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_3 = copy.deepcopy(setting_orig)

    setting_3.id = 3
    setting_3.name = u"user_password"
    setting_3.value = u"123456"
    
    try:
        session.add(setting_3)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_4 = copy.deepcopy(setting_orig)

    setting_4.id = 4
    setting_4.name = u"mail_sender"
    setting_4.value = u"*****@*****.**"
    
    try:
        session.add(setting_4)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()
        
    setting_5 = copy.deepcopy(setting_orig)

    setting_5.id = 5
    setting_5.name = u"mail_smtppassword"
    setting_5.value = u"123456"
    
    try:
        session.add(setting_5)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_6 = copy.deepcopy(setting_orig)

    setting_6.id = 6
    setting_6.name = u"mail_template"
    setting_6.valuex = u"123456"
    
    try:
        session.add(setting_6)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()
示例#4
0
def init_data():
    from motionman.models import Setting

    session = DBSession()

    setting_orig = Setting()
    setting_orig.id = 1
    setting_orig.name = u"motion_id_prefix"
    setting_orig.value = u"mm"
    setting_orig.valuex = u""
    setting_orig.creator = 0
    setting_orig.create_time = datetime.datetime.now()
    setting_orig.last_modifier = 0
    setting_orig.last_modify_time = datetime.datetime.now()
    setting_orig.status = 1

    setting_1 = copy.deepcopy(setting_orig)

    try:
        session.add(setting_1)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_2 = copy.deepcopy(setting_orig)

    setting_2.id = 2
    setting_2.name = u"admin_password"
    setting_2.value = u"123456"

    try:
        session.add(setting_2)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_3 = copy.deepcopy(setting_orig)

    setting_3.id = 3
    setting_3.name = u"user_password"
    setting_3.value = u"123456"

    try:
        session.add(setting_3)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_4 = copy.deepcopy(setting_orig)

    setting_4.id = 4
    setting_4.name = u"mail_sender"
    setting_4.value = u"*****@*****.**"

    try:
        session.add(setting_4)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_5 = copy.deepcopy(setting_orig)

    setting_5.id = 5
    setting_5.name = u"mail_smtppassword"
    setting_5.value = u"123456"

    try:
        session.add(setting_5)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()

    setting_6 = copy.deepcopy(setting_orig)

    setting_6.id = 6
    setting_6.name = u"mail_template"
    setting_6.valuex = u"123456"

    try:
        session.add(setting_6)
        session.flush()
        transaction.commit()
    except IntegrityError:
        transaction.abort()