예제 #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), [])
예제 #2
0
파일: test_loader.py 프로젝트: wolsen/soql
class Loaded(ModelBase):
    id = attributes.Integer('Id')
    one = attributes.Relationship('One', related_model=LoadedToOne)
    many = attributes.Relationship('Many',
                                   related_model=LoadedToMany,
                                   many=True)
예제 #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}))
예제 #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})])
예제 #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]),
예제 #6
0
파일: test_model.py 프로젝트: wolsen/soql
class AllZeRelationships(Model):
    parent = attributes.Relationship('Parent', related_model=AParent)
    children = attributes.Relationship('Children',
                                       related_model=AChild,
                                       many=True)
예제 #7
0
파일: test_model.py 프로젝트: wolsen/soql
class AChild(Model):
    id = attributes.Integer('Id')
    name = attributes.String('Name')
    mom = attributes.Relationship('Mom', related_model=AParent)
예제 #8
0
파일: test_model.py 프로젝트: wolsen/soql
 class Bar(Model):
     foos = attributes.Relationship('Foos',
                                    related_model=Foo,
                                    many=True)
예제 #9
0
파일: test_model.py 프로젝트: wolsen/soql
 class Foo(Model):
     bar = attributes.Relationship('Bar', related_model='Bar')