Exemplo n.º 1
0
    def test_string_form_referencing(self):
        """
        Regression test for #1661 and #1662

        Check that string form referencing of
        models works, both as pre and post reference, on all RelatedField types.
        """

        f1 = Foo(name="Foo1")
        f1.save()
        f2 = Foo(name="Foo2")
        f2.save()

        w1 = Whiz(name="Whiz1")
        w1.save()

        b1 = Bar(name="Bar1", normal=f1, fwd=w1, back=f2)
        b1.save()

        self.assertEquals(b1.normal, f1)

        self.assertEquals(b1.fwd, w1)

        self.assertEquals(b1.back, f2)

        base1 = Base(name="Base1")
        base1.save()

        child1 = Child(name="Child1", parent=base1)
        child1.save()

        self.assertEquals(child1.parent, base1)
Exemplo n.º 2
0
    def test_unicode_chars_in_queries(self):
        """
        Regression tests for #3937

        make sure we can use unicode characters in queries.
        If these tests fail on MySQL, it's a problem with the test setup.
        A properly configured UTF-8 database can handle this.
        """

        fx = Foo(name='Bjorn', friend=u'François')
        fx.save()
        self.assertEquals(Foo.objects.get(friend__contains=u'\xe7'), fx)

        # We can also do the above query using UTF-8 strings.
        self.assertEquals(Foo.objects.get(friend__contains='\xc3\xa7'), fx)
Exemplo n.º 3
0
    def test_unicode_chars_in_queries(self):
        """
        Regression tests for #3937

        make sure we can use unicode characters in queries.
        If these tests fail on MySQL, it's a problem with the test setup.
        A properly configured UTF-8 database can handle this.
        """

        fx = Foo(name='Bjorn', friend=u'François')
        fx.save()
        self.assertEqual(Foo.objects.get(friend__contains=u'\xe7'), fx)

        # We can also do the above query using UTF-8 strings.
        self.assertEqual(Foo.objects.get(friend__contains='\xc3\xa7'), fx)
Exemplo n.º 4
0
    def test_string_form_referencing(self):
        """
        Regression test for #1661 and #1662

        Check that string form referencing of
        models works, both as pre and post reference, on all RelatedField types.
        """

        f1 = Foo(name="Foo1")
        f1.save()
        f2 = Foo(name="Foo2")
        f2.save()

        w1 = Whiz(name="Whiz1")
        w1.save()

        b1 = Bar(name="Bar1", normal=f1, fwd=w1, back=f2)
        b1.save()

        self.assertEqual(b1.normal, f1)

        self.assertEqual(b1.fwd, w1)

        self.assertEqual(b1.back, f2)

        base1 = Base(name="Base1")
        base1.save()

        child1 = Child(name="Child1", parent=base1)
        child1.save()

        self.assertEqual(child1.parent, base1)