Exemplo n.º 1
0
 def test_load_many_when_relationship_is_none(self):
     attr = attributes.Relationship('Attr',
                                    related_model=RelatedModel,
                                    many=True)
     self.assertEqual(attr.load(None), [])
Exemplo n.º 2
0
class Loaded(ModelBase):
    id = attributes.Integer('Id')
    one = attributes.Relationship('One', related_model=LoadedToOne)
    many = attributes.Relationship('Many',
                                   related_model=LoadedToMany,
                                   many=True)
Exemplo n.º 3
0
 def test_load(self):
     attr = attributes.Relationship('Attr', related_model=RelatedModel)
     data = {'attributes': {'type': 'RelatedModel'}, 'Id': 1}
     self.assertEqual(attr.load(data), RelatedModel.load({'Id': 1}))
Exemplo n.º 4
0
 def test_load_many(self):
     attr = attributes.Relationship('Attr',
                                    related_model=RelatedModel,
                                    many=True)
     data = {'records': [{'attributes': {'type': 'RelatedModel'}, 'Id': 1}]}
     self.assertEqual(attr.load(data), [RelatedModel.load({'Id': 1})])
Exemplo n.º 5
0
import unittest

from soql import attributes
from soql import Model
from soql.path_builder import PathBuilder
from tests.helpers import SoqlAssertions

# Declare the relationships separately so we can assert some stuff in the tests
# more easily...
next_ = attributes.Relationship('Next', related_model='LinkedList')
list_ = attributes.Relationship('List', related_model='LinkedList')
children = attributes.Relationship('Children',
                                   related_model='GraphNode',
                                   many=True)


class LinkedList(Model):
    id = attributes.Integer('Id')
    next = next_


class GraphNode(Model):
    id = attributes.Integer('Id')
    value = attributes.Integer('Value')
    list = list_
    children = children


class PathBuilderTest(unittest.TestCase, SoqlAssertions):
    def assertColumnNodesEqual(self, node_list, expected):
        self.assertEqual(sorted([str(node) for node in node_list]),
Exemplo n.º 6
0
class AllZeRelationships(Model):
    parent = attributes.Relationship('Parent', related_model=AParent)
    children = attributes.Relationship('Children',
                                       related_model=AChild,
                                       many=True)
Exemplo n.º 7
0
class AChild(Model):
    id = attributes.Integer('Id')
    name = attributes.String('Name')
    mom = attributes.Relationship('Mom', related_model=AParent)
Exemplo n.º 8
0
 class Bar(Model):
     foos = attributes.Relationship('Foos',
                                    related_model=Foo,
                                    many=True)
Exemplo n.º 9
0
 class Foo(Model):
     bar = attributes.Relationship('Bar', related_model='Bar')