def test_build_binary_schedule(self):
     schedule = Schedule(version=2, originator='Global Radio')
     epg = Epg(schedule=schedule)
     
     programme = Programme(213456, crid='crid://bbc.co.uk/4969758988')
     
     programme.names.append(MediumName('Gilles Peterson'))
     programme.names.append(LongName('Gilles Peterson: Worldwide'))
     
     location = Location()
     location.times.append(Time(datetime.datetime(2003, 12, 18, 0, 0, 0, 0), datetime.timedelta(hours=2), actual_time=datetime.datetime(2003, 12, 18, 0, 0, 0, 0), actual_duration=datetime.timedelta(hours=2)))
     location.bearers.append(Bearer('e1.ce15.c221.0'))
     programme.locations.append(location)
     
     programme.media.append(ShortDescription('Gilles Peterson brings you two hours of global beats and the best of cool. Including the Worldwide family. KV5 are live from Maida Value with special guests.'))
     
     programme.genres.append(Genre('urn:tva:metadata:cs:ContentCS:2002:3.6.7', name='Rap/Hip Hop/Reggae'))
     
     programme.memberships.append(Membership(1000, crid='crid://www.bbc.co.uk/WorldwideGroup'))
     
     programme.links.append(Link('mailto:[email protected]', description='Email:'))
     
     event1 = ProgrammeEvent(6353, crid='crid://www.bbc.co.uk;dab/BC81123456a', recommendation=True)
     event1.names.append(ShortName('Herbert'))
     event1.names.append(MediumName('Herbert Live'))
     event1.names.append(LongName('Live session from Herbert'))
     event_location = Location(times=[RelativeTime(datetime.timedelta(minutes=45), datetime.timedelta(minutes=15))])
     event1.locations.append(event_location)
     event1.media.append(ShortDescription('Live session from Herbert, recorded at Cargo on 24/2/01'))
     programme.events.append(event1)
     
     event2 = ProgrammeEvent(59033)
     event2.names.append(MediumName('PM'))
     event2.locations.append(Location(times=[Time(datetime.datetime(2003, 12, 18, 17, 0, 0, 0), datetime.timedelta(hours=1))], bearers=[Bearer('e1.ce15.c224.0')]))
     programme.events.append(event2)
     
     schedule.programmes.append(programme)
     data = marshall(epg)
     print data
    def test_build_binary_schedule(self):
        schedule = Schedule(version=2, originator='Global Radio')
        epg = Epg(schedule=schedule)

        programme = Programme(213456, crid='crid://bbc.co.uk/4969758988')

        programme.names.append(MediumName('Gilles Peterson'))
        programme.names.append(LongName('Gilles Peterson: Worldwide'))

        location = Location()
        location.times.append(
            Time(datetime.datetime(2003, 12, 18, 0, 0, 0, 0),
                 datetime.timedelta(hours=2),
                 actual_time=datetime.datetime(2003, 12, 18, 0, 0, 0, 0),
                 actual_duration=datetime.timedelta(hours=2)))
        location.bearers.append(Bearer('e1.ce15.c221.0'))
        programme.locations.append(location)

        programme.media.append(
            ShortDescription(
                'Gilles Peterson brings you two hours of global beats and the best of cool. Including the Worldwide family. KV5 are live from Maida Value with special guests.'
            ))

        programme.genres.append(
            Genre('urn:tva:metadata:cs:ContentCS:2002:3.6.7',
                  name='Rap/Hip Hop/Reggae'))

        programme.memberships.append(
            Membership(1000, crid='crid://www.bbc.co.uk/WorldwideGroup'))

        programme.links.append(
            Link('mailto:[email protected]', description='Email:'))

        event1 = ProgrammeEvent(6353,
                                crid='crid://www.bbc.co.uk;dab/BC81123456a',
                                recommendation=True)
        event1.names.append(ShortName('Herbert'))
        event1.names.append(MediumName('Herbert Live'))
        event1.names.append(LongName('Live session from Herbert'))
        event_location = Location(times=[
            RelativeTime(datetime.timedelta(
                minutes=45), datetime.timedelta(minutes=15))
        ])
        event1.locations.append(event_location)
        event1.media.append(
            ShortDescription(
                'Live session from Herbert, recorded at Cargo on 24/2/01'))
        programme.events.append(event1)

        event2 = ProgrammeEvent(59033)
        event2.names.append(MediumName('PM'))
        event2.locations.append(
            Location(times=[
                Time(datetime.datetime(2003, 12, 18, 17, 0, 0, 0),
                     datetime.timedelta(hours=1))
            ],
                     bearers=[Bearer('e1.ce15.c224.0')]))
        programme.events.append(event2)

        schedule.programmes.append(programme)
        data = marshall(epg)
        print data
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#===============================================================================

from dabepg import * 
from dabepg.bands import BAND_5A
from dabepg.binary import marshall

info = ServiceInfo()
ensemble = Ensemble(ContentId('e1', 'cfff'))
info.ensembles.append(ensemble)
ensemble.frequencies.append(BAND_5A)
ensemble.names.append(ShortName('Demo'))
ensemble.names.append(MediumName('Demo Mux'))

# Service
service = Service(ContentId('e1', 'cfff', 'c0fe', '0'))
service.names.append(ShortName('Service'))
service.names.append(MediumName('Service'))
service.media.append(Multimedia('http://www.capitalfm.com/logos/32x32.png', Multimedia.LOGO_COLOUR_SQUARE))
service.media.append(Multimedia('http://www.capitalfm.com/logos/320x240.png', Multimedia.LOGO_UNRESTRICTED, width=320, height=240))
ensemble.services.append(service)

print marshall(info)