'If the course structure exists in the database, the view should return the data. Otherwise, the view should
initiate an asynchronous course structure generation and return a 503.'

def test_get(self):

    CourseStructure.objects.all().delete()
    self.assertFalse(CourseStructure.objects.filter(course_id=self.course.id).exists())
    response = self.http_get_for_course()
    self.assertEqual(response.status_code, 503)
    self.assertEqual(response['Retry-After'], '120')
    self.assertTrue(CourseStructure.objects.filter(course_id=self.course.id).exists())
    response = self.http_get_for_course()
    self.assertEqual(response.status_code, 200)
    blocks = {}
    def add_block(xblock):
        children = xblock.get_children()
        blocks[unicode(xblock.location)] = {u'id': unicode(xblock.location), u'type': xblock.category, u'parent': None, u'display_name': xblock.display_name, u'format': xblock.format, u'graded': xblock.graded, u'children': [unicode(child.location) for child in children]}
        for child in children:
            add_block(child)
    course = self.store.get_course(self.course.id, depth=None)
    add_block(course)
    expected = {u'root': unicode(self.course.location), u'blocks': blocks}
    self.maxDiff = None
    self.assertDictEqual(response.data, expected)
