TireSwingSoftware / openassign-server

OpenAssign server intended for use by a separate client via RPC
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Room.venue_address raises when address is None #83

Closed mhrivnak closed 12 years ago

mhrivnak commented 12 years ago

The property "venue_address" on models.Room incorrectly assumes that venue will have an address. If it does not, an exception is raised.

This seems to be demonstrated already in a failing unit test. I'm not sure how this came to be checked in while failing.

======================================================================
ERROR: test_view (pr_services.pr_tests.TestSessionManager)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mhrivnak/git/openassign-server/pr_services/pr_tests.py", line 1313, in test_view
    ret = self.session_manager.detailed_surr_view()
  File "/home/mhrivnak/git/openassign-server/pr_services/testlib/__init__.py", line 75, in _wrapper
    return method(token, *args, **kwargs)
  File "/home/mhrivnak/git/openassign-server/pr_services/event_system/session_manager.py", line 341, in detailed_surr_view
    ret = Utils.merge_queries(ret, facade.managers.RoomManager(), auth_token, ['name', 'venue_name', 'venue_address'], 'room')
  File "/home/mhrivnak/git/openassign-server/pr_services/utils/__init__.py", line 90, in merge_queries
    {'member' : {'id' : q2_ids}}, q2_requested_fields)
  File "/home/mhrivnak/git/openassign-server/pr_services/object_manager.py", line 187, in get_filtered
    result = self.Filter(self)._filter_common(auth_token, filters, field_names)
  File "/home/mhrivnak/git/openassign-server/pr_services/object_manager.py", line 277, in _filter_common
    return facade.subsystems.Getter(auth_token, self.my_manager, query_set, field_names).results
  File "/home/mhrivnak/git/openassign-server/pr_services/gettersetter.py", line 70, in __init__
    self.process(auth_token, requested_fields)
  File "/home/mhrivnak/git/openassign-server/pr_services/gettersetter.py", line 78, in process
    ret[f] = self.getters[f](item, f)
  File "/home/mhrivnak/git/openassign-server/pr_services/gettersetter.py", line 87, in get_general
    return getattr(result_object, field_name)
  File "/home/mhrivnak/git/openassign-server/pr_services/pr_models.py", line 1937, in venue_address
    return self.venue.address.address_dict
  File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/fields/related.py", line 315, in __get__
    rel_obj = QuerySet(self.field.rel.to).using(db).get(**params)
  File "/home/mhrivnak/pythons/openassign/lib/python2.6/site-packages/django/db/models/query.py", line 349, in get
    % self.model._meta.object_name)
DoesNotExist: Address matching query does not exist.
mhrivnak commented 12 years ago

This may be a fixture problem. The fixture "legacy_objects.json" shows this venue with an address FK of "1", but I don't see in any fixture that an address entry is created to match it.

jc0n commented 12 years ago

Interesting. I wouldnt have checked in with a failing test. For some reason that test isn't failing for me. I think you're right about the issue and I'll fix the fixture.

jc0n commented 12 years ago

I'm guessing venue_address should just be None when there is no address.

jc0n commented 12 years ago

Checkout the issue/83 branch and let me know if the test is still failing.

mhrivnak commented 12 years ago

Interestingly, it is currently passing for me on both the dev and issue/83 branches.