def setUp(self):
     for e in Model1.all():
         e.delete()
     for e in Model2.all():
         e.delete()
     ref = Model1()
     ref.put()
     m = Model1()
     m2 = Model2()
     m2.put()
     m.string = "string"
     m.bytestring = "\00\0x"
     m.boolean = True
     m.integer = 123
     m.float_ = 22.0
     m.datetime = datetime.now()
     m.date = datetime.now().date()
     m.time = datetime.now().time()
     m.list_ = [1, 2, 3]
     m.stringlist = ["one", "two", "three"]
     m.reference = m2
     m.selfreference = ref
     m.blobreference = None  # Todo
     m.user = users.get_current_user()
     m.blob = "binary data"  # Todo
     m.text = "text"
     m.category = "category"
     m.link = "http://www.yahoo.com"
     m.email = "*****@*****.**"
     m.geopt = "1.0, 2.0"
     m.im = "http://aim.com/ [email protected]"
     m.phonenumber = "612-292-4339"
     m.postaladdress = "234 Shady Oak Rd., Eden Prairie, MN, 55218"
     m.rating = 23
     m.put()
 def tearDown(self):
     for e in Model1.all():
         e.delete()
     for e in Model2.all():
         e.delete()
Example #3
0
 def get(self):
     create_sample_data()
     return self.json_response(self.fetch_page(Model1.all()), V2_SERVICE_STRATEGY)
Example #4
0
 def get(self):
     form_data = self.request.form.cleaned_data
     page_size = form_data['page_size']
     create_sample_data(page_size)
     return self.json_response(self.fetch_page(Model1.all()), V1_SERVICE_STRATEGY)
Example #5
0
def create_sample_data(page_size=agar_json_config.DEFAULT_PAGE_SIZE):
    count = Model1.all().count()
    while count < page_size + 1:
        model1 = Model1(string='test entry %s' % count)
        model1.put()
        count += 1
 def test_property(self):
     ss = ModelStrategy(Model1) + [{"text": lambda o: "the_text"}]
     tree = ET.fromstring(to_xml(Model1.all(), ss))
     self.assertEqual(len(tree.findall(".//the_text")), 0)
 def test_change_output(self):
     ss = ModelStrategy(Model1, output_name="person") + [{"the_text": lambda o: o.text}]
     tree = ET.fromstring(to_xml(Model1.all(), ss))
     self.assertEqual(len(tree.findall(".//person")), 2)
     self.assertEqual(len(tree.findall(".//the_text")), 2)
 def test_alias(self):
     ss = ModelStrategy(Model1) + [{"the_text": "text"}]
     tree = ET.fromstring(to_xml(Model1.all(), ss))
     self.assertEqual(len(tree.findall(".//model1")), 2)
     self.assertEqual(len(tree.findall(".//the_text")), 2)
     self.assertEqual(tree.findall(".//the_text")[1].text, 'text')