Exemple #1
0
def test_destination(tmpdir):
    testoptions = dict(STDOPTIONSWKEY)
    path = str(tmpdir.dirpath()) + '/'
    testoptions.update({'directory': path})
    testobj = organizer.Organizer(testoptions)

    assert testobj.optionsdict['destination'] == Path(path)
Exemple #2
0
def test_badapikeyfile():
    keyfile = getcwd() + '/apikey.ini'
    f = open(keyfile, 'w')
    f.write("TMDB_API_KEY = dasfasd\n")
    f.close()
    with pytest.raises(OSError):
        testobj = organizer.Organizer(STDOPTIONS)

    remove(keyfile)
Exemple #3
0
def test_goodapikeyfile(tmpdir):
    keyfile = getcwd() + '/apikey.ini'
    f = open(keyfile, 'w')
    f.write("TMDB_API_KEY = '" + APIKEY + "'\n")
    f.close()

    fixdirectory(STDOPTIONS, tmpdir)
    testobj = organizer.Organizer(STDOPTIONS)

    assert testobj.apikey == APIKEY

    remove(keyfile)
Exemple #4
0
def test_organizefolder(tmpdir):
    options = dict(STDOPTIONSWKEY)
    fixdirectory(options, tmpdir)
    options.update({'destination': str(tmpdir.dirpath()) + '/videos_out/'})
    testobj = organizer.Organizer(options)

    createdirstructure(tmpdir)

    testobj.organizefolder(str(tmpdir))

    for s in CORRECTST:
        p = Path(str(tmpdir.dirpath()) + '/videos_out/' + s)
        assert p.exists()
Exemple #5
0
def test_baddestination():
    #make sure destination is created
    letters = string.ascii_lowercase
    randomFolderName = ''.join(random.choice(letters) for i in range(20))

    baddir = '/tmp/' + randomFolderName + '/'

    testoptions = dict(STDOPTIONSWKEY)
    testoptions.update({'destination': baddir})

    # with pytest.raises(FileNotFoundError):
    testobj = organizer.Organizer(testoptions)
    assert Path(baddir).exists()
Exemple #6
0
def test_namingmovies(tmpdir):
    fixdirectory(STDOPTIONSWKEY, tmpdir)
    testobj = organizer.Organizer(STDOPTIONSWKEY)

    for i in range(len(MOVIES)):
        gdict = guessit(MOVIES[i])
        testtitle = gdict['title']
        fakemovie = movie.Movie(
            {
                'id': 0,
                'title': testtitle,
                'release_date': str(MYEARS[i])
            }, None)
        newPath = testobj.buildpath(fakemovie, gdict)
        assert newPath == FMNAMES[i]
Exemple #7
0
def test_createobjwithkey(tmpdir):
    fixdirectory(STDOPTIONSWKEY, tmpdir)
    testo = organizer.Organizer(STDOPTIONSWKEY)
    assert testo.apikey == APIKEY
Exemple #8
0
def test_noargs():
    with pytest.raises(RuntimeError):
        testobj = organizer.Organizer({})
Exemple #9
0
def test_createobjnokey(monkeypatch):
    # monkeypatch.setattr('builtins.input', lambda: APIKEY)
    with pytest.raises(FileNotFoundError):
        testo = organizer.Organizer(STDOPTIONS)