Skip to content

Commit

Permalink
storing data in the database of pushlog info
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jun 3, 2013
1 parent 53a2a46 commit d945522
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bisectcloud/base/test/pushlog.json
@@ -0,0 +1,3 @@
{"28834": {"branch_name": "Mozilla-Inbound", "revisions": ["71cd8f642cfa"]}, "28835": {"branch_name": "Mozilla-Inbound",
"revisions": ["b5b3993fd079"]}, "28836": {"branch_name": "Mozilla-Inbound", "revisions": ["b8122753e0b3",
"121b620c7e49"]}}
22 changes: 22 additions & 0 deletions bisectcloud/base/test/test_tasks.py
@@ -0,0 +1,22 @@
import os
import json


import test_utils
import bisectcloud.site.tasks as task
from bisectcloud.site.models import *

class TaskTests(test_utils.TestCase):

def test_we_can_call_tasks(self):
pass

def test_we_can_store_json_blob_in_datastore(self):
with open(os.path.join(os.path.dirname(__file__),'pushlog.json'), 'r') as f:
jsonblob = f.read()

task._store_pushlog_in_datastore(json.loads(jsonblob))

self.assertEqual(4, len(Revisions.objects.all()))
self.assertEqual(3, len(Pushlog.objects.all()))

17 changes: 17 additions & 0 deletions bisectcloud/site/tasks.py
@@ -0,0 +1,17 @@
import requests
from models import Pushlog, Revisions

def get_pushlog():
pass

def _store_pushlog_in_datastore(push_json):
for k, v in push_json.items():
pushlog = Pushlog(push_id = k,
branch_name=push_json[k]['branch_name'])
pushlog.save()
for revision in push_json[k]['revisions']:
revisions = Revisions(revisions=revision,
pushlog=pushlog)
revisions.save()


0 comments on commit d945522

Please sign in to comment.