def test_002_directories(self): with cd("~"): result = run('ls') self.assertTrue("sites" in result.split()) with cd("~/sites"): result = run('ls') self.assertTrue("todo.gdelo.com" in result.split())
def test_006_selenium_installed(self): "Test Selenium webdriver is installed" with cd("~/wendy_workspace"): result = run("ls -l") with cd("~/wendy_workspace/application/functional_tests"): run("ls -l") result = run("python3.5 tests.py") print(result)
def setup_application(): with cd("~/workspace"): run(setup + "wget https://github.com/hjwp/book-example/archive/chapter_07.zip") run(setup + "unzip chapter_07.zip") run("mv book-example-chapter_07 application") with cd("~/workspace/application"): run(setup + "python3 manage.py migrate")
def setup_Xvfb(): print("Installing pyvirtualdisplay.") with cd("~"): result = run("sudo apt-get -y install xvfb") with cd("~"): result = run("sudo pip3 install pyvirtualdisplay") print(result) print("pyvirtualdisplay installed")
def setup_firefox(): print("Installing Firefox.") with cd("~"): result = run("sudo apt-get -y install firefox") with cd("~"): result = run("firefox -v") assert("Firefox" in result) print(result) print("Firefox installed")
def test_005_app_installed(self): "Test that the application directory and software are present" with cd("~/workspace"): result = run("ls -l") self.assertTrue("application" in result) with cd("~/workspace/application"): result = run("ls -l") self.assertTrue("manage.py" in result) self.assertTrue("lists" in result)
def setup_django(): print("Installing Django.") with cd("~"): result = run("sudo pip3 install django") with cd("~"): result = run("pip3 list | grep Django") print(result) print("Django installed") assert(result.startswith("Django"))
def setup_git(): print("Installing git.") with cd("~"): result = run("sudo apt-get -y install git") with cd("~"): result = run("git --version") print(result) print("git is installed") assert(result.startswith("git"))
def setup_pip3(): print("Installing pip3.") with cd("~"): result = run("sudo apt-get -y install python3-pip") with cd("~"): result = run("pip3 --version") print(result) print("pip3 is installed") assert(result.startswith("pip"))
def setup_application(): print("Installing application") with cd("~/wendy_workspace"): run("wget https://github.com/hjwp/book-example/archive/chapter_07.zip") result = run("sudo apt-get -y install unzip") run("unzip chapter_07.zip") run("mv book-example-chapter_07 application") with cd("~/wendy_workspace/application"): run("python3 manage.py migrate") print("Application installed")
def test_003_directory_pemission(self): with cd("~/sites"): result = run("ls -l") results = result.split("\n") for result in results: if "todo.gdelo.com" in result: self.assertTrue("drwxrwxr-x" in result)
def setup_selenium(): print("Installing Selenium.") with cd("~"): result = run("sudo pip3 install selenium") #with cd("~"): #result = run("pip3 list | grep Django") print(result) print("Selenium installed")
def start_application(): with cd("~/workspace/application"): #run(setup + "nohup python3 manage.py runserver 0.0.0.0:3000 &") #run(setup + "nohup ps -aux \&") pass
def start_application(): with cd("~/wendy_workspace/application"): result = run("python3 manage.py runserver 127.0.0.1:8000") print(result) #run(setup + "nohup ps -aux \&") pass
def test_004_django(self): "Django is installed." with cd("~"): result = run(setup + "pip3 list | grep Django") self.assertTrue(result.startswith("Django"))
def test_003_git(self): "git is installed." with cd("~"): result = run(setup + "git --version") self.assertTrue(result.startswith("git"))
def test_002_pip3(self): "Pip3 is installed." with cd("~"): result = run(setup + "pip3 --version") self.assertTrue(result.startswith("pip"))
def test_001_python3(self): "Python 3 is installed." with cd("~"): result = run(setup + "python3 --version") self.assertTrue("Python 3" in result)
from remote_api import env,cd,run from private import user, password env.host_string = 'ssh.pythonanywhere.com' env.user = user env.password = password with cd(""): print(run("ls -l | grep READ"))
def setup_django(): with cd("~"): result = run(setup + "pip3 install django") with cd("~"): result = run(setup + "pip3 list | grep Django") assert(result.startswith("Django"))
def test_007_django(self): "Firefox is installed." with cd("~"): result = run("firefox -v") self.assertTrue("Firefox" in result)
def test_006_app_is_running(self): "Test that a Django application is running" with cd("~"): result = run("ps -aux | grep python") self.assertTrue("manage.py" in result)
from remote_api import env, cd, run from private import user, password env.host_string = "localhost" env.user = "******" env.password = "" with cd("~/workspace"): print(run("ls -l"))
def test_000_login(self): "Server is present and we can log in." with cd("~/workspace"): result = run("whoami") self.assertTrue(env.user in result)