def test_user_agent(): clear() assert not utils.exist() ua = UserAgent(cache=False) assert ua.ie is not None assert ua.msie is not None assert ua.internetexplorer is not None assert ua.internet_explorer is not None assert ua['internet explorer'] is not None assert ua.google is not None assert ua.chrome is not None assert ua.googlechrome is not None assert ua.google_chrome is not None assert ua['google chrome'] is not None assert ua.firefox is not None assert ua.ff is not None assert ua.ie is not None assert ua.safari is not None assert ua.random is not None assert ua['random'] is not None assert ua.non_existing is None assert ua['non_existing'] is None data1 = ua.data ua.update() data2 = ua.data assert data1 == data2 assert data1 is not data2 clear() del ua ua = UserAgent() assert utils.exist() data1 = ua.data clear() ua.update() assert utils.exist() data2 = ua.data assert data1 == data2 assert data1 is not data2
def test_user_agent(): clear() assert not utils.exist() ua = UserAgent(cache=False) assert not ua.ie is None assert not ua.msie is None assert not ua.internetexplorer is None assert not ua.internet_explorer is None assert not ua['internet explorer'] is None assert not ua.google is None assert not ua.chrome is None assert not ua.googlechrome is None assert not ua.google_chrome is None assert not ua['google chrome'] is None assert not ua.firefox is None assert not ua.ff is None assert not ua.ie is None assert not ua.safari is None assert not ua.random is None assert not ua['random'] is None assert ua.non_existing is None assert ua['non_existing'] is None data1 = ua.data ua.update() data2 = ua.data assert data1 == data2 assert not data1 is data2 clear() del ua ua = UserAgent() assert utils.exist() data1 = ua.data clear() ua.update() assert utils.exist() data2 = ua.data assert data1 == data2 assert not data1 is data2
def test_utils_exist(path): assert not os.path.isfile(path) assert not utils.exist(path) with io.open(path, mode='wb') as fp: fp.write(b'\n') assert os.path.isfile(path) assert utils.exist(path)
def test_custom_path(): location = os.path.join( tempfile.gettempdir(), 'fake_useragent' + uuid.uuid1().hex + '.json', ) ua = UserAgent(path=location) assert utils.exist(location) check_dict(ua.data) mtime = os.path.getmtime(location) ua.update() assert os.path.getmtime(location) != mtime clear(location)
def test_update(): assert not utils.exist() utils.update() assert utils.exist() utils.update() assert utils.exist()
def test_rm(): assert utils.exist() utils.rm() assert not utils.exist()
def test_exists(): assert utils.exist()
def test_user_agent(): clear(settings.DB) assert not utils.exist(settings.DB) ua = UserAgent(cache=False) assert ua.ie is not None assert ua.msie is not None assert ua.internetexplorer is not None assert ua.internet_explorer is not None assert ua['internet explorer'] is not None assert ua.google is not None assert ua.chrome is not None assert ua.googlechrome is not None assert ua.google_chrome is not None assert ua['google chrome'] is not None assert ua.firefox is not None assert ua.ff is not None assert ua.ie is not None assert ua.safari is not None assert ua.random is not None assert ua['random'] is not None try: ua.non_existing except FakeUserAgentError: pass else: assert False try: assert ua['non_existing'] except FakeUserAgentError: pass else: assert False data1 = ua.data ua.update(settings.DB) data2 = ua.data assert data1 == data2 assert data1 is not data2 clear(settings.DB) del ua ua = UserAgent() assert utils.exist(settings.DB) data1 = ua.data clear(settings.DB) ua.update(settings.DB) assert utils.exist(settings.DB) data2 = ua.data assert data1 == data2 assert data1 is not data2 clear(settings.DB)
def test_update(): assert not utils.exist(settings.DB) utils.update(settings.DB) assert utils.exist(settings.DB) utils.update(settings.DB) assert utils.exist(settings.DB)
def test_rm(): assert utils.exist(settings.DB) clear(settings.DB) assert not utils.exist(settings.DB)
def test_exists(): assert utils.exist(settings.DB)
def test_rm(): assert utils.exist(settings.DB) utils.rm(settings.DB) assert not utils.exist(settings.DB)