def setUp(self):
        blog = Blog(name='Databases')
        blog.save()
        self.blogs = [blog]

        authors = ('John Smith', 'Jane Doe', 'Joe Plummer')
        headlines = ('MySQL is a relational DB',
                     'Postgres is a really good relational DB',
                     'Neo4J is a graph DB')

        self.entries = [
            Entry(headline=headline, blog=blog) for headline in headlines
        ]
        for entry in self.entries:
            entry.save()

        self.authors = [Author(name=name) for name in authors]
        for author in self.authors:
            author.save()

        for i, entry in enumerate(self.entries):
            entry.authors.add(self.authors[i])
            entry.authors.add(self.authors[(i + 1) % len(self.authors)])

        model_registry.register(curious_tests.models)
        model_registry.get_manager('Blog').allowed_relationships = ['authors']
Exemplo n.º 2
0
  def setUp(self):
    names = ('Databases', 'Relational Databases', 'Graph Databases')
    authors = ('John Smith', 'Jane Doe', 'Joe Plummer')
    headlines = ('MySQL is a relational DB',
                 'Postgres is a really good relational DB',
                 'Neo4J is a graph DB')

    self.blogs = [Blog(name=name) for name in names]
    for blog in self.blogs:
      blog.save()

    self.entries = [Entry(headline=headline, blog=blog) for headline, blog in zip(headlines, self.blogs)]
    for entry in self.entries:
      entry.save()

    self.authors = [Author(name=name) for name in authors]
    for author in self.authors:
      author.save()

    for i, entry in enumerate(self.entries):
      entry.authors.add(self.authors[i])
      entry.authors.add(self.authors[(i+1)%len(self.authors)])

    model_registry.register(curious_tests.models)
    model_registry.get_manager('Blog').allowed_relationships = ['authors']
Exemplo n.º 3
0
    def setUp(self):
        blog = Blog(name='Databases')
        blog.save()
        self.blogs = [blog]

        authors = ('John Smith', 'Jane Doe', 'Joe Plummer')
        comments = ('Ok', 'Believe it', "Sounds right")
        headlines = ('MySQL is a relational DB',
                     'Postgres is a really good relational DB',
                     'Neo4J is a graph DB')

        self.entries = [
            Entry(headline=headline, blog=blog) for headline in headlines
        ]
        for entry in self.entries:
            entry.save()

        self.authors = [Author(name=name) for name in authors]
        for author in self.authors:
            author.save()

        self.comments = [
            Comment(comment=comment, entry=entry)
            for comment, entry in zip(comments, self.entries)
        ]
        for comment in self.comments:
            comment.save()

        for i, entry in enumerate(self.entries):
            entry.authors.add(self.authors[i])
            entry.authors.add(self.authors[(i + 1) % len(self.authors)])

        model_registry.register(curious_tests.models)
Exemplo n.º 4
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blogs = [blog]

    authors = ('John Smith', 'Jane Doe', 'Joe Plummer')
    comments = ('Ok', 'Believe it', "Sounds right")
    headlines = ('MySQL is a relational DB',
                 'Postgres is a really good relational DB',
                 'Neo4J is a graph DB')

    self.entries = [Entry(headline=headline, blog=blog) for headline in headlines]
    for entry in self.entries:
      entry.save()

    self.authors = [Author(name=name) for name in authors]
    for author in self.authors:
      author.save()

    self.comments = [Comment(comment=comment, entry=entry) for comment, entry in zip(comments, self.entries)]
    for comment in self.comments:
      comment.save()

    for i, entry in enumerate(self.entries):
      entry.authors.add(self.authors[i])
      entry.authors.add(self.authors[(i+1)%len(self.authors)])

    model_registry.register(curious_tests.models)
Exemplo n.º 5
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blogs = [blog]

    authors = ('John Smith', 'Jane Doe', 'Joe Plummer')
    headlines = ('MySQL is a relational DB',
                 'Postgres is a really good relational DB',
                 'Neo4J is a graph DB')

    self.entries = [Entry(headline=headline, blog=blog) for headline in headlines]
    for entry in self.entries:
      entry.save()

    self.authors = [Author(name=name) for name in authors]
    for author in self.authors:
      author.save()

    for entry, author in zip(self.entries, self.authors):
      entry.authors.add(author)

    for i, author in enumerate(self.authors):
      author.friends.add(self.authors[(i+1)%len(self.authors)])

    model_registry.register(curious_tests.models)
Exemplo n.º 6
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blog = blog

    authors = ('John Smith', 'Jane Doe', 'Joe Plummer', 'Jessical Jones')
    headlines = ('MySQL is a good relational DB',
                 'Postgres is a really good relational DB',
                 'Neo4J is a graph DB',
                 'But we are not comparing relational and graph DBs')

    self.entries = [Entry(headline=headline, blog=blog) for headline in headlines]
    for entry in self.entries:
      entry.save()

    self.entries[1].response_to = self.entries[0]
    self.entries[1].save()
    self.entries[2].response_to = self.entries[1]
    self.entries[2].save()
    self.entries[3].response_to = self.entries[2]
    self.entries[3].save()

    self.authors = [Author(name=name, age=30) for name in authors]
    for i, author in enumerate(self.authors):
      author.save()

    for i, entry in enumerate(self.entries):
      entry.authors.add(self.authors[i])

    model_registry.register(curious_tests.models)
Exemplo n.º 7
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blog = blog

    headlines = ['MySQL is a relational DB']*TestQueryAPI.N
    self.entries = [Entry(headline=headline, blog=blog) for i, headline in enumerate(headlines)]
    for entry in self.entries:
      entry.save()

    # register model
    model_registry.register(curious_tests.models)
