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',))
 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',))
 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, [])
 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, [])
 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)
 def test_local_key_can_be_accessed(self):
     article = LKArticle(name='A')
     self.assertEqual(article.author_id, None)
 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)
 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)