[google-appengine] Re: Using Google App Engine to implement a service which will compute in parallel many tasks ?

2009-11-18 Thread Michelschr
Sure, it is possible:

http://code.google.com/intl/fr/appengine/docs/python/taskqueue/

The problem will only be your resource consumption...

On 18 nov, 16:09, Wojciech woj...@gmail.com wrote:
 Hello,

 I'd like to know if there is any way to use Google App Engine to make
 a cloud  hosted service which will be compuing in parallel not so
 trivial tasks. I'm planning to implement raytracer engine, where
 calculations for each pixel (defining its colour) should be performed
 in the cloud.. in parallel . Is there possibility to make such thing
 using Google App Engine ? I'm affraid it's not the purpose of the
 Google App Engine, but I'd like someone to  dispel my doubts.

 And sorry for my bad english.

--

You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.




[google-appengine] Re: Does Gdata Python Client ProgrammaticLogin works in a Google App Engine Task?

2009-10-22 Thread Michelschr

Yes!

gdata.alt.appengine.run_on_appengine(client, store_tokens=False,
single_user_mode=True)

(Tanks for the stars :-)

On Oct 21, 7:42 pm, Michelschr michels...@gmail.com wrote:
 Hello everyone,

 I want to access one (and only one) spreadsheet of a user from within
 a task of a google app engine application.

 This code works in a normal request but not in a task:
     client  = gdata.spreadsheet.service.SpreadsheetsService()
     gdata.alt.appengine.run_on_appengine(client)
     client.email = 'anad...@gmail.com'
     client.password = '...'
     client.source  = '...'
     client.ProgrammaticLogin()
     feed = client.GetWorksheetsFeed(spreadKey) #

 With the Google Web interface the user can give access to
 'anad...@gmail.com' for this unique spreadsheet and everything than
 goes fine for a normal request.

 I understand that ProgrammaticLogin is normally for 'installed
 applications' because with Web apps it's better to ask the
 authorization on-line... But what strategy should we use in a task?

 I need to make some treatments on the spreadsheet and these can nicely
 be parted in tasks. Like that, I have all the benefits of tasks...

 I could copy all the feeds that I need during a normal request
 somewhere in the datastore and later read at this place from the
 tasks... But this put a lot of workload on the normal request that
 could otherwise be spread on the different tasks.

 ProgrammaticLogin has some advantage over AuthSub because I found
 problems when trying to limit the authorization scope to everything in
 only one spreadshead. And thus with authSub, it even not work in a
 normal request.

 Could someone give me ideas to solve this situation?

 Thanks in advance,

 Michel

 PS: Below the error message and trace
 Exception in request: RequestError: {'status': 404L, 'body': 'HTML
 \nHEAD\nTITLENot Found/TITLE\n/HEAD\nBODY BGCOLOR=#FF
 TEXT=#00\nH1Not Found/H1\nH2Error 404/H2\n/BODY\n/
 HTML\n', 'reason': ''}
 Traceback (most recent call last):
   File /base/python_lib/versions/third_party/django-1.0/django/core/
 handlers/base.py, line 86, in get_response
     response = callback(request, *callback_args, **callback_kwargs)
   File /base/data/home/apps/.../..._views.py, line 412, in ...
     feed        = client.GetWorksheetsFeed(spreadKey) #
   File /base/data/home/.../gdata/spreadsheet/service.py, line 126,
 in GetWorksheetsFeed
     converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
   File /base/data/home/.../gdata/service.py, line 1050, in Get
     'reason': server_response.reason, 'body': result_body}
 RequestError: {'status': 404L, 'body': 'HTML\nHEAD\nTITLENot
 Found/TITLE\n/HEAD\nBODY BGCOLOR=#FF TEXT=#00
 \nH1Not Found/H1\nH2Error 404/H2\n/BODY\n/HTML\n',
 'reason': ''}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Does Gdata Python Client ProgrammaticLogin works in a Google App Engine Task?

2009-10-21 Thread Michelschr

Hello everyone,

I want to access one (and only one) spreadsheet of a user from within
a task of a google app engine application.

This code works in a normal request but not in a task:
    client  = gdata.spreadsheet.service.SpreadsheetsService()
    gdata.alt.appengine.run_on_appengine(client)
    client.email = 'anad...@gmail.com'
    client.password = '...'
    client.source  = '...'
    client.ProgrammaticLogin()
    feed = client.GetWorksheetsFeed(spreadKey) #

