Skip to content
This repository has been archived by the owner on Jul 17, 2018. It is now read-only.

Commit

Permalink
delete save_from_resource in favor of get_or_create_from_resource
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Nov 11, 2014
1 parent 44b1c34 commit 9516205
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
14 changes: 0 additions & 14 deletions wjordpress/models.py
Expand Up @@ -10,7 +10,6 @@
"""
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.timezone import now

from . import managers
from .api import WPApi
Expand Down Expand Up @@ -41,19 +40,6 @@ def fetch(self): # pragma: no cover
"""
raise NotImplementedError

def save_from_resource(self, data):
"""
Takes the data from the api and applies it back to the instance.
Similar to `WPManager.get_or_create_from_resource`.
"""
field_names = self._meta.get_all_field_names()
obj_data = {k: v for k, v in data.items() if k in field_names}
obj_data['synced_at'] = now()
# WISHLIST log what changed
self.__dict__.update(obj_data)
self.save()


##########
# MODELS #
Expand Down
13 changes: 0 additions & 13 deletions wjordpress/tests/test_models.py
@@ -1,4 +1,3 @@
import json
import mock
import os

Expand All @@ -13,18 +12,6 @@
BASE_DIR = os.path.dirname(__file__)


class WPObjectModelTest(WPTestCase):
def test_save_from_resource_works(self):
# WISHLIST assert WPPostFactory.save_from_resource is from WPObjectModel
post = WPPostFactory()
self.assertFalse(post.title)

data = json.load(open(os.path.join(BASE_DIR, 'support', 'posts_521.json')))
with self.assertNumQueries(1):
post.save_from_resource(data)
self.assertTrue(post.title)


class WPSiteTest(WPTestCase):
# not a very good test, should use real data
mock_data = {
Expand Down

0 comments on commit 9516205

Please sign in to comment.