from __future__ import absolute_import, print_function

from ..pyautoupdate.launcher import Launcher
from .pytest_skipif import needinternet
from .pytest_makevers import fixture_update_dir

import os
import sys

import pytest

@pytest.mark.trylast
@needinternet
def test_check_get_new(fixture_update_dir):
    """Test that gets new version from internet"""
    package=fixture_update_dir("0.0.1")
    launch = Launcher('filling up the boring replacements',
                      r'http://rlee287.github.io/pyautoupdate/testing/')
    launch._get_new()
    with open(os.path.abspath("downloads/extradir/blah.py"), "r") as file_code:
        file_text=file_code.read()
    assert "new version" in file_text

@@ -224,29 +224,8 @@
 st%0A%0A
-@pytest.mark.trylast%0A
 @nee
@@ -677,8 +677,446 @@
 le_text%0A
+%0A@needinternet%0Adef test_check_get_invalid_archive(fixture_update_dir):%0A    %22%22%22Test that gets new version from internet%22%22%22%0A    package=fixture_update_dir(%220.0.1%22)%0A    launch = Launcher('what file? hahahaha',%0A                      r'http://rlee287.github.io/pyautoupdate/testing2/',%0A                      newfiles=%22project.tar.gz%22)%0A    launch._get_new()%0A    assert os.path.isfile(%22project.tar.gz.dump%22)%0A    os.remove(%22project.tar.gz.dump%22)%0A

Write test that attempts to unpack invalid archive