With the Google Web interface the user can give access to
'anad...@gmail.com' for this unique spreadsheet and everything than
goes fine for a normal request.

I understand that ProgrammaticLogin is normally for 'installed
applications' because with Web apps it's better to ask the
authorization on-line... But what strategy should we use in a task?

I need to make some treatments on the spreadsheet and these can nicely
be parted in tasks. Like that, I have all the benefits of tasks...

I could copy all the feeds that I need during a normal request
somewhere in the datastore and later read at this place from the
tasks... But this put a lot of workload on the normal request that
could otherwise be spread on the different tasks.

ProgrammaticLogin has some advantage over AuthSub because I found
problems when trying to limit the authorization scope to everything in
only one spreadshead. And thus with authSub, it even not work in a
normal request.

Could someone give me ideas to solve this situation?

Thanks in advance,

Michel

PS: Below the error message and trace
Exception in request: RequestError: {'status': 404L, 'body': 'HTML
\nHEAD\nTITLENot Found/TITLE\n/HEAD\nBODY BGCOLOR=#FF
TEXT=#00\nH1Not Found/H1\nH2Error 404/H2\n/BODY\n/
HTML\n', 'reason': ''}
Traceback (most recent call last):
  File /base/python_lib/versions/third_party/django-1.0/django/core/
handlers/base.py, line 86, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File /base/data/home/apps/.../..._views.py, line 412, in ...
    feed        = client.GetWorksheetsFeed(spreadKey) #
  File /base/data/home/.../gdata/spreadsheet/service.py, line 126,
in GetWorksheetsFeed
    converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
  File /base/data/home/.../gdata/service.py, line 1050, in Get
    'reason': server_response.reason, 'body': result_body}
RequestError: {'status': 404L, 'body': 'HTML\nHEAD\nTITLENot
Found/TITLE\n/HEAD\nBODY BGCOLOR=#FF TEXT=#00
\nH1Not Found/H1\nH2Error 404/H2\n/BODY\n/HTML\n',
'reason': ''}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-09 Thread Michelschr

Hello,

Yes, my recommended solution only works with Netbeans6.7. (I never
seen something comparable with that level of integration and test
coverage information...) But with a little effort you can probably
adapt it to another environment...

I detailed my motivations and the patches on my mail of July 2.
Essentially it was:
1) A patch in the Netbeans test runner to invoke App Engine Patch with
that:
os.environ['RUNNING_CONTEXT'] = 'test'
os.environ['SERVER_NAME'] = 'testserver'
os.environ['SERVER_PORT'] = '80'
os.environ['SERVER_SOFTWARE'] = 'Devel'
os.environ['USER_EMAIL'] = '' # set to '' for not logged in user

from common.appenginepatch import aecmd
aecmd.PROJECT_DIR = os.getcwd() + /togae # This should be your
settings.py dir
aecmd.setup_env()

2) You should add this in your settings.py:
import os
if 'RUNNING_CONTEXT' in os.environ.keys():
DATABASE_ENGINE = 'appengine' # 'appengine' pour les tests
DATABASE_SUPPORTS_TRANSACTIONS = False
DJANGO_STYLE_MODEL_KIND = False

To make it quicker, if you hesitate to install the Netbeans IDE, I can
send you a picture of the (in colour :-) coverage information... But I
need your e-mail to do that...

Bye,

Michel

On Jul 9, 10:09 am, Andi Albrecht albrecht.a...@googlemail.com
wrote:
 On Fri, Jul 3, 2009 at 3:45 PM, Michelschrmichels...@gmail.com wrote:

  Hi,

  thanks for the explanations on how you do the testing. I assume you've
  grabbed the Rietveld test cases you've mentioned from the testing
  branch?

  I got 1 file: tests.py from this branch and the tests passed easily!

  Nice to have, I removed the os.environ['... as you asked!

  import codereview.models as models
  import codereview.engine as engine

  # Set some essential variables.
  # TODO(guido): Shouldn't InstallAppengineHelperForDjango() do this?
  #os.environ['SERVER_NAME'] = 'localhost'
  #os.environ['SERVER_PORT'] = '80'
  #os.environ['USER_EMAIL'] = ''

  These basic tests cover 31% of 5751 lines. Particularly:
  9,9% of engine
  16% of intra_region_diff
  22% of views
  (...)

  For views, I can point quickly that these portions of code are not
  tested:
   def render(self, name, value, attrs=None):
   def set_branch_choices(self, base=None):
   def get_base(self):
   def clean_base(self):
   def clean(self):
   def clean_nickname(self):
  (...)

  I suggest you make a quick try of Netbeans6.7 with my different
  patches to see that in colour... :-)

 Sorry for the delayed reply, I'm not sure which patches you're talking
 about... Does this only work with Netbeans?

 Andi



  Have a hot weekend!

  Michel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-03 Thread Michelschr

