def test3():
    """Franchised, Series, Seasoned, with 1 OTO"""
    p = Producer(name='BBC Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    ep1 = SeriesEpisode(name="Scandal in Belgravia")
    ep1.save()

    se = Season(name="Season 2", ordinal="2")
    se.save()

    s = Series(name='Sherlock')
    s.orgs = [p, d]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = ep1
    sa.season = se
    sa.save()

    # get the previous
    f = session.query(Franchise).filter(Franchise.name=="Masterpiece").all()[0]
    f.serieses.append(s)
    f.save()
def test4():
    """Franchised series with 1 oto"""
    p = Producer(name='Ken Burns')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    ep1 = SeriesEpisode(name="The Scripture of Nature (1851-1890)")
    ep1.save()

    se = Season(name='Season 2009', ordinal=2009)
    se.save()

    s = Series(name='The National Parks')
    s.orgs = [p, d]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = ep1
    sa.season = se
    sa.save()

    f = Franchise(name='Ken Burns')
    f.serieses = [s]
    f.save()
def test_tag():
    p = Producer(name='BBC Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    ep1 = SeriesEpisode(name="Wolf Hall Ep 1")
    ep1.save()

    se = Season(name="1", ordinal="1")
    se.save()

    s = Series(name='Wolf Hall')
    s.orgs = [p, d]
    s.save()

    s2 = Series(name='Wolf Hall Subseries')
    s2.orgs = [p, d]
    s2.save()

    #sept = SeriesEpisodeTag(series=s, episode=s2, tag='subseries')
    #sept.save()

    sept = SeriesRelationTag(parent=s, child=s2, tag='subseries')
    sept.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = ep1
    sa.season = se
    sa.save()
def test1():
    """Franchised, Series, 1 Season, 1 Ep"""
    p = Producer(name='BBC Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    ep1 = SeriesEpisode(name="Wolf Hall Ep 1")
    ep1.save()

    se = Season(name="1", ordinal="1")
    se.save()

    s = Series(name='Wolf Hall')
    s.orgs = [p, d]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = ep1
    sa.season = se
    sa.save()

    f = Franchise(name='Masterpiece')
    f.serieses.append(s)
    f.save()
def test1112():
    """Series with 1 ep (in a season) and 1 OTO (seasonless)"""
    p = Producer(name='Universal')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    se = Season(name='3', ordinal=3)
    se.save()

    e1 = SeriesEpisode(name="Go West Young Monkey")
    e1.seasons = [se,]
    e1.save()

    e2 = OneTimeOnlyEpisode(name="Curious George XMAS")
    e2.save()

    s = Series(name="Curious George")
    s.onetimeonlys = [e2,]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = e1
    sa.save()
def test7():
    """Series with Subseries and 1 Ep"""
    p = Producer(name='WGBH Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    se = Season(name='17', ordinal=17)
    se.save()

    e1 = SeriesEpisode(name="Antiques Roadshow Seattle, Ep1")
    e1.seasons = [se,]
    e1.save()

    sss = Season(name='1', ordinal=1)
    sss.save()

    ss1 = SubSeries(name="Antiques Roadshow in Seattle")
    ss1.save()

    s = Series(name="Antiques Roadshow")
    s.subseries = [ss1]
    s.seasons = [se,]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = e1
    sa.save()

    sa2 = SeasonAssociation(season=sss)
    sa2.series = ss1
    sa2.episode = e1
    sa2.save()
def test8():
    """Series with EP"""

    p = Producer(name='WETA')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    ep1 = SeriesEpisode(name="Monday, July 15th, 2014")
    ep1.save()

    s = Series(name='PBS NewsHour')
    s.orgs = [p, d]
    s.save()

    se = Season(name='29', ordinal=29)
    se.save()

    sa2 = SeasonAssociation(season=se)
    sa2.series = s
    sa2.episode = ep1
    sa2.save()
def test9():
    """WEIRD ONE: Series and Subseries of different seasons sharing the same Ep"""
    p = Producer(name='WETA Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    se = Season(name='41', ordinal=41)
    se.save()

    se2 = Season(name='2012', ordinal=2012)
    se2.save()

    e1 = SeriesEpisode(name="Democratic National Convention September 5, 2015 Part 1")
    e1.save()

    ss1 = SubSeries(name="Elections")
    #ss1.episodes = [e1,]
    ss1.seasons = [se2]
    ss1.save()

    s = session.query(Series).filter(Series.name=="PBS NewsHour").all()[0]
    #s = Series(name="PBS NewsHour")
    s.subseries = [ss1]
    s.seasons = [se,]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = e1
    sa.save()

    sa2 = SeasonAssociation(season=se2)
    sa2.series = ss1
    sa2.episode = e1
    sa2.save()
def test5():
    """Series with Ep in one season AND Subseries with Ep in a different season"""
    p = Producer(name='WGBH Productions')
    p.save()

    d = Distributor(name='PBS Distribution')
    d.save()

    se = Season(name='38', ordinal=38)
    se.save()

    se1 = Season(name='1', ordinal=1)
    se1.save()

    e1 = SeriesEpisode(name="Making Stuff Similar Episode")
    e1.save()

    e2 = SeriesEpisode(name="Making Stuff Similar Episode2")
    e2.save()

    ss1 = SubSeries(name="Making Stuff")
    ss1.save()

    s = Series(name="NOVA")
    s.subseries = [ss1]
    s.save()

    sa = SeasonAssociation(season=se)
    sa.series = s
    sa.episode = e1
    sa.save()

    sa2 = SeasonAssociation(season=se1)
    sa2.series = ss1
    sa2.episode = e2
    sa2.save()