Exemplo n.º 8
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blog = blog

    # add custom rel
    Blog.blog_to_my_models_ = blog_to_my_models_

    # register model
    model_registry.register(Blog)
    model_registry.register(MyModel)
    model_registry.get_manager('Blog').allowed_relationships = ['blog_to_my_models_']
Exemplo n.º 9
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blog = blog

    headlines = ['MySQL is a relational DB']*TestBatchFetch.N
    self.entries = [Entry(headline=headline, blog=blog) for i, headline in enumerate(headlines)]
    for entry in self.entries:
      entry.save()

    # register model
    model_registry.register(curious_tests.models)
    model_registry.get_manager('Blog').allowed_relationships = ['authors']
Exemplo n.º 10
0
    def setUp(self):
        self.blogs = [Blog(name='A'), Blog(name='C'), Blog(name='B')]
        for b in self.blogs:
            b.save()

        headlines = ('A entry', 'C entry', 'B entry')
        self.entries = [
            Entry(headline=headline, blog=self.blogs[i])
            for i, headline in enumerate(headlines)
        ]
        for entry in self.entries:
            entry.save()

        model_registry.register(curious_tests.models)
Exemplo n.º 11
0
  def setUp(self):
    self.blog = Blog(name='Databases')
    self.blog.save()

    self.entries = [Entry(headline='Abc {}'.format(i), blog=self.blog) for i in xrange(self.N)]
    for index, entry in enumerate(self.entries):
      if index < len(self.entries) - 1:
        entry.related_blog_id = self.entries[index + 1].pk

    for entry in self.entries:
      entry.save()

    self.query_count = len(connection.queries)
    model_registry.register(curious_tests.models)
    Blog.entry_ = remote_fk('entry_id', Entry)
    Entry.related_blog_ = remote_fk('related_blog_id', Entry)
    model_registry.get_manager('Entry').allowed_relationships = [
      'related_blog_',
    ]
Exemplo n.º 12
0
    def setUp(self):
        blog = Blog(name='Databases')
        blog.save()
        self.blog = blog

        authors = ('John Smith', 'Jane Doe', 'Joe Plummer', 'Jessical Jones')
        headlines = ('MySQL is a good relational DB',
                     'Postgres is a really good relational DB',
                     'Neo4J is a graph DB',
                     'But we are not comparing relational and graph DBs')

        self.entries = [
            Entry(headline=headline, blog=blog) for headline in headlines
        ]
        for entry in self.entries:
            entry.save()

        self.entries[1].response_to = self.entries[0]
        self.entries[1].save()
        self.entries[2].response_to = self.entries[1]
        self.entries[2].save()
        self.entries[3].response_to = self.entries[2]
        self.entries[3].save()

        self.authors = [Author(name=name, age=30) for name in authors]
        for i, author in enumerate(self.authors):
            author.save()

        for i, entry in enumerate(self.entries):
            entry.authors.add(self.authors[i])

        model_registry.register(curious_tests.models)

        qs = 'Blog(%s) Blog.entry_set(headline__icontains="MySQL")' % self.blog.pk
        query = Query(qs)
        result = query()
        self.assertEquals(result[0][0][1], -1)
        assertQueryResultsEqual(self, result[0][0][0],
                                [(self.entries[0], None)])
        self.assertEquals(result[1], Entry)
Exemplo n.º 13
0
    def setUp(self):
        self.blog = Blog(name='Databases')
        self.blog.save()

        self.entries = [
            Entry(headline='Abc {}'.format(i), blog=self.blog)
            for i in xrange(self.N)
        ]
        for index, entry in enumerate(self.entries):
            if index < len(self.entries) - 1:
                entry.related_blog_id = self.entries[index + 1].pk

        for entry in self.entries:
            entry.save()

        self.query_count = len(connection.queries)
        model_registry.register(curious_tests.models)
        Blog.entry_ = remote_fk('entry_id', Entry)
        Entry.related_blog_ = remote_fk('related_blog_id', Entry)
        model_registry.get_manager('Entry').allowed_relationships = [
            'related_blog_',
        ]
Exemplo n.º 14
0
  def setUp(self):
    blog = Blog(name='Databases')
    blog.save()
    self.blog = blog

    authors = ('John Smith', 'Jane Doe', 'Joe Plummer', 'Jessical Jones')
    headlines = ('MySQL is a good relational DB',
                 'Postgres is a really good relational DB',
                 'Neo4J is a graph DB',
                 'But we are not comparing relational and graph DBs')

    self.entries = [Entry(headline=headline, blog=blog) for headline in headlines]
    for entry in self.entries:
      entry.save()

    self.entries[1].response_to = self.entries[0]
    self.entries[1].save()
    self.entries[2].response_to = self.entries[1]
    self.entries[2].save()
    self.entries[3].response_to = self.entries[2]
    self.entries[3].save()

    self.authors = [Author(name=name, age=30) for name in authors]
    for i, author in enumerate(self.authors):
      author.save()

    for i, entry in enumerate(self.entries):
      entry.authors.add(self.authors[i])

    model_registry.register(curious_tests.models)
    
    qs = 'Blog(%s) Blog.entry_set(headline__icontains="MySQL")' % self.blog.pk
    query = Query(qs)
    result = query()
    self.assertEquals(result[0][0][1], -1)
    assertQueryResultsEqual(self, result[0][0][0], [(self.entries[0], None)])
    self.assertEquals(result[1], Entry)