当前位置: 首页>>代码示例>>Python>>正文


Python Person.delete方法代码示例

本文整理汇总了Python中models.Person.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Person.delete方法的具体用法?Python Person.delete怎么用?Python Person.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Person的用法示例。


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

示例1: test_signals

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import delete [as 别名]
    def test_signals(self):
        user = Person(id=2, first_name='Ivan', last_name='Ivanov',
                      birth_date=datetime.datetime.strptime("30 Nov 00",
                                                            "%d %b %y").date(),
                      bio='bio', email='[email protected]', skype='name_',
                      jabber='[email protected]', other_contacts='111')
        user.save()

        record = ModelsActions.objects.latest('date_with_time')
        self.assertEqual(record.action, 0)
        self.assertEquals(record.model_name, user.__name__)
        self.assertEquals(record.pk, user.pk)

        user.bio = "This is new Biography"
        user.save()
        record = ModelsActions.objects.latest('date_with_time')
        self.assertEqual(record.action, 1)

        user.delete()
        record = ModelsActions.objects.latest('date_with_time')

        self.assertEqual(record.action, 2)
开发者ID:alexa-repo,项目名称:test42cc,代码行数:24,代码来源:tests.py

示例2: test_pair_stairs_model

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import delete [as 别名]
class test_pair_stairs_model(TestCase):

    def setUp(self):
        self.person1 = Person(name = "Person1")
        self.person2 = Person(name = "Person2")
        self.person3 = Person(name = "Person3")
        self.person4 = Person(name = "Person4")
        self.person1.save()
        self.person2.save()
        self.person3.save()
        self.person4.save()

    def test_that_person_exists(self):
        expected_name = "Person1"
        self.assertEquals(self.person1.name, expected_name)

    def test_that_persons_in_pair_exist(self):
        self.pair = Pair(pair1 = self.person1, pair2 = self.person2, count = 0)
        pair_result = self.pair.pair1.name, self.pair.pair2.name
        expected = "Person1", "Person2"
        self.assertEqual(pair_result, expected)

    def test_that_pairing_adds_one_to_count(self):
        pair = Pair(pair1 = self.person1, pair2 = self.person2, count = 0)
        pair.add_count_to_pair()
        self.assertEqual(1, pair.count)

    def test_create_pairs(self):
        self.person1.create_pairs()
        list_all_pairs = Pair.objects.all()
        expected_pair1 = "Person1", "Person1", 0
        actual_pair1 = list_all_pairs[0].pair1.name, list_all_pairs[0].pair2.name, list_all_pairs[0].count
        expected_pair2 = "Person1", "Person2", 0
        actual_pair2 = list_all_pairs[1].pair1.name, list_all_pairs[1].pair2.name, list_all_pairs[1].count
        self.assertEqual(actual_pair1,expected_pair1)
        self.assertEqual(actual_pair2,expected_pair2)





    def tearDown(self):
        self.person1.delete()
        self.person2.delete()
        self.person3.delete()
        self.person4.delete()
开发者ID:kkraft,项目名称:twupairstairs,代码行数:48,代码来源:tests.py

示例3: test_basic

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import delete [as 别名]
    def test_basic(self):
        p = Person(first_name="John", last_name="Smith")
        self.assertEqual(p.data, [])
        p.save()
        self.assertEqual(p.data, [
            "Before save",
            "After save",
        ])

        self.assertQuerysetEqual(
            Person.objects.all(), [
                "John Smith",
            ],
            unicode
        )

        p.delete()
        self.assertEqual(p.data, [
            "Before save",
            "After save",
            "Before deletion",
            "After deletion",
        ])
        self.assertQuerysetEqual(Person.objects.all(), [])
开发者ID:0xmilk,项目名称:appscale,代码行数:26,代码来源:tests.py

