Пример #1
0
def onair(request):
    """The onair view
    """
    datas = onair_datas()

    response = HttpResponse(mimetype='application/json; charset=utf-8')

    from json import dumps
    response.write(dumps(datas))

    return response
Пример #2
0
    def test_onair_nodatas(self):
        """
        Datas are not present in cache
        """
        cache.delete('onair_artist')
        cache.delete('onair_album')
        cache.delete('onair_title')

        datas = onair_datas()

        attends = {'artist': None,
                   'title': None,
                   'album': None}

        self.assertEqual(datas, attends)
Пример #3
0
    def test_onair(self):
        """
        Datas are present in cache
        """
        artist = 'U2'
        title = 'All I want is you'
        album = 'Rattle and Hum'

        cache.set('onair_artist', artist)
        cache.set('onair_album', album)
        cache.set('onair_title', title)

        datas = onair_datas()

        attends = {'artist': artist,
                   'title': title,
                   'album': album}

        self.assertEqual(datas, attends)