Пример #1
0
    def test_band_view_one(self):
        """
        view a band - just one
        """
        from c3sar.views.band import band_view
        band_instance = self._makeBand1()
        self.dbsession.add(band_instance)
        self.dbsession.flush()
        the_id = band_instance.id  # db id of that band
        from c3sar.models import Band
        max_id = Band.get_max_id()

        request = testing.DummyRequest()
        request.matchdict['band_id'] = the_id
        self.config = testing.setUp(request=request)
        result = band_view(request)
        self.assertTrue('band' in result, 'band was not seen.')
        self.assertTrue(
            result['prev_id'] is the_id - 1 or max_id,
            'wrong nav id.')
        self.assertTrue(
            result['next_id'] is the_id + 1 or 1,
            'wrong nav id.')
        self.assertTrue('viewer_username' in result,
                        'viewer_username was not seen.')
        self.assertTrue(result['viewer_username'] is None,
                        'viewer_username was not seen.')
Пример #2
0
 def test_band_view_None(self):
     """
     view a band -- None if none exists. redirect to not_found
     """
     from c3sar.views.band import band_view
     request = testing.DummyRequest()
     request.matchdict['band_id'] = 123456  # high id, RLY
     self.config = testing.setUp(request=request)
     _registerRoutes(self.config)
     result = band_view(request)
     # test: redirect
     self.assertTrue(isinstance(result, HTTPFound), "expected redirect")
     self.assertTrue('not_found' in result.headerlist[2][1])
     self.assertEquals(result.headerlist.pop(),
                       ('Location', 'http://example.com/not_found'),
                       "not the redirect expected")
Пример #3
0
    def test_band_view_two(self):
        """
        view a band - two bands
        """
        from c3sar.views.band import band_view
        band_instance1 = self._makeBand1()
        self.dbsession.add(band_instance1)
        band_instance2 = self._makeBand2()
        self.dbsession.add(band_instance2)
        self.dbsession.flush()

        request = testing.DummyRequest()
        request.matchdict['band_id'] = 2
        self.config = testing.setUp(request=request)
        result = band_view(request)
        self.assertTrue('band' in result, 'band was not seen.')
        self.assertTrue(result['prev_id'] is 1, 'wrong nav id.')
        self.assertTrue(result['next_id'] is 1, 'wrong nav id.')
        self.assertTrue('viewer_username' in result,
                        'viewer_username was not seen.')
        self.assertTrue(result['viewer_username'] is None,
                        'viewer_username was not seen.')