• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python changes.AutoChanges类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中south.creator.changes.AutoChanges的典型用法代码示例。如果您正苦于以下问题:Python AutoChanges类的具体用法?Python AutoChanges怎么用?Python AutoChanges使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AutoChanges类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_not_deleted_auto

    def test_not_deleted_auto(self):

        empty_defs = { }
        old_defs = freezer.freeze_apps(["non_managed"])
        class InitialMigration(SchemaMigration):
            "Serves as fake previous migration"
        
            def forwards(self, orm):
                pass
        
            def backwards(self, orm):
                pass
        
            models = self.full_defs

            complete_apps = ['non_managed']
                    
        migrations = Migrations("non_managed")
        initial_orm = FakeORM(InitialMigration, "non_managed")
        changes = AutoChanges(
            migrations = migrations,
            old_defs = self.full_defs,
            old_orm = initial_orm,
            new_defs = empty_defs,
        )
        change_list = changes.get_changes()
        if list(change_list):
            self.fail("Auto migration deletes table for non-managed model")
开发者ID:brynn,项目名称:slowdown,代码行数:28,代码来源:autodetection.py


示例2: test_not_added_auto

    def test_not_added_auto(self):

        empty_defs = { }
        class EmptyMigration(SchemaMigration):
            "Serves as fake previous migration"
        
            def forwards(self, orm):
                pass
        
            def backwards(self, orm):
                pass
        
            models = empty_defs

            complete_apps = ['non_managed']
                    
        migrations = Migrations("non_managed")
        empty_orm = FakeORM(EmptyMigration, "non_managed")
        changes = AutoChanges(
            migrations = migrations,
            old_defs = empty_defs,
            old_orm = empty_orm,
            new_defs = self.full_defs,
        )
        change_list = changes.get_changes()
        if list(change_list):
            self.fail("Auto migration creates table for non-managed model")
开发者ID:brynn,项目名称:slowdown,代码行数:27,代码来源:autodetection.py


示例3: test_no_change

 def test_no_change(self):
     "Test with a completely unchanged definition."
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['southdemo.Lizard']"}),
             ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['southdemo.Lizard']"}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.related.ForeignKey', ['ohhai', 'there'], {'to': "somewhere", "from": "there"}),
             ('django.db.models.fields.related.ForeignKey', ['ohhai', 'there'], {"from": "there", 'to': "somewhere"}),
         ),
         False,
     )
开发者ID:brynn,项目名称:slowdown,代码行数:18,代码来源:autodetection.py


示例4: test_kwd_change

 def test_kwd_change(self):
     "Test a changed keyword argument"
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['b'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['b'], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['a'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['a'], {}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', [], {}),
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['a'], {}),
             ('django.db.models.fields.CharField', ['a'], {'to': "foo"}),
         ),
         True,
     )
开发者ID:brynn,项目名称:slowdown,代码行数:58,代码来源:autodetection.py


示例5: test_not_modified_auto

    def test_not_modified_auto(self):

        fake_defs = {
            'non_managed.legacy': {
                'Meta': {'object_name': 'Legacy', 'db_table': "'legacy_table'", 'managed': 'False'},
                'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
                'name': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}),
                #'size': ('django.db.models.fields.IntegerField', [], {}) # The "change" is the addition of this field
            }
        } 
        class InitialMigration(SchemaMigration):
            "Serves as fake previous migration"
        
            def forwards(self, orm):
                pass
        
            def backwards(self, orm):
                pass
        
            models = fake_defs

            complete_apps = ['non_managed']
                    
        from non_managed import models as dummy_import_to_force_loading_models # TODO: Does needing this indicate a bug in MokeyPatcher?
        reload_module(dummy_import_to_force_loading_models) # really force... 
        
        migrations = Migrations("non_managed")
        initial_orm = FakeORM(InitialMigration, "non_managed")
        changes = AutoChanges(
            migrations = migrations,
            old_defs = fake_defs,
            old_orm = initial_orm,
            new_defs = self.full_defs
        )
        change_list = changes.get_changes()
        if list(change_list):
            self.fail("Auto migration changes table for non-managed model")
开发者ID:brynn,项目名称:slowdown,代码行数:37,代码来源:autodetection.py


示例6: test_pos_change

 def test_pos_change(self):
     "Test with a changed positional argument."
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['hi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['bye'], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['pisdadad'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['hi'], {}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', [], {}),
             ('django.db.models.fields.CharField', ['bye'], {}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {}),
             ('django.db.models.fields.CharField', ['pi'], {}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {}),
             ('django.db.models.fields.CharField', ['45fdfdf'], {}),
         ),
         True,
     )
开发者ID:brynn,项目名称:slowdown,代码行数:66,代码来源:autodetection.py


示例7: test_backcompat_nochange

 def test_backcompat_nochange(self):
     "Test that the backwards-compatable comparison is working"
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', [], {}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['ack'], {}),
             ('django.db.models.fields.CharField', ['ack'], {}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', [], {'to':'b'}),
             ('django.db.models.fields.CharField', [], {'to':'b'}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {'to':'you'}),
             ('django.db.models.fields.CharField', ['hah'], {'to':'you'}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {'to':'you'}),
             ('django.db.models.fields.CharField', ['hah'], {'to':'heh'}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':"orm['appname.hah']"}),
         ),
         False,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':'hah'}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':'rrr'}),
         ),
         True,
     )
     
     self.assertEqual(
         AutoChanges.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.IntField', [], {'to':'hah'}),
         ),
         True,
     )
开发者ID:brynn,项目名称:slowdown,代码行数:74,代码来源:autodetection.py



注:本文中的south.creator.changes.AutoChanges类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python freezer.freeze_apps函数代码示例发布时间:2022-05-27
下一篇:
Python _minhash.MinHash类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap