Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Commit

Permalink
refresh_from_db. fixes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jun 28, 2017
1 parent a8f8c4d commit 88624d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions bigbuild/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ def build(self):
view = PageDetailView()
view.build_object(self)

def sync_frontmatter(self):
def refresh_from_db(self):
"""
Reads in the frontmatter from metadata.yaml and syncs it with
the object.
Reads in the frontmatter from metadata.yaml and syncs it with the object.
"""
yaml_obj = BigBuildFrontmatterDeserializer(self.slug, self.__class__.__name__)
for field in yaml_obj._meta.fields:
Expand Down
8 changes: 4 additions & 4 deletions bigbuild/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_aml(self):
f.write("[arrayName]\nkey: value")

# Resync the object so that it opens the data file
p.sync_frontmatter()
p.refresh_from_db()

# Make sure everything matches
self.assertEqual(p.metadata['data']['foo'], "static/bar.aml")
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_csv(self):
f.write('key,bar\nvalue,value')

# Resync the object so that it opens the data file
p.sync_frontmatter()
p.refresh_from_db()

# Make sure everything matches
self.assertEqual(p.metadata['data']['foo'], "static/bar.csv")
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_json(self):
f.write('[{"key": "value"}]')

# Resync the object so that it opens the data file
p.sync_frontmatter()
p.refresh_from_db()

# Make sure everything matches
self.assertEqual(p.metadata['data']['foo'], "static/bar.json")
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_yaml(self):
f.write('- key: value')

# Resync the object so that it opens the data file
p.sync_frontmatter()
p.refresh_from_db()

# Make sure everything matches
self.assertEqual(p.metadata['data']['foo'], "static/bar.yaml")
Expand Down
2 changes: 1 addition & 1 deletion bigbuild/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_bad_metadata(self):
bad.close()

with self.assertRaises(DeserializationError):
p.sync_frontmatter()
p.refresh_from_db()

good = open(p.frontmatter_path, 'w')
good.write(yaml)
Expand Down

0 comments on commit 88624d9

Please sign in to comment.