Beispiel #1
0
    def test_no_change(self):
        "Test with a completely unchanged definition."

        self.assertEqual(
            startmigration.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(
            startmigration.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,
        )
Beispiel #2
0
 def test_no_change(self):
     "Test with a completely unchanged definition."
     
     self.assertEqual(
         startmigration.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(
         startmigration.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,
     )
Beispiel #3
0
 def test_kwd_change(self):
     "Test a changed keyword argument"
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['b'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['b'], {'to': "blue"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['a'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['a'], {}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', [], {}),
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['a'], {}),
             ('django.db.models.fields.CharField', ['a'], {'to': "foo"}),
         ),
         True,
     )
Beispiel #4
0
 def test_pos_change(self):
     "Test with a changed positional argument."
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['hi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', [], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['bye'], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['pisdadad'], {'to': "foo"}),
             ('django.db.models.fields.CharField', ['pi'], {'to': "foo"}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['hi'], {}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', [], {}),
             ('django.db.models.fields.CharField', ['bye'], {}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {}),
             ('django.db.models.fields.CharField', ['pi'], {}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('django.db.models.fields.CharField', ['pi'], {}),
             ('django.db.models.fields.CharField', ['45fdfdf'], {}),
         ),
         True,
     )
Beispiel #5
0
 def test_backcompat_nochange(self):
     "Test that the backwards-compatable comparison is working"
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', [], {}),
             ('django.db.models.fields.CharField', [], {}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['ack'], {}),
             ('django.db.models.fields.CharField', ['ack'], {}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', [], {'to':'b'}),
             ('django.db.models.fields.CharField', [], {'to':'b'}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {'to':'you'}),
             ('django.db.models.fields.CharField', ['hah'], {'to':'you'}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {'to':'you'}),
             ('django.db.models.fields.CharField', ['hah'], {'to':'heh'}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':"orm['appname.hah']"}),
         ),
         False,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':'hah'}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.CharField', [], {'to':'rrr'}),
         ),
         True,
     )
     
     self.assertEqual(
         startmigration.different_attributes(
             ('models.CharField', ['hah'], {}),
             ('django.db.models.fields.IntField', [], {'to':'hah'}),
         ),
         True,
     )
Beispiel #6
0
    def test_pos_change(self):
        "Test with a changed positional argument."

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['hi'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', [], {
                    'to': "foo"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', [], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['bye'], {
                    'to': "foo"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['pi'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['pi'], {
                    'to': "foo"
                }),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['pisdadad'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['pi'], {
                    'to': "foo"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['hi'], {}),
                ('django.db.models.fields.CharField', [], {}),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', [], {}),
                ('django.db.models.fields.CharField', ['bye'], {}),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['pi'], {}),
                ('django.db.models.fields.CharField', ['pi'], {}),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['pi'], {}),
                ('django.db.models.fields.CharField', ['45fdfdf'], {}),
            ),
            True,
        )
Beispiel #7
0
    def test_backcompat_nochange(self):
        "Test that the backwards-compatable comparison is working"

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', [], {}),
                ('django.db.models.fields.CharField', [], {}),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['ack'], {}),
                ('django.db.models.fields.CharField', ['ack'], {}),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', [], {
                    'to': 'b'
                }),
                ('django.db.models.fields.CharField', [], {
                    'to': 'b'
                }),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {
                    'to': 'you'
                }),
                ('django.db.models.fields.CharField', ['hah'], {
                    'to': 'you'
                }),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {
                    'to': 'you'
                }),
                ('django.db.models.fields.CharField', ['hah'], {
                    'to': 'heh'
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {}),
                ('django.db.models.fields.CharField', [], {
                    'to': "orm['appname.hah']"
                }),
            ),
            False,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {}),
                ('django.db.models.fields.CharField', [], {
                    'to': 'hah'
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {}),
                ('django.db.models.fields.CharField', [], {
                    'to': 'rrr'
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('models.CharField', ['hah'], {}),
                ('django.db.models.fields.IntField', [], {
                    'to': 'hah'
                }),
            ),
            True,
        )
Beispiel #8
0
    def test_kwd_change(self):
        "Test a changed keyword argument"

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['pi'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['pi'], {
                    'to': "blue"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', [], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', [], {
                    'to': "blue"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['b'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['b'], {
                    'to': "blue"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', [], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', [], {}),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['a'], {
                    'to': "foo"
                }),
                ('django.db.models.fields.CharField', ['a'], {}),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', [], {}),
                ('django.db.models.fields.CharField', [], {
                    'to': "foo"
                }),
            ),
            True,
        )

        self.assertEqual(
            startmigration.different_attributes(
                ('django.db.models.fields.CharField', ['a'], {}),
                ('django.db.models.fields.CharField', ['a'], {
                    'to': "foo"
                }),
            ),
            True,
        )