示例4: test_basic

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import delete [as 别名]
    def test_basic(self):
        # Save up the number of connected signals so that we can check at the
        # end that all the signals we register get properly unregistered (#9989)
        pre_signals = (
            len(signals.pre_save.receivers),
            len(signals.post_save.receivers),
            len(signals.pre_delete.receivers),
            len(signals.post_delete.receivers),
        )

        data = []

        def pre_save_test(signal, sender, instance, **kwargs):
            data.append(
                (instance, kwargs.get("raw", False))
            )
        signals.pre_save.connect(pre_save_test)

        def post_save_test(signal, sender, instance, **kwargs):
            data.append(
                (instance, kwargs.get("created"), kwargs.get("raw", False))
            )
        signals.post_save.connect(post_save_test)

        def pre_delete_test(signal, sender, instance, **kwargs):
            data.append(
                (instance, instance.id is None)
            )
        signals.pre_delete.connect(pre_delete_test)

        post_delete_test = PostDeleteHandler(data)
        signals.post_delete.connect(post_delete_test)

        # throw a decorator syntax receiver into the mix
        @receiver(signals.pre_save)
        def pre_save_decorator_test(signal, sender, instance, **kwargs):
            data.append(instance)

        @receiver(signals.pre_save, sender=Car)
        def pre_save_decorator_sender_test(signal, sender, instance, **kwargs):
            data.append(instance)

        p1 = Person(first_name="John", last_name="Smith")
        self.assertEqual(data, [])
        p1.save()
        self.assertEqual(data, [
            (p1, False),
            p1,
            (p1, True, False),
        ])
        data[:] = []

        p1.first_name = "Tom"
        p1.save()
        self.assertEqual(data, [
            (p1, False),
            p1,
            (p1, False, False),
        ])
        data[:] = []

        # Car signal (sender defined)
        c1 = Car(make="Volkswagon", model="Passat")
        c1.save()
        self.assertEqual(data, [
            (c1, False),
            c1,
            c1,
            (c1, True, False),
        ])
        data[:] = []

        # Calling an internal method purely so that we can trigger a "raw" save.
        p1.save_base(raw=True)
        self.assertEqual(data, [
            (p1, True),
            p1,
            (p1, False, True),
        ])
        data[:] = []

        p1.delete()
        self.assertEqual(data, [
            (p1, False),
            (p1, False),
        ])
        data[:] = []

        p2 = Person(first_name="James", last_name="Jones")
        p2.id = 99999
        p2.save()
        self.assertEqual(data, [
            (p2, False),
            p2,
            (p2, True, False),
        ])
        data[:] = []

        p2.id = 99998
        p2.save()
#.........这里部分代码省略.........
开发者ID:101studio,项目名称:django,代码行数:103,代码来源:tests.py

示例5: RegTestCase

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import delete [as 别名]

#.........这里部分代码省略.........
            
        )
        self.omni_reg.save()

        self.omni_reg.people.add(self.omni)       
        self.omni_reg.save()        
        
        self.omni2 = Person(
            first_name="omni2",
            gender = 'W,TW',
            age = 42,
            seeking_primary = False,
            kinky = True,
            seek_gender = 'M-2,W,TM-2,TW,Q,GQ,NA,BU,FE,AN',
            seek_age_min = 24,
            seek_age_max = 60,
            seek_kinkiness = 'K')
        self.omni2.save()

        self.omni2_reg = RegRecord(
            psdid = "omni2",
            is_group = False,
            location = 'SB,EB',
            event="testing1"
            
        )
        self.omni2_reg.save()

        self.omni2_reg.people.add(self.omni2)   
        self.omni2_reg.save()
                

    def tearDown(self):
        self.bob_reg.delete()
        self.lulu_reg.delete()
        self.omni_reg.delete()
        self.omni2_reg.delete()
        self.bob.delete()
        self.lulu.delete()
        self.omni.delete()
        self.omni2.delete()
        
    def test_Bob(self):
        bob = self.bob
        self.all_equal(
            (bob.first_name, 'Bob'),
            (bob.gender_set, set('M')),
            (bob.seek_gender_set, set('W')),
            (bob.will_date_kinky, True),
            (bob.will_date_nonkinky, True),
        )

    def test_Omni(self):
        omni = self.omni
        self.all_equal(
            (omni.first_name, 'omni'),
            (omni.gender_set, set(['W','TW'])),
            (omni.pref_gender_set, set(['M','TM'])),
            (omni.will_date_kinky, True),
            (omni.will_date_nonkinky, False),
        )

    def test_Bob_reg(self):
        r = self.bob_reg
        self.all_equal(
            (r.integrity_ok(), True),
开发者ID:apachols,项目名称:psd,代码行数:70,代码来源:tests.py


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