Hi,

Thanks for your comments!

The in-browser tests are a very important complement to tests with the
django client.

I will suggest first Windmill instead of Selenium because at the end I
suspect that we will arrive at a better integration with the Python
world.

I begin/prefer tests with the django client for several reasons:
- I have access to everything in python, like for example the models,
thus I can make a get, verify what append in the DB, clean some
things, try again, change os.environ... test again... You see what I
means?
- I can have an idea of the coverage of my tests and thus I see where
it could be important to make more efforts on tests first...

The big question is if it's possible to have coverage information when
running for example Windmill tests?? (I suspect this is not
straightforward, because you can get coverage information only in
child threats...)
Could anyone help-us to answer this question???

Michel

On Jul 3, 10:32 am, Akume akume...@gmail.com wrote:
 ok so i got selenium RC to work and it's probably a better solution
 for functional testing of the browser than using the internal django
 client.  why?  well because it runs in the browser via it's remote
 control server so you can test content on all browsers.  and it can
 be integrated for use with the plugin for firefox (though they need to
 fix it for firefox 3.5).

 On Jul 3, 12:53 am, Akume akume...@gmail.com wrote:

  i couldn't agree more.  google needs to make it easier for us to do
  proper testing on
  our app engine apps.  i found another solution to represent the client
  for functional
  testing.  using selenium RC.  however i'm running into an annoying
  timeout since i'm
  using gaeunit as the test runner.  if it's not one thing it's
  another.  still working
  on it.  i'll let you know how it goes.

  -akume

  On Jul 2, 2:15 pm, Michelschr michels...@gmail.com wrote:

   Hi,

   First of all, I think that Google should do the job of establishing
   good practices and environments for testing GAE applications. That's
   the only pragmatic solution! I don't means big integrated things but
   small pieces that we can easily integrate in our environment of
   choice. A lot of people like you or a newbie like me do their best to
   build just basic things and I think that a large amount of
   professionals will simply go for Django or Rails if they cannot find
   the elementary tools.

   That said, I should also mention this interesting 
   discussion:http://groups.google.com/group/google-appengine-python/browse_thread/...

   On my side, I have specific objectives and I still cannot said that my
   solution is relevant, because it's specific and not yet sufficiently
   tested. I will try to explain you everything, hoping I will forget
   nothing...

   For me, it's a poor choice to send the files with the tests to GAE.
   That's why I try to exclude Gaeunit or classic django directory
   structures.

   On the other hand, my business is to develop applications and not
   testing environments... and on the side of GAE/django integration, I
   think that App Engine Patch do a pretty good job... It would be nice
   if AEP can do for me (because Google don't do it) all the job of
   integrating the different parts when I run tests...

   Well, to conclude on my specific motivations, I like the Netbeans6.7
   IDE which offer a perfect integration of tests, with coverage
   information etc... Thus, let's describe each step at a time...

   1) The test runner should start GAE/django, is it possible to benefit
   from AEP? Here is the patch that I did to the nb_test_runner.py
   (Netbeans):
   (...)# Driver for running tests from NetBeans
   ##

   def init_gae_django(): # ++
   +
       os.environ['RUNNING_CONTEXT'] = 'test'
       os.environ['SERVER_NAME'] = 'testserver'
       os.environ['SERVER_PORT'] = '80'
       os.environ['SERVER_SOFTWARE'] = 'Devel'
       os.environ['USER_EMAIL'] = '' # set to '' for not logged in user

       from common.appenginepatch import aecmd
       aecmd.PROJECT_DIR = os.getcwd() + /togae
       aecmd.setup_env() # +++
   +

   if __name__ == '__main__':
       import unittest
       import doctest
       init_gae_django() # Here my patch and funct above
   ##
   (...)
   You should adapt this to your environment... I try to reuse the core
   business of AEP to the max, because we need a lot of patches in django
   to have the things working together... I am not sure that this is a
   good solution, comments are welcome! (so AEP shoud simply be in your
   path, Netbeans make the cwd as the root of the project and I put all
   the code in the ./togae directory, what will be send to GAE... The
   test are in a ./mytest directory, just beside... AEP will try to start
   its sample app

[google-appengine] Re: Testing GAE application best practices

2009-07-03 Thread Michelschr

Hi,

First I should also thanks you for your work on 
http://code.google.com/p/django-gae2django/
That is where I discovered Rietveld!

 thanks for the explanations on how you do the testing. I assume you've
 grabbed the Rietveld test cases you've mentioned from the testing
 branch?

I had missed this branch before you mentioned it...

For the rest, I mostly agree with you...

That said, for me, the more important point is maintenance. Who will
maintain the code we use? That is why I have tried to NOT touch the
code of App Engine Patch. If they come with a new version I just need
to extract it in my path, provided that they continue to support the
aecmd.PROJECT_DIR and aecmd.setup_env() API.

Thus, it will be very interesting if you can from outside limit

 the relevant parts of the App Engine
 Patch (not helper) to simulate the parts of an Django environment that
 were needed to run the tests (using Django's test framework as much as
 possible). At least it's only the database backend and a few lines of
 code to make manage.py's test command work.

You comments are welcome?

Michel

PS: Here I correct a bug in the correction to the setting, we need an
except:
try:
if os.environ['RUNNING_CONTEXT'] == 'test':
DATABASE_ENGINE = 'appengine' # 'appengine' pour les tests
DATABASE_SUPPORTS_TRANSACTIONS = False
DJANGO_STYLE_MODEL_KIND = False
except:
pass

APPEND_SLASH = False

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-03 Thread Michelschr

Hi,

 thanks for the explanations on how you do the testing. I assume you've
 grabbed the Rietveld test cases you've mentioned from the testing
 branch?

I got 1 file: tests.py from this branch and the tests passed easily!

Nice to have, I removed the os.environ['... as you asked!

import codereview.models as models
import codereview.engine as engine

# Set some essential variables.
# TODO(guido): Shouldn't InstallAppengineHelperForDjango() do this?
#os.environ['SERVER_NAME'] = 'localhost'
#os.environ['SERVER_PORT'] = '80'
#os.environ['USER_EMAIL'] = ''

These basic tests cover 31% of 5751 lines. Particularly:
9,9% of engine
16% of intra_region_diff
22% of views
(...)

For views, I can point quickly that these portions of code are not
tested:
  def render(self, name, value, attrs=None):
  def set_branch_choices(self, base=None):
  def get_base(self):
  def clean_base(self):
  def clean(self):
  def clean_nickname(self):
(...)

I suggest you make a quick try of Netbeans6.7 with my different
patches to see that in colour... :-)

Have a hot weekend!

Michel




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-02 Thread Michelschr

Hello,

You can simulate being logged or not by using os.environ
['USER_EMAIL']. The following tests pass on Rietveld/codereview:

from django.test.client import Client
from django.test import TestCase
import os

class Test(TestCase):
  def setUp(self):
self.client = Client()

  def testStart(self):
response = self.client.get('/')
self.failUnlessEqual(response.status_code, 200)
self.assertContains(response,'Code Review')

os.environ['USER_EMAIL'] = '' # simulate not logged in
response = self.client.get('/mine')
self.failUnlessEqual(response.status_code, 302)

os.environ['USER_EMAIL'] = 't...@example.com' # simulate logged in
response = self.client.get('/mine')
self.failUnlessEqual(response.status_code, 200)
self.assertContains(response,'Issues Created by me')

os.environ['USER_EMAIL'] = '' # simulate not logged in
response = self.client.get('/mine')
self.failUnlessEqual(response.status_code, 302)

Hope it helps,

Michel

On Jun 30, 1:33 am, Akume akume...@gmail.com wrote:
 ok,
 what about this scenario.  some of my pages require a login prior to
 seeing the content and i can't see to get this to work using the
 django
 client.  any suggestions?  this is what my test looks like so far.

 import unittest
 from django.test.client import Client

 class Test(unittest.TestCase):
   def setUp(self):
     self.client = Client()

   def testStart(self):
     response = self.client.get('/app/layout')
     self.failUnlessEqual(response.status_code, 301)

 #attempting to log in here.
     response = self.client.get('/_ah/login?continue=http%3A//localhost
 %3A8081/app/layout')
     self.failUnlessEqual(response.status_code, 302)

     # another attempt at logging in.
     #response = self.client.get('/_ah/login?email=Aliquam.nec
 %40Vestibulumante.eduaction=Logincontinue=http%3A%2F%2Flocalhost
 %3A8081%2Fapp%2Flayout')
     response = self.client.login(path='/app/layout',
 username='Aliquam.nec%40Vestibulumante.edu', password='')
     self.failUnlessEqual(response, True)

     response = self.client.get('/app/layout')
     self.failUnlessEqual(response.status_code, 200)

 On Jun 26, 12:15 pm, Michelschr michels...@gmail.com wrote:

  I had GaeUnit working on Rietveld (à la Guido...), the test:

  import unittest
  from django.test.client import Client

  class Test(unittest.TestCase):

      def testDjango(self):
          c = Client()
          response = c.get('/code')
          self.failUnlessEqual(response.status_code, 200)
          self.failIf(not ('SERVER' in response.content))

  passed, not possible (for me) to 'from django.test import TestCase'
  only from unittest.

  But it is not out of the box! You should search a lot by yourself...

  I will continue to investigate...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-02 Thread Michelschr
.__str__())
output_file.write('\n')
x = c1_dict.get(k)
output_file.write(x.keys().__str__())
output_file.write('\n')

output_file.close()


# Run coverage.py
execfile(coverage_py_file)
(...)

That's what I have up to now... It is still not really tested and thus
every comments will be welcome!
Hope it helps,

Michel

On Jul 2, 8:50 pm, Akume akume...@gmail.com wrote:
 i noticed that you're importing TestCase from django.test.
 what are you using to run your unit test? nosegae? i tried to
 implement your solution by changing the environment variable but
 still no success. i still get a status_code of 301.  i'm using
 gaeunit as my testrunner.  that may be the reason why.

 On Jul 2, 8:10 am, Michelschr michels...@gmail.com wrote:

  Hello,

  You can simulate being logged or not by using os.environ
  ['USER_EMAIL']. The following tests pass on Rietveld/codereview:

  from django.test.client import Client
  from django.test import TestCase
  import os

  class Test(TestCase):
    def setUp(self):
      self.client = Client()

    def testStart(self):
      response = self.client.get('/')
      self.failUnlessEqual(response.status_code, 200)
      self.assertContains(response,'Code Review')

      os.environ['USER_EMAIL'] = '' # simulate not logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 302)

      os.environ['USER_EMAIL'] = 't...@example.com' # simulate logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 200)
      self.assertContains(response,'Issues Created by me')

      os.environ['USER_EMAIL'] = '' # simulate not logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 302)

  Hope it helps,

  Michel

  On Jun 30, 1:33 am, Akume akume...@gmail.com wrote:

   ok,
   what about this scenario.  some of my pages require a login prior to
   seeing the content and i can't see to get this to work using the
   django
   client.  any suggestions?  this is what my test looks like so far.

   import unittest
   from django.test.client import Client

   class Test(unittest.TestCase):
     def setUp(self):
       self.client = Client()

     def testStart(self):
       response = self.client.get('/app/layout')
       self.failUnlessEqual(response.status_code, 301)

   #attempting to log in here.
       response = self.client.get('/_ah/login?continue=http%3A//localhost
   %3A8081/app/layout')
       self.failUnlessEqual(response.status_code, 302)

       # another attempt at logging in.
       #response = self.client.get('/_ah/login?email=Aliquam.nec
   %40Vestibulumante.eduaction=Logincontinue=http%3A%2F%2Flocalhost
   %3A8081%2Fapp%2Flayout')
       response = self.client.login(path='/app/layout',
   username='Aliquam.nec%40Vestibulumante.edu', password='')
       self.failUnlessEqual(response, True)

       response = self.client.get('/app/layout')
       self.failUnlessEqual(response.status_code, 200)

   On Jun 26, 12:15 pm, Michelschr michels...@gmail.com wrote:

I had GaeUnit working on Rietveld (à la Guido...), the test:

import unittest
from django.test.client import Client

class Test(unittest.TestCase):

    def testDjango(self):
        c = Client()
        response = c.get('/code')
        self.failUnlessEqual(response.status_code, 200)
        self.failIf(not ('SERVER' in response.content))

passed, not possible (for me) to 'from django.test import TestCase'
only from unittest.

But it is not out of the box! You should search a lot by yourself...

I will continue to investigate...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-07-02 Thread Michelschr
.__str__())
output_file.write('\n')
x = c1_dict.get(k)
output_file.write(x.keys().__str__())
output_file.write('\n')

output_file.close()


# Run coverage.py
execfile(coverage_py_file)
(...)

That's what I have up to now... It is still not really tested and thus
every comments will be welcome!
Hope it helps,

Michel

On Jul 2, 8:50 pm, Akume akume...@gmail.com wrote:
 i noticed that you're importing TestCase from django.test.
 what are you using to run your unit test? nosegae? i tried to
 implement your solution by changing the environment variable but
 still no success. i still get a status_code of 301.  i'm using
 gaeunit as my testrunner.  that may be the reason why.

 On Jul 2, 8:10 am, Michelschr michels...@gmail.com wrote:

  Hello,

  You can simulate being logged or not by using os.environ
  ['USER_EMAIL']. The following tests pass on Rietveld/codereview:

  from django.test.client import Client
  from django.test import TestCase
  import os

  class Test(TestCase):
    def setUp(self):
      self.client = Client()

    def testStart(self):
      response = self.client.get('/')
      self.failUnlessEqual(response.status_code, 200)
      self.assertContains(response,'Code Review')

      os.environ['USER_EMAIL'] = '' # simulate not logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 302)

      os.environ['USER_EMAIL'] = 't...@example.com' # simulate logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 200)
      self.assertContains(response,'Issues Created by me')

      os.environ['USER_EMAIL'] = '' # simulate not logged in
      response = self.client.get('/mine')
      self.failUnlessEqual(response.status_code, 302)

  Hope it helps,

  Michel

  On Jun 30, 1:33 am, Akume akume...@gmail.com wrote:

   ok,
   what about this scenario.  some of my pages require a login prior to
   seeing the content and i can't see to get this to work using the
   django
   client.  any suggestions?  this is what my test looks like so far.

   import unittest
   from django.test.client import Client

   class Test(unittest.TestCase):
     def setUp(self):
       self.client = Client()

     def testStart(self):
       response = self.client.get('/app/layout')
       self.failUnlessEqual(response.status_code, 301)

   #attempting to log in here.
       response = self.client.get('/_ah/login?continue=http%3A//localhost
   %3A8081/app/layout')
       self.failUnlessEqual(response.status_code, 302)

       # another attempt at logging in.
       #response = self.client.get('/_ah/login?email=Aliquam.nec
   %40Vestibulumante.eduaction=Logincontinue=http%3A%2F%2Flocalhost
   %3A8081%2Fapp%2Flayout')
       response = self.client.login(path='/app/layout',
   username='Aliquam.nec%40Vestibulumante.edu', password='')
       self.failUnlessEqual(response, True)

       response = self.client.get('/app/layout')
       self.failUnlessEqual(response.status_code, 200)

   On Jun 26, 12:15 pm, Michelschr michels...@gmail.com wrote:

I had GaeUnit working on Rietveld (à la Guido...), the test:

import unittest
from django.test.client import Client

class Test(unittest.TestCase):

    def testDjango(self):
        c = Client()
        response = c.get('/code')
        self.failUnlessEqual(response.status_code, 200)
        self.failIf(not ('SERVER' in response.content))

passed, not possible (for me) to 'from django.test import TestCase'
only from unittest.

But it is not out of the box! You should search a lot by yourself...

I will continue to investigate...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-06-30 Thread Michelschr

Hello,

Let's make a bit of walk together, here are some ideas:

1) I am testing Netbeans 6.7 python early access 2, and it looks
pretty fine for testing purpose (nice presentation of test results,
easy to go to the code, able to run test in the Netbeans project, but
above what I will transmit to GAE... + I still don't say that
everything is perfect, for example, it mix a bit the counting of
tests...)
http://download.netbeans.org/netbeans/6.7/python/ea2/

2) I founded yesterday these interesting links in the GAE discussion,
but I don't reden them yet:
http://domderrien.blogspot.com/2009/01/automatic-testing-of-gae-applications.html
http://blog.appenginefan.com/2008/06/unit-tests-for-google-app-engine-apps.html

