This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit to run acceptance tests
- Loading branch information
Showing
9 changed files
with
238 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,2 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# Robot Framework language cache files | ||
*.tmPreferences.cache | ||
*.tmLanguage.cache | ||
|
||
# Robot datafiles | ||
robot_data/ | ||
|
||
# Directories/files that start with dot '.' but not .git* files | ||
.* | ||
!/.gitignore | ||
!/.git/ | ||
!.no-sublime-package | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
*.pyc | ||
test/results/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
*** Settings *** | ||
Library OperatingSystem | ||
Library String | ||
Library ../../scr/DataParser.py | ||
Library ../resource/utilities/json_to_dictionary.JsonParser | ||
*** Test Cases *** | ||
Parser Should Be Able To Parse Resource File | ||
${result} = DataParser.Parse Resource | ||
... ${CURDIR}${/}..${/}resource${/}simple_resource.robot | ||
${result} = Parse Json ${result} | ||
Copy And Replace Path In File | ||
... ${CURDIR}${/}..${/}resource${/}simple_resource_as.json | ||
... ${OUTPUT_DIR}${/}simple_resource_as.json | ||
... REPLACE_PATH | ||
... ${OUTPUT_DIR}${/} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}simple_resource_as.json | ||
Compare Dicts ${result} ${expected} | ||
Parser Should Be Able To Parse Test Suite | ||
${result} = DataParser.Parse Suite | ||
... ${CURDIR}${/}..${/}resource${/}simple_test.robot | ||
${result} = Parse Json ${result} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}simple_test_as.json | ||
Compare Dicts ${result} ${expected} | ||
Parser Should Be Able To Parse Variable File | ||
${result} = DataParser.Parse Variable File | ||
... ${CURDIR}${/}..${/}resource${/}simple_var.py | ||
${result} = Parse Json ${result} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}simple_var_as.json | ||
Compare Dicts ${result} ${expected} | ||
Parser Should Be Able To Parse Internal Library | ||
${result} = DataParser.Parse Library | ||
... BuiltIn | ||
${result} = Parse Json ${result} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}builtint_as.json | ||
Compare Dicts ${result} ${expected} | ||
Parser Should Be Able To Parse External Library From Python Path | ||
${result} = DataParser.Parse Library | ||
... Selenium2Library | ||
${result} = Parse Json ${result} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}s2l_as.json | ||
Compare Dicts ${result} ${expected} | ||
Parser Should Be Able To Parse External Library From File | ||
${result} = DataParser.Parse Library | ||
... ${CURDIR}${/}..${/}resource${/}utilities${/}json_to_dictionary.JsonParser | ||
${result} = Parse Json ${result} | ||
${expected} = Parse Json From File | ||
... ${CURDIR}${/}..${/}resource${/}JsonParser_as.json | ||
Compare Dicts ${result} ${expected} | ||
*** Keywords *** | ||
Copy And Replace Path In File | ||
[Arguments] ${source} ${destination} ${search_for} ${replace_to} | ||
${source} = OperatingSystem.Normalize Path ${source} | ||
${destination} = OperatingSystem.Normalize Path ${destination} | ||
${replace_to} = OperatingSystem.Normalize Path ${replace_to} | ||
${data} = OperatingSystem.Get File | ||
... path=${source} | ||
${data} = String.Replace String | ||
... ${data} | ||
... search_for=${search_for} | ||
... replace_with=${replace_to}${/} | ||
OperatingSystem.Create File | ||
... ${destination} | ||
... ${data} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from os import path | ||
import sys | ||
|
||
ROOT_DIR = path.dirname(path.abspath(__file__)) | ||
UNIT_TEST_DIR = path.join(ROOT_DIR, "unit") | ||
ACCEPTANCE_TEST_DIR = path.join(ROOT_DIR, "acceptance") | ||
LIB_DIR = path.join(ROOT_DIR, "lib") | ||
RESOURCES_DIR = path.join(ROOT_DIR, "resources") | ||
TEST_LIBS_DIR = path.join(RESOURCES_DIR, "testlibs") | ||
RESULTS_DIR = path.join(ROOT_DIR, "results") | ||
SRC_DIR = path.join(ROOT_DIR, "..", "src") | ||
|
||
sys.path.insert(0, SRC_DIR) | ||
sys.path.append(LIB_DIR) | ||
sys.path.append(UNIT_TEST_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"file_name": "simple_resource.robot", | ||
"file_path": "REPLACE_PATHsimple_resource.robot", | ||
"keywords": [ | ||
{ | ||
"My Kw 1": { | ||
"args": [ | ||
"${arg1}=${False}", | ||
"${arg2}=${True}" | ||
], | ||
"doc": "Some documentation", | ||
"tags": [ | ||
"some_tag", | ||
"other_tag" | ||
], | ||
"keyword_variables": [ | ||
"${some_return_value}", | ||
"${other_return_value}" | ||
] | ||
} | ||
} | ||
], | ||
"library": [ | ||
"Selenium2Library" | ||
], | ||
"resource": [ | ||
"REPLACE_PATHsimple_resrouce2.robot", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
*** Settings *** | ||
Library Selenium2Library | ||
Documentation foobar | ||
Resource simple_resrouce2.robot | ||
*** Variable *** | ||
${ARG} 1 | ||
*** Keywords *** | ||
My Kw 1 | ||
[Arguments] ${arg1}=${False} ${arg2}=${True} | ||
[Tags] some_tag other_tag | ||
[Documentation] Some documentation | ||
${some_return_value} = Set Variable 123 | ||
${other_return_value} = Set Variable ${EMPTY} | ||
Log ${arg1} | ||
[Return] ${False} | ||
My Kw 2 | ||
[Arguments] ${arg2}=${False} ${arg2}=${True} | ||
[Documentation] Some documentation. | ||
... In multi line | ||
Log ${arg2} | ||
[Return] ${arg2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*** Keywords *** | ||
Other Rerouce Kw | ||
Log 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*** Settings *** | ||
Resource simple_resource.robot | ||
*** Variable *** | ||
${ARG} 1 | ||
*** Test Cases *** | ||
Example Test | ||
My Kw | ||
Other Kw | ||
*** Keywords *** | ||
Other Kw | ||
Log 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import env | ||
import os | ||
import sys | ||
import shutil | ||
from robot import run | ||
|
||
|
||
def acceptance_test(options): | ||
print options | ||
if len(options) == 0: | ||
_acceptance_all() | ||
else: | ||
if '-s' in options or '--suite': | ||
_acceptance_include(options[1:]) | ||
else: | ||
print 'Only "-s" or "--suite" supported' | ||
_exit(255) | ||
|
||
|
||
def _acceptance_all(): | ||
run(env.ACCEPTANCE_TEST_DIR, | ||
outputdir=env.RESULTS_DIR) | ||
|
||
|
||
def _acceptance_include(options): | ||
run(env.ACCEPTANCE_TEST_DIR, | ||
outputdir=env.RESULTS_DIR, | ||
suite=options) | ||
|
||
|
||
def clean_results(): | ||
print 'Clean: {0}'.format(env.RESULTS_DIR) | ||
shutil.rmtree(env.RESULTS_DIR) | ||
os.mkdir(env.RESULTS_DIR) | ||
|
||
|
||
def unit_test(): | ||
print 'TODO' | ||
|
||
|
||
def _help(): | ||
print 'Usage: python run_test.py [-s suite_name]' | ||
return 255 | ||
|
||
|
||
def _exit(rc): | ||
sys.exit(rc) | ||
|
||
if __name__ == '__main__': | ||
if '--help' in sys.argv or '-h' in sys.argv: | ||
_exit(_help()) | ||
clean_results() | ||
unit_test() | ||
acceptance_test(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import json | ||
from os import path | ||
|
||
|
||
class JsonParser(): | ||
|
||
def parse_json_from_file(self, path_to_file): | ||
"""Example doc for testing""" | ||
with open(path.normpath(path_to_file)) as f: | ||
data = ''.join(f.readlines()) | ||
f.close() | ||
return json.loads(data) | ||
|
||
def parse_json(self, json_data): | ||
return json.loads(json_data) | ||
|
||
def compare_dicts(self, dict1, dict2): | ||
if cmp(dict1, dict2): | ||
return True | ||
else: | ||
raise ValueError('{0} != {1}'.format(dict1, dict2)) |