예제 #1
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)
예제 #2
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)
예제 #3
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)
예제 #4
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)
예제 #5
0
 def doGet(self):
   task = Task()
   task.title = "hello"
   return task
예제 #6
0
def GetAllTaskOfTag(tag_key):
  """Gets all tasks with the tag."""
  return Task.query().filter(Task.tags == tag_key).fetch(1000)
예제 #7
0
def GetAllTaskOfProject(project_key):
  """Gets all tasks of same project."""
  return Task.query().filter(Task.project == project_key).fetch(1000)
예제 #8
0
def GetAllActionableTasks():
  """Gets all task whose status is actionable."""
  return Task.query().filter(Task.status == str(TaskStatus.actionable)).fetch(
    1000)