3) I don't have investigated your problem in detail yet but:
a) I suppose you have read the django doc about this topic, normally,
they have material about that...
b) I am begining to investigate a bit more... It's not easy to make
that import of the django Client, I don't know in which context you
try this import... I will try to solve my one... With Netbeans 6.7,
when I try this import, it simply don't take the test any more in
consideration, silently... Thus, I tried it in a python console:
NbPython console
Python 2.5.4 (r254:67916, Apr  4 2009, 17:55:16)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
(InteractiveConsole)
 from django.test.client import Client
Traceback (most recent call last):
  File console, line 1, in module
  File /usr/lib/python2.5/site-packages/django/test/__init__.py,
line 6, in module
from django.test.testcases import TestCase
  File /usr/lib/python2.5/site-packages/django/test/testcases.py,
line 10, in module
from django.db import transaction
  File /usr/lib/python2.5/site-packages/django/db/__init__.py, line
9, in module
if not settings.DATABASE_ENGINE:
  File /usr/lib/python2.5/site-packages/django/conf/__init__.py,
line 28, in __getattr__
self._import_settings()
  File /usr/lib/python2.5/site-packages/django/conf/__init__.py,
line 57, in _import_settings
raise ImportError(Settings cannot be imported, because
environment variable %s is undefined. % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Like that I see better some problems, but I don't know if this is also
relevant for you?
If you run in a django environment like App Engine Patch, you don't
have this kind of problems because these settings are done fou you...

Hope it helps,

Michel

On Jun 30, 1:33 am, Akume akume...@gmail.com wrote:
 ok,
 what about this scenario.  some of my pages require a login prior to
 seeing the content and i can't see to get this to work using the
 django
 client.  any suggestions?  this is what my test looks like so far.

 import unittest
 from django.test.client import Client

 class Test(unittest.TestCase):
   def setUp(self):
     self.client = Client()

   def testStart(self):
     response = self.client.get('/app/layout')
     self.failUnlessEqual(response.status_code, 301)

 #attempting to log in here.
     response = self.client.get('/_ah/login?continue=http%3A//localhost
 %3A8081/app/layout')
     self.failUnlessEqual(response.status_code, 302)

     # another attempt at logging in.
     #response = self.client.get('/_ah/login?email=Aliquam.nec
 %40Vestibulumante.eduaction=Logincontinue=http%3A%2F%2Flocalhost
 %3A8081%2Fapp%2Flayout')
     response = self.client.login(path='/app/layout',
 username='Aliquam.nec%40Vestibulumante.edu', password='')
     self.failUnlessEqual(response, True)

     response = self.client.get('/app/layout')
     self.failUnlessEqual(response.status_code, 200)

 On Jun 26, 12:15 pm, Michelschr michels...@gmail.com wrote:

  I had GaeUnit working on Rietveld (à la Guido...), the test:

  import unittest
  from django.test.client import Client

  class Test(unittest.TestCase):

      def testDjango(self):
          c = Client()
          response = c.get('/code')
          self.failUnlessEqual(response.status_code, 200)
          self.failIf(not ('SERVER' in response.content))

  passed, not possible (for me) to 'from django.test import TestCase'
  only from unittest.

  But it is not out of the box! You should search a lot by yourself...

  I will continue to investigate...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-06-29 Thread Michelschr

It seems that they are some conceptual incompatibilities between GAE,
GaeUnit and what I would have prefered:

1) It seems me at bit crazy to upload the tests directories to GAE if
I only use them in local...
2) Inside GAE, you do not have access to file outside what is uploaded
3) GAEUnit execute the tests inside GAE... (by way of a django app)

