'This verifies a bug we had where inherited metadata was getting written to the
module as \'own-metadata\' when publishing. Also verifies the metadata inheritance is
properly computed'

def test_draft_metadata(self):

    course = self.store.update_item(self.course, self.user.id)
    course.graceperiod = timedelta(days=1, hours=5, minutes=59, seconds=59)
    course = self.store.update_item(course, self.user.id)
    problem = self.store.get_item(self.problem.location)
    self.assertEqual(problem.graceperiod, course.graceperiod)
    self.assertNotIn('graceperiod', own_metadata(problem))
    self.store.convert_to_draft(problem.location, self.user.id)
    problem = self.store.get_item(problem.location)
    self.assertEqual(problem.graceperiod, course.graceperiod)
    self.assertNotIn('graceperiod', own_metadata(problem))
    self.store.publish(problem.location, self.user.id)
    problem = self.store.get_item(problem.location)
    self.assertEqual(problem.graceperiod, course.graceperiod)
    self.assertNotIn('graceperiod', own_metadata(problem))
    self.store.convert_to_draft(problem.location, self.user.id)
    problem = self.store.get_item(problem.location)
    new_graceperiod = timedelta(hours=1)
    self.assertNotIn('graceperiod', own_metadata(problem))
    problem.graceperiod = new_graceperiod
    problem.save()
    self.assertIn('graceperiod', own_metadata(problem))
    self.assertEqual(problem.graceperiod, new_graceperiod)
    self.store.update_item(problem, self.user.id)
    problem = self.store.get_item(problem.location)
    self.assertIn('graceperiod', own_metadata(problem))
    self.assertEqual(problem.graceperiod, new_graceperiod)
    self.store.publish(problem.location, self.user.id)
    self.store.convert_to_draft(problem.location, self.user.id)
    problem = self.store.get_item(problem.location)
    self.assertIn('graceperiod', own_metadata(problem))
    self.assertEqual(problem.graceperiod, new_graceperiod)
