コード例 #1
0
ファイル: test_set.py プロジェクト: fillmula/jsonclasses
 def test_set_accepts_nested_keypaths_for_instances(self):
     author = Author(name='Kieng')
     article = Article(
         **{
             'title': 'E Sai',
             'content': 'Tsê Tioh Si Kim Sieng Ua Ê Tsuê Ai',
             'author': author
         })
     article.set(**{'author.name': 'abc.def'})
     self.assertEqual(article.author.name, 'abc.def')
コード例 #2
0
ファイル: test_set.py プロジェクト: fillmula/jsonclasses
 def test_set_accepts_nested_keypaths_for_instances_in_lists(self):
     article = Article(title='T', content='C')
     author = Author(**{'name': 'Kieng', 'articles': [article]})
     author.set(**{'articles.0.title': 'QQQQQ'})
     self.assertEqual(author.articles[0].title, 'QQQQQ')
コード例 #3
0
ファイル: test_set.py プロジェクト: fillmula/jsonclasses
 def test_set_accepts_object(self):
     author = Author(name='Kieng')
     article = Article(title='E Sai',
                       content='Tsê Tioh Si Kim Sieng Ua Ê Tsuê Ai')
     article.set(author=author)
     self.assertEqual(author, article.author)
コード例 #4
0
ファイル: test_set.py プロジェクト: fillmula/jsonclasses
 def test_set_accepts_object_list(self):
     article = Article(title='Khi Sit', content='Ua Sim Lai Tsa Tiu E Tsai')
     author = Author(name='Hun')
     author.set(articles=[article])
     self.assertEqual(author.articles, [article])