Well, it's more easy if you accept to upload all your test stuff to
GAE...
But I will still try a bit to find a way to test with tests outside of
GAE??

On Jun 26, 9:15 pm, Michelschr michels...@gmail.com wrote:
 I had GaeUnit working on Rietveld (à la Guido...), the test:

 import unittest
 from django.test.client import Client

 class Test(unittest.TestCase):

     def testDjango(self):
         c = Client()
         response = c.get('/code')
         self.failUnlessEqual(response.status_code, 200)
         self.failIf(not ('SERVER' in response.content))

 passed, not possible (for me) to 'from django.test import TestCase'
 only from unittest.

 But it is not out of the box! You should search a lot by yourself...

 I will continue to investigate...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-06-26 Thread Michelschr

Still testing the test tools...
[My tests with the 'older' version of Rietveld was not significant,
this version was unfortunately based on django 1.1...]

GaeUnit seems to work for simple test on Rietveld... More later...

To make justice to App Engine Patch, I should say that I was able to
have access to the Django test framework with AEP, including the
Django test client and test coverage reports (you can see other post
about this subject...)

In the GaeUnit doc, I read: GAEUnit for Django is an Django app. So
it can be installed like other app into any Django framework based on
Google App Engine, such as app-engine-patch and Google App Engine
Helper.

