Example #1
0
    def test_user_creation_and_editing(self):
        test_user = users.User('*****@*****.**')
        new = Customer.create(url='test', user=test_user)
        self.assertTrue(new)
        self.assertEqual(Customer.get_points_for('test').__len__(), 0)
        self.assertTrue(Point.create_point(new, dict(lat=63.345, lon= -4.23)))
        self.assertEqual(Customer.get_points_for('test').__len__(), 1)

        self.assertRaises(Exception, Customer.create, url='test', user=users.User('*****@*****.**'))
        self.assertRaises(Exception, Customer.create, url='TeSt', user=users.User('*****@*****.**'))
        self.assertRaises(Exception, Customer.create, url='new_test', user=test_user)

        renew = Customer.create(url='newtest', user=test_user)
        self.assertTrue(renew)
        self.assertEqual(Customer.get_points_for('newtest').__len__(), 1)
        self.assertTrue(Point.create_point(renew, dict(lat=43.345, lon= -3.23)))
        self.assertEqual(Customer.get_points_for('newtest').__len__(), 2)
Example #2
0
 def test_setting_points_for_user(self):
     mom = models.Customer(user=users.User('*****@*****.**'), url='momurl')
     mom.put()
     confirmation = Point.create_point(mom, dict(lat=34.678, lon= -44.3456))
     self.assertTrue(confirmation)
     result = Customer.get_points_for('momurl')
     self.assertEqual(len(result), 1)
     self.assertEqual(result.count(dict(lat=34.678, lon= -44.3456, title='Untitled', key=str(confirmation.key()))), 1) 
Example #3
0
    def test_point_editing(self):
        result = Customer.get_points_for('sudhirurl')
        start_count = len(result)
        new_point_dict = dict(lat=7.0, lon=7.0, title="seven")
        new_point_key = Point.create_point(self.sudhir, new_point_dict).key().__str__()
        result = Customer.get_points_for('sudhirurl')

        self.assertEqual(len(result), start_count + 1)
        self.assertTrue(self.find(result, new_point_dict))

        new_point_dict = dict(lon=7.0, lat=8.0, title='seveneight')
        Point.edit(new_point_key, new_point_dict, self.sudhir_gmail)
        new_results = Customer.get_points_for('sudhirurl')

        self.assertEqual(len(new_results), start_count + 1)
        self.assertTrue(self.find(new_results, new_point_dict))
        self.assertRaises(db.BadValueError, Point.edit, new_point_key, dict(lon=2345, lat=3, title='invalid values'), self.sudhir_gmail)
Example #4
0
def set_point(customer, new_point):
    return Point.create_point(customer, new_point)