Exemplo n.º 1
0
 def get(self):
   tid = self.request.get('taskId', '')
   all_tasks = []
   if tid:
     task = task_dao.GetById(tid)
     if task:
       all_tasks = [task]
   else:
     all_tasks = task_dao.GetAllActionableTasks()
   self.response.write(mjson.model2json(all_tasks))
Exemplo n.º 2
0
  def test_model_2_json_enum_fields(self):
    """enum filed tests."""
    model = Task()
    model.status = 'actionable'
    model.title = 'title'

    json_string = mjson.model2json(model)

    self.assertEqual('{"status": "actionable", "title": "title"}',
                     json_string)

    parsed_model = mjson.json2model(Task, json_string)
    self.assertEqual(model, parsed_model)
Exemplo n.º 3
0
  def test_model_2_json_simple_fields(self):
    """simple json test."""
    model = Task()
    model.status = 'actionable'
    model.title = 'title'
    model.created_at = datetime.utcfromtimestamp(1390576468)

    json_string = mjson.model2json(model)
    self.assertIsNotNone(json_string, 'message is none')
    self.assertEquals(
        '{"created_at": 1390576468, "status": "actionable", ' +
        '"title": "title"}', json_string)

    parsed_model = mjson.json2model(Task, json_string)

    self.assertEqual(model, parsed_model)
Exemplo n.º 4
0
  def test_model_2_json_repeated_structure(self):
    """repeated message test."""
    model = Task()
    model.status = 'actionable'
    model.title = 'title'
    model.notes.append(TaskNote(text="text1"))
    model.notes.append(TaskNote(text="text2"))

    json_string = mjson.model2json(model)
    self.assertIsNotNone(json_string)
    self.assertEqual('{' +
                     '"notes": [{"text": "text1"}, {"text": "text2"}], ' +
                     '"status": "actionable", ' +
                     '"title": "title"}', json_string)

    parsed_model = mjson.json2model(Task, json_string)
    self.assertEqual(model, parsed_model)
Exemplo n.º 5
0
  def test_model_2_json_repeated_fields(self):
    """Repeated field test."""
    model = Task()
    model.status = 'actionable'

    model.title = 'title'
    model.tags.append("path.context1")
    model.tags.append("path.context2")

    json_string = mjson.model2json(model)
    self.assertIsNotNone(json_string)
    self.assertEqual('{"status": "actionable", ' +
                     '"tags": ["path.context1", "path.context2"], ' +
                     '"title": "title"}', json_string)

    parsed_model = mjson.json2model(Task, json_string)

    self.assertEqual(model, parsed_model)
Exemplo n.º 6
0
 def post(self):
   project = self.request.body
   m = mjson.json2model(Project, project)
   logging.info("get project: %s", m.to_dict())
   saved = project_dao.add(m.project_name)
   self.response.write(mjson.model2json(saved))
Exemplo n.º 7
0
 def get(self):
   all_projects = project_dao.get_all()
   self.response.write(mjson.model2json(all_projects))
Exemplo n.º 8
0
 def post(self):
   tag = self.request.body
   m = mjson.json2model(Tag, tag)
   logging.info("get tag: %s", m.to_dict())
   saved = tag_dao.add_tag(m.tag_name)
   self.response.write(mjson.model2json(saved))
Exemplo n.º 9
0
 def get(self):
   all_tags = tag_dao.get_all_tags()
   self.response.write(mjson.model2json(all_tags))