Well, if I use AEP, I don't need so much GaeUnit... So I will test now
the integration in Rietveld...

On Jun 26, 1:44 pm, Waldemar Kornewald wkornew...@gmail.com wrote:

 If you already mention Django, you should also mention app-engine-
 patch which provides full unit test 
 support:http://code.google.com/p/app-engine-patch/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-06-26 Thread Michelschr

I had GaeUnit working on Rietveld (à la Guido...), the test:

import unittest
from django.test.client import Client

class Test(unittest.TestCase):

def testDjango(self):
c = Client()
response = c.get('/code')
self.failUnlessEqual(response.status_code, 200)
self.failIf(not ('SERVER' in response.content))

passed, not possible (for me) to 'from django.test import TestCase'
only from unittest.

But it is not out of the box! You should search a lot by yourself...

I will continue to investigate...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Testing GAE application best practices

2009-06-25 Thread Michelschr

Hello,

Thanks to all of you for your contributions!

On my side, following your suggestion, I tried nose-gae. It seems to
work with webapp...

Then I tried it with: http://code.google.com/p/rietveld/ which is a
sample application using django maintained by Guido van Rossum.
Unfortunately, the unit tests are still on the TODO list, and alone, I
was not able to make it work! (problems with 'application' and imports
like 'use_library' to choose the new django version...) Even with an
older version of Rietveld (to by pass the django version problem) I
add problems.

