Skip to content

Commit

Permalink
Change structure for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Medeiros committed Jan 19, 2020
1 parent 890f82d commit a905e45
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ po/gen-pot
*.rej
*.pem
ui/pages/help/*/*.html
uiTests/.env
tests/ui/.env
22 changes: 13 additions & 9 deletions uiTests/README.md → tests/ui/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Kimchi E2E Tests

The tests are located in uiTests. You should go to the directory to start them
The tests are located in `tests/ui`. You should go to the directory to start them
```
$ cd uiTests
$ cd tests/ui
```

## How to run
Expand All @@ -22,20 +22,22 @@ $ pip install -r requirements.txt
```

### Run in headless mode
The Makefile expect some environment variables to run kimchi, which are:
The script expect some environment variables to run kimchi-project tests, which are:

```
Expect environment variables:
KIMCHI_USERNAME: username for the host default: root
KIMCHI_PASSWORD: password for the host
KIMCHI_HOST: host for kimchi default: localhost
KIMCHI_PORT: port for kimchi default: 8001
USERNAME: username for the host default: root
PASSWORD: password for the host
HOST: host for kimchi default: localhost
PORT: port for kimchi default: 8001
```

So, if you are running against a remote host:

```
$ read -s pass; KIMCHI_HOST=<HOST> KIMCHI_PASSWORD=$pass make
$ HOST=<HOST> ./run_tests.sh
Type password for host USER@HOST
```

### Run in debug mode
Expand All @@ -44,5 +46,7 @@ If you use the command above, the browser will no be visible for you.
To see the browser action, add the variable `DEBUG`

```
$ read -s pass; KIMCHI_HOST=<HOST> KIMCHI_PASSWORD=$pass DEBUG=true make
$ HOST=<HOST> DEBUG=true ./run_tests.sh
Type password for host USER@HOST
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import utils
from .login import KimchiLoginPage
from pages.login import KimchiLoginPage

VIRTUALIZATION_TAB = "//a[@class = 'item virtualizationTab']"
TEMPLATES_TAB = "//a[@href = 'plugins/kimchi/tabs/templates.html']"
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
verbose = True
log_cli = True
log_cli_level = INFO
File renamed without changes.
16 changes: 16 additions & 0 deletions tests/ui/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

HOST=${HOST:-localhost}
PORT=${PORT:-8001}
USERNAME=${USERNAME:-root}

# ask for password if not passed
if [ -z $PASSWORD ]; then
echo "Type password for host ${USERNAME}@${HOST}"
read -s PASSWORD
fi

# ../../../../../../ is wok root

HOST=${HOST} PASSWORD=${PASSWORD} USERNAME=${USERNAME} PORT=${PORT} \
PYTHONPATH=$PYTHONPATH:../../../../../../tests/ui/ python3 -m pytest
36 changes: 36 additions & 0 deletions tests/ui/test_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import unittest

from utils import getBrowser
from pages.templates import KimchiTemplatePage
EXPECTED_TEMPLATES = [['Debian', '10', 'Not Available'],
['Fedora', '30', 'Not Available'],
['Fedora', '31', 'Not Available'],
['Opensuse', '15.1', 'Not Available'],
['Ubuntu', '19.04', 'Not Available'],
['Ubuntu', '19.10', 'Not Available']
]



VIRTUALIZATION_TAB = "//a[@class = 'item virtualizationTab']"
TEMPLATES_TAB = "//a[@href = 'plugins/kimchi/tabs/templates.html']"
ADD_TEMPLATE = "template-add"
ISOS_LIST = "list-local-iso"


class TestTemplate(unittest.TestCase):

def setUp(self):
self.browser = getBrowser()
self.templatePage = KimchiTemplatePage(self.browser)

def test_default_templates(self):
templates = self.templatePage.retrieveDefaulTemplates()

# assert templates
for template in templates:
assert template in EXPECTED_TEMPLATES, f"{template} not found"

def tearDown(self):
self.browser.close()

68 changes: 0 additions & 68 deletions uiTests/pages/kimchi_project/login.py

This file was deleted.

2 changes: 0 additions & 2 deletions uiTests/pytest.ini

This file was deleted.

31 changes: 0 additions & 31 deletions uiTests/test_templates.py

This file was deleted.

103 changes: 0 additions & 103 deletions uiTests/utils.py

This file was deleted.

0 comments on commit a905e45

Please sign in to comment.