[TIP] Please help for StorageMediaNotFound

Madhusudan C.S madhusudancs at gmail.com
Wed Nov 18 12:48:59 PST 2009


Hi Kumar,

On Thu, Nov 19, 2009 at 2:04 AM, Kumar McMillan <kumar.mcmillan at gmail.com>wrote:

> Every one of your dataset classes must descend from DataSet.  Your
> class HostData does not which is why you got the error.
>
> Yeah understood now. My tests are running well along with fixture. Fixture
is awesome. Thanks for the wonderful tool. Thanks for all the help too.
Worth investing time to get it up and running. I am reaping the benefits
now.


>  On Wed, Nov 18, 2009 at 2:04 PM, Madhusudan C.S <madhusudancs at gmail.com>
> wrote:
> > Hi Kumar,
> >     Thank you again for the response.
> >
> > On Thu, Nov 19, 2009 at 12:18 AM, Kumar McMillan <
> kumar.mcmillan at gmail.com>
> > wrote:
> >>
> >> On Wed, Nov 18, 2009 at 12:34 PM, Madhusudan C.S <
> madhusudancs at gmail.com>
> >> wrote:
> >> > The data models for our app doesn't reside in a single Python module,
> >> > but
> >> > spread across several Python modules in the package called models.
> >> >
> >> > Can you please tell me what should I do in this case? How should my
> >> >
> >> > datafixture = GoogleDatastoreFixture(env=models,
> >> > style=NamedDataStyle())  #
> >> > Note models is a package containing models in each file, for example
> >> > user
> >> > model is in the module user.py.
> >> > self.data = datafixture.data(datasets.UserData)
> >>
> >> ok, I see.  The env keyword can be a dictionary.  So you can type out
> >> every model class, like:
> >>
> >> env={'User': models.User, 'Other': other_models.Other, ...}
> >>
> >> but if that's not feasible then you'll have to make a proxy that acts
> >> like a dictionary.  Something like this should work:
> >>
> >> class MultiModuleEnv(object):
> >>
> >>    def __init__(self, modules):
> >>        self.modules = modules
> >>
> >>    def __getitem__(self, name):
> >>        for m in self.modules:
> >>            if hasattr(m, name):
> >>                return getattr(m, name)
> >>        raise KeyError("%s not found in %r" % (name, self.modules))
> >>
> >> datafixture = GoogleDatastoreFixture(env=MultiModuleEnv([models,
> >> other_models, more_models]), ...)
> >
> > I have exactly the same
> > thing I get the error,
> >
> > ======================================================================
> > ERROR: testCreateRedirect
> > (tests.app.soc.modules.ghop.views.models.test_task.TaskTest)
> > ----------------------------------------------------------------------
> > Traceback (most recent call last):
> >   File
> >
> "/media/python/workspace/melange-ghop-integration/tests/app/soc/modules/ghop/views/models/test_task.py",
> > line 146, in setUp
> >     self.data.setup()
> >   File
> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/base.py",
> > line 70, in setup
> >     for ds in iter(self.datasets)])
> > AttributeError: class HostData has no attribute 'shared_instance'
> >
> > I am pasting my test class's setUp method here:
> >
> > def setUp(self):
> >     """Set up required for the view tests.
> >     """
> >
> >     self.view = TestView()
> >     self.stubout = stubout.StubOutForTesting()
> >     self.stubout.Set(responses, 'respond', respond_raw)
> >     self.stubout.Set(responses, 'errorResponse', error_raw)
> >
> >     # using fixtures to setup data
> >     models_dict = {
> >         'UserData': models.user.User,
> >         'SiteData': models.site.Site,
> >         'SponsorData': models.sponsor.Sponsor,
> >         'HostData': models.host.Host,
> >         'TimelineData': models.timeline.Timeline,
> >         'ProgramData': models.program.Program,
> >         'OrgData': models.organization.Organization,
> >         'OrgAdminData': models.org_admin.OrgAdmin,
> >         'MentorData': models.mentor.Mentor,
> >         'StudentData': models.student.Student,
> >         }
> >
> >     datafixture = GoogleDatastoreFixture(env=models_dict,
> >                                          style=NamedDataStyle())
> >
> >     self.data = datafixture.data(datasets.UserData, datasets.SiteData,
> >                                  datasets.SponsorData, datasets.HostData,
> >                                  datasets.TimelineData,
> > datasets.ProgramData,
> >                                  datasets.OrgData, datasets.OrgAdminData,
> >                                  datasets.MentorData,
> datasets.MentorData)
> >     self.data.setup()
> >
> > And my datasets file:
> >
> > __all__ = ['UserData', 'SiteData', 'SponsorData', 'HostData',
> 'MentorData',
> > 'OrgData', 'OrgAdminData',
> >            'ProgramData', 'StudentData', 'TimelineData']
> >
> >
> > class UserData(DataSet):
> >   class site_admin:
> >     key_name = 'site_admin'
> >     link_id = 'site_admin'
> >     account = users.User(email='site_admin at example.com')
> >     name = 'Site Admin'
> >
> >   class melange_admin:
> >     key_name = 'melange_admin'
> >     link_id = 'melange_admin'
> >     account = users.User(email='melange_admin at example.com')
> >     name = 'Melange Admin'
> >
> >   class melange_mentor:
> >     key_name = 'melange_mentor'
> >     link_id = 'melange_mentor'
> >     account = users.User(email='melange_mentor at example.com')
> >     name = 'Melange Mentor'
> >
> >   class melange_student_0001:
> >     key_name = 'melange_student_0001'
> >     link_id = 'melange_student_0001'
> >     account = users.User(email='melange_student_0001 at example.com')
> >     name = 'Melange Student 0001'
> >
> >   class melange_student_0002:
> >     key_name = 'melange_student_0002'
> >     link_id = 'melange_student_0002'
> >     account = users.User(email='melange_student_0002 at example.com')
> >     name = 'Melange Student 0002'
> >
> >
> > class SiteData(DataSet):
> >   class site:
> >     key_name = 'site'
> >     link_id = 'site'
> >
> >
> > class SponsorData(DataSet):
> >   class google:
> >     key_name = 'google'
> >     link_id = 'google'
> >     name = 'Google Inc.'
> >     short_name = 'Google'
> >     founder = UserData.site_admin
> >     home_page = 'http://www.google.com'
> >     email = 'ospo at google.com'
> >     description = 'This is the profile for Google.'
> >     contact_street = 'Some Street'
> >     contact_city = 'Some City'
> >     contact_country = 'United States'
> >     contact_postalcode = '12345'
> >     phone = '1-555-BANANA'
> >     status = 'active'
> >
> >
> > class HostData:
> >   class google:
> >     key_name = 'google/test'
> >     link_id = 'test'
> >     scope = SponsorData.google
> >     scope_path = 'google'
> >     user = UserData.site_admin
> >     given_name = 'Test'
> >     surname = 'Example'
> >     name_on_documents = 'Test Example'
> >     email = 'test at example.com'
> >     res_street = 'Some Street'
> >     res_city = 'Some City'
> >     res_state = 'Some State'
> >     res_country = 'United States'
> >     res_postalcode = '12345'
> >     phone = '1-555-BANANA'
> >     birth_date = db.DateProperty.now()
> >     agreed_to_tos = True
> >
> > ... and it continous. I guess, this happening because of the
> > ReferenceProperty there. But I am not able to find out why
> > this error is happening and how it must be fixed. Can you
> > please help me?
> >>
> >> >
> >> > be rewritten. Please help me.
> >> >
> >> >>
> >> >> >
> >> >> > Traceback (most recent call last):
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/tests/app/soc/modules/ghop/views/models/test_task.py",
> >> >> > line 130, in setUp
> >> >> >     self.data.setup()
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/base.py",
> >> >> > line 71, in setup
> >> >> >     self.loader.load(self.data)
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
> >> >> > line 193, in load
> >> >> >     self.wrap_in_transaction(loader, unloading=False)
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
> >> >> > line 310, in wrap_in_transaction
> >> >> >     routine()
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
> >> >> > line 192, in loader
> >> >> >     self.load_dataset(ds)
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
> >> >> > line 217, in load_dataset
> >> >> >     self.attach_storage_medium(ds)
> >> >> >   File
> >> >> >
> >> >> >
> >> >> >
> "/media/python/workspace/melange-ghop-integration/eggs/fixture-1.3.1-py2.5.egg/fixture/loadable/loadable.py",
> >> >> > line 375, in attach_storage_medium
> >> >> >     self.Medium, ds.meta.storable_name, ds, repr_env))
> >> >> > StorageMediaNotFound: could not find <class
> >> >> > 'fixture.loadable.google_datastore_loadable.EntityMedium'> 'User'
> for
> >> >> > dataset <UserData at 0xa84decc with keys ['user_0001']> in self.env
> >> >> > (<type
> >> >> > 'module'>)
> >> >> >
> >> >> > Can some one please tell me why I get this error and what I should
> to
> >> >> > do
> >> >> > to
> >> >> > fix this?
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Thanks and regards,
> >> >> >  Madhusudan.C.S
> >> >> >
> >> >> > Blogs at: www.madhusudancs.info
> >> >> > My Online Identity: madhusudancs
> >> >> >
> >> >> > _______________________________________________
> >> >> > testing-in-python mailing list
> >> >> > testing-in-python at lists.idyll.org
> >> >> > http://lists.idyll.org/listinfo/testing-in-python
> >> >> >
> >> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Thanks and regards,
> >> >  Madhusudan.C.S
> >> >
> >> > Blogs at: www.madhusudancs.info
> >> > My Online Identity: madhusudancs
> >> >
> >
> >
> >
> > --
> > Thanks and regards,
> >  Madhusudan.C.S
> >
> > Blogs at: www.madhusudancs.info
> > My Online Identity: madhusudancs
> >
>



-- 
Thanks and regards,
 Madhusudan.C.S

Blogs at: www.madhusudancs.info
My Online Identity: madhusudancs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20091119/a3a4ae46/attachment-0001.htm>


More information about the testing-in-python mailing list