I can easily make the hypothesis that this way of using django
proposed by Guido van Rossum is a good direction...

But after all these problems with nose-gae, I am not sure that this is
the right direction for testing?

Reading again the discussions, I founded another way to explore:
http://code.google.com/p/gaeunit/

I don't know you... but I am beginning to cruelly miss some direction
from more advanced GAE developers.

I was thinking that professional developers start early with important
tests. On your wish-list I will add the importance for me to be able
to measure test coverage. (Personally I will never embark in a project
without a complete testing architecture...) I could not imagine how to
attract professional senior developers without some clear and
effective ways to test?

I read in the GAE documentation: Writing unit tests that make use of
the local service implementations that are bundled with the SDK is a
natural and healthy thing to do. This chapter describes how to
accomplish this task with...
But wait: with JUnit 3... This is extracted from:
http://code.google.com/intl/fr/appengine/docs/java/howto/unittesting.html

Yes, in Java, they have a nice How To from Google giving clear, sure,
official directions!

Thus I think that this subject of good testing is important enough for
the success of everyone's projects to ask one more time, please, could
advanced users give us directions?

Thanks in advance,

Michel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Uploading App for another person will help market adoption - Is-it possible?

2009-05-05 Thread Michelschr

Hello everyone,

After reading the docs and discussions, I still don't find how it will
be possible to upload an application for another person Google
account... Could someone give me light...?

