Ejemplo n.º 1
0
Archivo: tests.py Proyecto: progo/moary
 def testNothing_partial_info_noIMDB(self):
     """test non-edit with partial (no IMDB) info. Will skip the ID."""
     old_entry = Entry("ABC", rating='1', message='Nice.')
     self.set_edited_content(edit_entry.fill_in_form(old_entry))
     new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=True)
     self.assertEquals(old_entry.message, new_entry.message)
     self.assertEquals(old_entry.imdb, new_entry.imdb)
     self.assertEquals(old_entry.movie, new_entry.movie)
     self.assertEquals(old_entry.rating, new_entry.rating)
Ejemplo n.º 2
0
Archivo: tests.py Proyecto: progo/moary
 def testNothing_noIMDB(self):
     """test non-edit with full info. Skip IMDB."""
     old_entry = Entry("ABC", rating='1', imdb='0999555', message='Nice.')
     self.set_edited_content(edit_entry.fill_in_form(old_entry))
     new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=True)
     self.assertEquals(old_entry.message, new_entry.message)
     self.assertEquals(old_entry.imdb, new_entry.imdb)
     self.assertEquals(old_entry.movie, new_entry.movie)
     self.assertEquals(old_entry.rating, new_entry.rating)
Ejemplo n.º 3
0
Archivo: tests.py Proyecto: progo/moary
 def testFaultyIMDBAdd(self):
     """should clear the faulty id because no previous id provided."""
     self.set_edited_content("""Movie: def
     Rating: 4
     IMDB: vccv
     ----- Review -----
     Cool movie.
     """)
     entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
     self.assertEquals(entry.movie, "def")
     self.assertEquals(entry.rating, '4')
     self.assertEquals(entry.imdb, '')
     self.assertEquals(entry.message, "Cool movie.")
Ejemplo n.º 4
0
Archivo: tests.py Proyecto: progo/moary
 def testBadRating(self):
     """Test bad rating. should clear the bad rating to 0."""
     self.set_edited_content("""Movie: Balzone
     Rating: +
     IMDB: 
     ----- Review -----
     Cool.
     """)
     entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
     self.assertEquals(entry.movie, "Balzone")
     self.assertEquals(entry.rating, '0')
     self.assertEquals(entry.imdb, '')
     self.assertEquals(entry.message, "Cool.")
Ejemplo n.º 5
0
Archivo: tests.py Proyecto: progo/moary
 def testSimpleAddNoIMDB_noIMDB(self):
     """test a situation where no IMDB id has been provided. Should skip."""
     self.set_edited_content("""Movie: def
     Rating: 4
     IMDB: 
     ----- Review -----
     Cool movie.
     """)
     entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
     self.assertEquals(entry.movie, "def")
     self.assertEquals(entry.rating, '4')
     self.assertEquals(entry.imdb, '')
     self.assertEquals(entry.message, "Cool movie.")
Ejemplo n.º 6
0
Archivo: tests.py Proyecto: progo/moary
 def testFaultyIMDBAdd_noIMDB(self):
     """Give incorrect IMDB id. Should clear it."""
     self.set_edited_content("""Movie: def
     Rating: 4
     IMDB: vccv
     ----- Review -----
     Cool movie.
     """)
     entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
     self.assertEquals(entry.movie, "def")
     self.assertEquals(entry.rating, '4')
     self.assertEquals(entry.imdb, '')
     self.assertEquals(entry.message, "Cool movie.")
Ejemplo n.º 7
0
Archivo: tests.py Proyecto: progo/moary
    def testClearMovieName(self):
        """empty the name field. Should probably raise UserCancel."""
        old_entry = Entry("ABC", rating='1', imdb='0999555', message='Nice.')

        self.set_edited_content("""
        Movie:
        Rating: 1
        IMDB: 0999555
        ----- Review -----
        Nice, isn't it.
        """)

        self.assertRaises(edit_entry.UserCancel,
                lambda: edit_entry.edit_data_interactive({}, skip_imdb=False))
