Ejemplo n.º 1
0
 def test_local_key_is_considered_modified_field_with_id_assign(self):
     article = LKArticle(name='A', author=None)
     author = LKAuthor(name='A')
     setattr(author, '_is_new', False)
     setattr(article, '_is_new', False)
     article.author_id = author.id
     self.assertEqual(article.modified_fields, ('author',))
Ejemplo n.º 2
0
 def test_local_key_is_considered_modified_field(self):
     author = LKAuthor(name='A')
     article = LKArticle(name='A', author=author)
     setattr(author, '_is_new', False)
     setattr(article, '_is_new', False)
     article.author = None
     self.assertEqual(article.modified_fields, ('author',))
     self.assertEqual(author.modified_fields, ('articles',))
Ejemplo n.º 3
0
 def test_object_is_set_to_none_then_local_key_is_set_to_none(self):
     author = LKAuthor(name='A')
     article = LKArticle(name='A', author=author)
     self.assertEqual(article.author, author)
     self.assertEqual(author.articles[0], article)
     article.author = None
     self.assertEqual(article.author_id, None)
     self.assertEqual(author.articles, [])
Ejemplo n.º 4
0
 def test_set_local_key_resets_object(self):
     author = LKAuthor(name='A')
     article = LKArticle(name='A', author=author)
     self.assertEqual(article.author, author)
     self.assertEqual(author.articles[0], article)
     article.author_id = 500
     self.assertEqual(article.author, None)
     self.assertEqual(author.articles, [])
Ejemplo n.º 5
0
 def test_init_should_accept_local_key(self):
     article = LKArticle(name='A', author_id=1005)
     self.assertEqual(article.author, None)
     self.assertEqual(article.author_id, 1005)
Ejemplo n.º 6
0
 def test_local_key_can_be_accessed(self):
     article = LKArticle(name='A')
     self.assertEqual(article.author_id, None)
Ejemplo n.º 7
0
 def test_set_object_modifies_local_key(self):
     author = LKAuthor(name='A')
     article = LKArticle(name='A', author=author)
     self.assertEqual(article.author_id, author.id)
Ejemplo n.º 8
0
 def test_set_should_accept_local_key_in_json_form(self):
     article = LKArticle()
     article.set(**{'name': 'A', 'authorId': 1005})
     self.assertEqual(article.author, None)
     self.assertEqual(article.author_id, 1005)