That is the context, as I see it:
. Google App Engine is fine, particularly for companies with limited
IT staff
. GAE is also fine for IT professionals who want to develop App for
that companies

Hypothesis:
. Google will be happy to attract both: small companies and IT
specialist interested

The problem:
. Lets imagine that one person has obtain an application ID and he
want a developer to develop this App
. As I see up to now, the developer need the password of the Gmail
account to upload the App
. So what...? The person should keep this email address for the App?
He should renounce to the confidentiality of this email? He should
trust the developer? He should become an IT developer and do the
development...?

Obviously none of these solutions are ideal for mass market adoption!
As I am still new to GAE, maybe I missed some points and I will be
happy I someone could help me.

For me, the ideal solution would be something like:
The gmail account owner:
. obtain an application ID
. manage the application: quotas, billings...
. can temporarily delegate application development and uploading to a
developer
. can revoke the uploading right when he want.
The developer:
. Receive an application ID an the right to upload
. Do uploads
... (has access to some part of the dashboard ... loads, errors... Or
the owner could also send him these informations...)

I know, this is kind of wishful thinking... :-) On the other hand,
maybe it's still there and I just can't see it... Or maybe they are a
lot of other developer that will be interested by this feature??

Thus, your comments are welcome!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Uploading App for another person will help market adoption - Is-it possible?

2009-05-05 Thread Michelschr

Thanks a lot,

I missed this point in the app control panel.

Now it works fine!

On May 5, 4:52 pm, Nick Johnson (Google) nick.john...@google.com
wrote:
 Hi Michel,

 You can add additional administrators for your app in the control
 panel, and remove them when you no longer require them there.

 Failing that, your (hypothetical) contractor can develop the app
 independently, and simply send it to you to deploy.

 -Nick Johnson
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---