Ejemplo n.º 8
0
Archivo: tests.py Proyecto: progo/moary
    def testBadRating(self):
        """push something nonnumeric to rating. Should keep the old rating."""
        old_entry = Entry("ABC", rating='1', imdb='0999555', message='Nice.')

        self.set_edited_content("""
        Movie: ABC
        Rating: -
        IMDB: 0999555
        ----- Review -----
        Nice, isn't it.
        """)

        new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=False)
        self.assertEquals(old_entry.rating, new_entry.rating)
Ejemplo n.º 9
0
Archivo: tests.py Proyecto: progo/moary
    def testSimpleAdd_noIMDB(self):
        self.set_edited_content("""
        Movie: ABC
        Rating: 4
        IMDB:  01234
        ----- Review -----
        Cool movie.
        """)

        entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
        self.assertEquals(entry.movie, "ABC")
        self.assertEquals(entry.rating, '4')
        self.assertEquals(entry.message, "Cool movie.")
        self.assertEquals(entry.imdb, '0001234')
Ejemplo n.º 10
0
Archivo: tests.py Proyecto: progo/moary
    def testBadIMDB_skipIMDB(self):
        """full material, change to crappy imdb. Should keep the old one!"""
        old_entry = Entry("ABC", rating='1', imdb='0999555', message='Nice.')

        self.set_edited_content("""
        Movie: ABC
        Rating: 1
        IMDB: aybabtu
        ----- Review -----
        Nice, isn't it.
        """)

        new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=True)
        self.assertEquals(old_entry.movie, new_entry.movie)
        self.assertEquals(new_entry.imdb, old_entry.imdb)
Ejemplo n.º 11
0
Archivo: tests.py Proyecto: progo/moary
    def testAddNoIMDB_skipIMDB(self):
        """don't give IMDB id."""
        self.set_edited_content("""
        Movie: ABC
        Rating: 4
        IMDB:
        ----- Review -----
        Cool movie.
        """)

        entry = edit_entry.edit_data_interactive({}, skip_imdb=True)
        self.assertEquals(entry.movie, "ABC")
        self.assertEquals(entry.rating, '4')
        self.assertEquals(entry.message, "Cool movie.")
        self.assertEquals(entry.imdb, '')
Ejemplo n.º 12
0
Archivo: tests.py Proyecto: progo/moary
    def testFullAdd(self):
        """fill in full form."""
        self.set_edited_content("""
        Movie: ABC
        Rating: 4
        IMDB:  01234
        ----- Review -----
        Cool movie.
        """)
 
        entry = edit_entry.edit_data_interactive({})
        self.assertEquals(entry.movie, "ABC")
        self.assertEquals(entry.rating, '4')
        self.assertEquals(entry.message, "Cool movie.")
        self.assertEquals(entry.imdb, '0001234')
Ejemplo n.º 13
0
Archivo: moary.py Proyecto: progo/moary
def do_add(args):
    """CLI func to call when doing subtask "add". """
    # Three kinds of cases here in a mess:
    # 1. movie name provided (possibly other info) (go batch)
    # 2. movie name not provided, IMDB provided (go batch)
    # 3. neither is provided, go interactive
    # TODO refactoring needed. Replace functions and so on.
    db = data.DataFacilities(dbfile=args.db_file)
    if args.movie:
        # 1. batch
        newflick = Entry(args.movie,
                         args.rating,
                         args.imdb,
                         args.message or "")
        newflick.imdb = imdbutils.just_work_dammit(newflick,
                skip=args.skip_imdb)
    elif args.imdb:
        # 2. batch: No movie name given but something of an IMDB id
        if args.skip_imdb:
            print("Can't do this without querying IMDB!")
            return
        try:
            moviename = imdbutils.query_imdb_name(args.imdb)
            clean_id = imdbutils.clean_imdb_id(args.imdb)
        except imdbutils.BadIMDBIdException:
            print("Malformed IMDB id, aborting.")
            return
        except imdbutils.NoIMDBpyException:
            print("Can't do this without querying IMDB! (No IMDBpy)")
            return
        newflick = Entry(moviename, imdb=clean_id, rating=args.rating,
                         message=args.message or "")
    else:
        # 3. interactive
        try:
            newflick = edit_entry.edit_data_interactive(None,
                    skip_imdb=args.skip_imdb)
            if not args.skip_imdb:
                from textwrap import fill
                #triv = imdbutils.query_random_trivia(newflick.imdb)
                #if triv: print 'TRIVIA:',fill(triv )
        except edit_entry.UserCancel:
            print("Empty name, exiting...")
            return 0
    if args.debug:
        print(newflick.__dict__)
    else:
        db.store_entry(newflick)
Ejemplo n.º 14
0
Archivo: tests.py Proyecto: progo/moary
    def testClearIMDB_noIMDB(self):
        """clear the IMDB for a reason or another. ID will be cleared."""
        old_entry = Entry("ABC", rating='1', imdb='0999555', message='+1')

        self.set_edited_content("""
        Movie: ABC
        Rating: 0
        IMDB: 
        ----- Review -----
        +1
        """)

        new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=True)
        self.assertEquals(new_entry.movie, "ABC")
        self.assertEquals(new_entry.rating, '0')
        self.assertEquals(new_entry.imdb, '')
Ejemplo n.º 15
0
Archivo: tests.py Proyecto: progo/moary
    def testGoodEdit(self):
        """good edit, modify everything a bit."""
        old_entry = Entry("ABC", rating='1', imdb='0999555', message='+1')

        self.set_edited_content("""
        Movie: DEZ
        Rating: 0
        IMDB: 0999000
        ----- Review -----
        Cool!
        """)

        new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=False)
        self.assertEquals(new_entry.movie, "DEZ")
        self.assertEquals(new_entry.rating, '0')
        self.assertEquals(new_entry.message, 'Cool!')
        self.assertEquals(new_entry.imdb, '0999000')
Ejemplo n.º 16
0
Archivo: tests.py Proyecto: progo/moary
    def testGoodEdit_noIMDB(self):
        """change one bit. Skip imdb."""
        old_entry = Entry("Dland", rating='1', imdb='0999555', message='+1')
 
        self.set_edited_content("""
        Movie: DBland
        Rating: 1
        IMDB: 0999555
        ----- Review -----
        +1
        """)
 
        new_entry = edit_entry.edit_data_interactive(old_entry, skip_imdb=True)
        self.assertEquals(new_entry.movie, "DBland")
        self.assertEquals(new_entry.rating, old_entry.rating)
        self.assertEquals(new_entry.message, old_entry.message)
        self.assertEquals(new_entry.imdb, old_entry.imdb)
Ejemplo n.º 17
0
Archivo: tests.py Proyecto: progo/moary
    def testSimpleAddU8(self):
        """Test a situation everything has been provided. Try UTF8
        capabilities.  Terrible issues: IMDB query itself should be tested
        here. Well, not everything is going to be automatized and I hope we get
        away with simply trying to store proper UTF8 content to DB."""

        self.set_edited_content("""
        Movie: Yö
        Rating: 4
        IMDB:  01234
        ----- Review -----
        Sacré bleu!
        """)

        entry = edit_entry.edit_data_interactive({})
        self.assertEquals(entry.movie, "Yö")
        self.assertEquals(entry.rating, '4')
        self.assertEquals(entry.message, "Sacré bleu!")
        self.assertEquals(entry.imdb, '0001234')
Ejemplo n.º 18
0
Archivo: moary.py Proyecto: progo/moary
def do_edit(args):
    """Handle subtask "edit"."""
    db = data.DataFacilities(dbfile=args.db_file)

    try:
        lastentry = db.get_last()
    except data.EmptyDBException:
        print "Nothing in the DB!"
        return

    if args.delete:
        if args.debug:
            print "Would delete:", vars(lastentry)
            return
        else:
            db.delete_entry()
            return
    # at this point, only edit the last one
    edited = edit_entry.edit_data_interactive(lastentry, skip_imdb=args.skip_imdb)
    db.set_entry(edited)
Ejemplo n.º 19
0
Archivo: tests.py Proyecto: progo/moary
 def testEmptyAdd_with_imdb(self):
     """test a situation where the user provides nothing new. Should raise
     UserCancel."""
     self.set_edited_content(edit_entry.fill_in_form(None))
     self.assertRaises(edit_entry.UserCancel,
         lambda: edit_entry.edit_data_interactive({}))