summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/opnfv_testapi/tests')
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/homeControllerSpec.js56
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js390
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js354
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js416
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js381
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js1041
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/scenariosControllerSpec.js725
-rw-r--r--testapi/opnfv_testapi/tests/UI/e2e/testCasesControllerSpec.js650
-rw-r--r--testapi/opnfv_testapi/tests/unit/fake_pymongo.py4
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_base.py15
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_deploy_result.py201
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_pod.py37
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_result.py157
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py118
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py79
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/deploy_result.json14
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/scenario-c1.json (renamed from testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json)0
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/scenario-c2.json (renamed from testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json)0
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/test_result.json27
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/testcase_d.json16
-rw-r--r--testapi/opnfv_testapi/tests/unit/templates/testcase_e.json16
21 files changed, 3936 insertions, 761 deletions
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/homeControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/homeControllerSpec.js
new file mode 100644
index 0000000..57794a6
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/UI/e2e/homeControllerSpec.js
@@ -0,0 +1,56 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000"
+describe('testing the home page for anonymous user', function () {
+
+ it( 'should navigate to pods link ', function() {
+ browser.get(baseURL);
+ var signOut = element(by.linkText('Sign In / Sign Up'))
+ expect(signOut.isDisplayed()).toBe(true);
+ });
+});
+
+describe('testing the home page for user', function () {
+ beforeEach(function(){
+ mock([{
+ request: {
+ path: '/api/v1/pods',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ pods: [{role: "community-ci", name: "test", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-functest-submitters"], "email": "testuser@test.com"
+ }
+ }
+ }])
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the profile page', function() {
+ browser.get(baseURL);
+ var profile = element(by.linkText('Profile'))
+ expect(profile.isDisplayed()).toBe(true);
+ profile.click()
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '/#/profile'), 10000);
+ });
+});
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js
index c3961ab..97e61ad 100644
--- a/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js
+++ b/testapi/opnfv_testapi/tests/UI/e2e/podsControllerSpec.js
@@ -17,7 +17,24 @@ describe('testing the Pods page for anonymous user', function () {
creation_date: "2017-10-25 11:58:25.926168"}]
}
}
- }]);
+ },
+ {
+ request: {
+ path: '/api/v1/pods',
+ method: 'GET',
+ queryString: {
+ name: 'test'
+ }
+ },
+ response: {
+ data: {
+ pods: [{role: "community-ci", name: "test", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}]
+ }
+ }
+ }
+ ]);
});
afterEach(function(){
@@ -42,81 +59,249 @@ describe('testing the Pods page for anonymous user', function () {
expect(buttonFilter.isDisplayed()).toBe(true)
});
- it('clear button is visible for anonymous user', function () {
- var buttonClear = element(by.buttonText('Clear'));
- expect(buttonClear.isDisplayed()).toBe(true)
+ it('Delete button is visible for anonymous user', function () {
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBeFalsy();
});
- it('Show results when click filter button', function () {
+ it('Show results', function () {
+ var row = element.all(by.repeater('(index, pod) in ctrl.data.pods')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test");
+ });
+
+ it('Show relevant results to the filter', function () {
+ var filter = element(by.model('ctrl.filterText'));
+ filter.sendKeys('test');
var buttonFilter = element(by.buttonText('Filter'));
- buttonFilter.click();
- var pod = element(by.css('.show-pod'));
- expect(pod.isPresent()).toBe(true);
+ var row = element.all(by.repeater('(index, pod) in ctrl.data.pods')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test");
});
- it('Show results when click clear button', function () {
+ it('delete Operation is not visible for user ', function () {
browser.get(baseURL+'#/pods');
- var buttonClear = element(by.buttonText('Clear'));
- buttonClear.click();
- var pod = element(by.css('.show-pod'));
- expect(pod.isPresent()).toBe(true);
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBeFalsy();
});
- it('If details is not shown then show details when click the link',function() {
- expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(true);
- var podslink = element(by.linkText('test')).click();
- expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(false);
- });
- it('If details is shown then hide details when click the link',function() {
- expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(false);
- var podslink = element(by.linkText('test')).click();
- expect(element(by.css('.show-pod.hidden')).isPresent()).toBe(true);
+});
+
+describe('testing the Pods page for authorized user', function () {
+
+ beforeEach(function(){
+ mock([{
+ request: {
+ path: '/api/v1/pods',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ pods: [{role: "community-ci", name: "test", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-functest-submitters"], "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods',
+ method: 'GET',
+ queryString: {
+ name: 'test'
+ }
+ },
+ response: {
+ data: {
+ pods: [{role: "community-ci", name: "test", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods/test',
+ method: 'DELETE'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/pods/test"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods/test1',
+ method: 'DELETE'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/pods/test1"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods',
+ method: 'POST'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/pods/test1"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods/test',
+ method: 'GET'
+ },
+ response: {
+ data: {role: "community-ci", name: "test", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}
+ }
+ }
+ ]);
});
- it('If backend is not responding then show error when click filter button', function () {
- browser.get(baseURL + '/#/pods');
+ afterEach(function(){
mock.teardown();
+ });
+
+ it( 'should navigate to pods link ', function() {
+ browser.get(baseURL);
+ var podslink = element(by.linkText('Pods')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '/#/pods'), 10000);
+ });
+
+ it('create button is not visible for user', function () {
+ browser.get(baseURL+'#/pods');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBe(true);
+ });
+
+ it('filter button is visible for user', function () {
var buttonFilter = element(by.buttonText('Filter'));
- buttonFilter.click().then(function(){
- expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
- .isDisplayed()).toBe(true);
- });
+ expect(buttonFilter.isDisplayed()).toBe(true)
});
-});
+ it('Delete button is visible for user', function () {
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBe(true)
+ });
-describe('testing the Pods page for authorized user', function () {
+ it('Show results', function () {
+ var row = element.all(by.repeater('(index, pod) in ctrl.data.pods')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test");
+ });
- beforeEach(function(){
- mock([
- {
+ it('Show relevant results to the filter', function () {
+ var filter = element(by.model('ctrl.filterText'));
+ filter.sendKeys('test');
+ var buttonFilter = element(by.buttonText('Filter'));
+ var row = element.all(by.repeater('(index, pod) in ctrl.data.pods')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test");
+ });
+
+ it('delete Operation is visible for user ', function () {
+ browser.get(baseURL+'#/pods');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Batch Delete the pods ', function () {
+ browser.get(baseURL+"#/pods");
+ var checkBox = element(by.model('ctrl.checkBox[index]'));
+ checkBox.click();
+ var buttonDelete = element(by.buttonText('Delete'));;
+ buttonDelete.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Delete Success"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Delete the pods ', function () {
+ browser.get(baseURL+"#/pods");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Delete Success"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Create the pod', function () {
+ browser.get(baseURL+"#/pods");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('PodModalCtrl.pod.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Create Success"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Showing error when creating with a empty name ', function () {
+ browser.get(baseURL+"#/pods");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('PodModalCtrl.pod.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click()
+ expect(element(by.cssContainingText(".alert","Name is missing."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('cancel the delete confimation modal of the pod ', function () {
+ browser.get(baseURL+"#/pods");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonCancel = element(by.buttonText('Cancel'));
+ buttonCancel.click();
+ expect(buttonCancel.isPresent()).toBe(false);
+ });
+
+ it('Delete the pods which do not exist ', function () {
+ mock.teardown();
+ mock([{
request: {
- path: '/api/v1/pods',
- method: 'POST'
+ path: '/api/v1/pods',
+ method: 'GET'
},
response: {
data: {
- href: baseURL+"/api/v1/pods/test"
+ pods: [{role: "community-ci", name: "test1", owner: "testUser",
+ details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed",
+ creation_date: "2017-10-25 11:58:25.926168"}]
}
- }
- },
- {
- request: {
- path: '/api/v1/pods',
- method: 'POST',
- data: {
- name: 'test1',
- details : 'DemoDetails',
- role : 'community-ci',
- mode : 'metal'
- }
- },
- response: {
- status : 403
- }
- },
- {
+ }
+ },
+ {
request: {
path: '/api/v1/profile',
method: 'GET'
@@ -127,57 +312,48 @@ describe('testing the Pods page for authorized user', function () {
"user": "testUser", "groups": ["opnfv-testapi-users",
"opnfv-gerrit-functest-submitters"], "email": "testuser@test.com"
}
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/pods/test1',
+ method: 'DELETE'
+ },
+ response: {
+ status : 403,
+ data : 'pods do not exist'
}
}
]);
+ browser.get(baseURL+"#/pods");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.css(".alert.alert-danger"))
+ .isDisplayed()).toBe(true);
});
- afterEach(function(){
- mock.teardown();
- });
-
- it('create button is visible for authorized user', function () {
- browser.get(baseURL + '/#/pods');
- var buttonCreate = element(by.buttonText('Create'));
- expect(buttonCreate.isDisplayed()).toBe(true);
+ it('view the test case ', function () {
+ browser.get(baseURL+"#/pods");
+ var viewOperation = element(by.css('a[class=text-info]'));
+ viewOperation.click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains('#/pods/test'), 10000);
});
- it('Do not show error if input is acceptable', function () {
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.details'));
- name.sendKeys('test');
- details.sendKeys('DemoDetails');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click().then(function(){
- expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
- .isDisplayed()).toBe(false);
- });
- });
-
- it('Show error when user click the create button with a empty name', function () {
- browser.get(baseURL+ '/#/pods');
- var details = element(by.model('ctrl.details'));
- details.sendKeys('DemoDetails');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click();
- expect(element(by.cssContainingText(".alert","Name is missing.")).isDisplayed()).toBe(true);
- });
-
- it('Show error when user click the create button with an already existing name', function () {
- browser.get(baseURL+ '/#/pods');
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.details'));
- name.sendKeys('test1');
- details.sendKeys('DemoDetails');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click();
- expect(element(by.cssContainingText(".alert","Error creating the new pod from server: undefined")).isDisplayed()).toBe(true);
- });
-
- it('If backend is not responding then show error when user click the create button',function(){
+ it('Show error if server is not responding', function () {
mock.teardown();
- mock([
- {
+ mock([{
+ request: {
+ path: '/api/v1/pods',
+ method: 'GET'
+ },
+ response: {
+ status : 404
+ }
+ },
+ {
request: {
path: '/api/v1/profile',
method: 'GET'
@@ -185,21 +361,15 @@ describe('testing the Pods page for authorized user', function () {
response: {
data: {
"fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
- "user": "testUser", "groups": ["opnfv-testapi-users"],
- "email": "testuser@test.com"
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-functest-submitters"], "email": "testuser@test.com"
}
- }
}
+ },
]);
- browser.get(baseURL+ '/#/pods');
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.details'));
- name.sendKeys('test');
- details.sendKeys('DemoDetails');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click().then(function(){
- expect(element(by.css('.alert.alert-danger.ng-binding'))
- .isDisplayed()).toBe(true);
- });
+ browser.get(baseURL+"#/pods");
+ expect(element(by.css(".alert.alert-danger"))
+ .isDisplayed()).toBe(true);
});
+
}); \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js
deleted file mode 100644
index 475e037..0000000
--- a/testapi/opnfv_testapi/tests/UI/e2e/projectControllerSpec.js
+++ /dev/null
@@ -1,354 +0,0 @@
-'use strict';
-
-var mock = require('protractor-http-mock');
-var baseURL = "http://localhost:8000/#/"
-
-describe('testing the Project Link for anonymous user', function () {
- beforeEach(function(){
- mock([
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'GET'
- },
- response: {
- data: {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject"
- }
- }
- }
- ]);
- });
-
- afterEach(function(){
- mock.teardown();
- });
-
- it( 'navigate to the project page', function() {
- browser.get(baseURL+"projects/testproject");
- var EC = browser.ExpectedConditions;
- browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000);
- });
-
- it('show the project details for anonymous user ', function(){
- var table = $$('.projects-table.ng-scope tr');
- var projectDetailsLable = ['Name','Description','Creation date']
- var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259']
- table.each(function(row,index) {
- var rowElems = row.$$('td');
- expect(rowElems.count()).toBe(2);
- expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]);
- expect(rowElems.get(1).getText()).toMatch(projectDetails[index]);
- });
- });
-
- it('should not show the update & delete button', function(){
- var buttonUpdate = element(by.buttonText('Update Project'));
- var buttonDelete = element(by.buttonText('Delete Project'));
- expect(buttonUpdate.isDisplayed()).toBeFalsy();
- expect(buttonDelete.isDisplayed()).toBeFalsy();
- });
-
-});
-
-
-describe('testing the Project Link for authorized user(not a submitter)', function () {
- beforeEach(function(){
- mock([
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'GET'
- },
- response: {
- data: {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject"
- }
- }
- },
- {
- request: {
- path: '/api/v1/profile',
- method: 'GET'
- },
- response: {
- data: {
- "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
- "user": "testUser", "groups": ["opnfv-testapi-users"],
- "email": "testuser@test.com"
- }
- }
- }
- ]);
- });
-
- afterEach(function(){
- mock.teardown();
- });
-
- it( 'navigate to the project page', function() {
- browser.get(baseURL+"projects/testproject");
- var EC = browser.ExpectedConditions;
- browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000);
- });
-
- it('show the project details for user ', function(){
- var table = $$('.projects-table.ng-scope tr');
- var projectDetailsLable = ['Name','Description','Creation date']
- var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259']
- table.each(function(row,index) {
- var rowElems = row.$$('td');
- expect(rowElems.count()).toBe(2);
- expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]);
- expect(rowElems.get(1).getText()).toMatch(projectDetails[index]);
- });
- });
-
- it('should not show the update & delete button', function(){
- var buttonUpdate = element(by.buttonText('Update Project'));
- var buttonDelete = element(by.buttonText('Delete Project'));
- expect(buttonUpdate.isDisplayed()).toBeFalsy();
- expect(buttonDelete.isDisplayed()).toBeFalsy();
- });
-
-});
-
-describe('testing the Project Link for authorized user(a submitter)', function () {
- beforeEach(function(){
- mock([
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'GET'
- },
- response: {
- data: {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject"
- }
- }
- },
- {
- request: {
- path: '/api/v1/projects/testproject1',
- method: 'GET'
- },
- response: {
- data: {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject1"
- }
- }
- },
- {
- request: {
- path: '/api/v1/projects',
- method: 'GET'
- },
- response: {
- data: {
- "projects": [
- {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject"
- }
- ]
- }
- }
- },
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'DELETE'
- },
- response: {
- status : 200
- }
- },
- {
- request: {
- path: '/api/v1/projects/testproject1',
- method: 'DELETE'
- },
- response: {
- status : 403
- }
- },
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'PUT',
- data: {
- name: 'testProject2',
- description : 'demoDescription',
- }
- },
- response: {
- status : 200,
- data : {
- "owner": "thuva4",
- "_id": "5a0c022f9a07c846d3c2cc94",
- "creation_date": "2017-11-15 14:30:31.200259",
- "description": "dsfsd",
- "name": "testproject2"
- }
- }
- },
- {
- request: {
- path: '/api/v1/projects/testproject',
- method: 'PUT',
- data: {
- name: 'testProject1',
- description : 'demoDescription',
- }
- },
- response: {
- status : 403
- }
- },
- {
- request: {
- path: '/api/v1/profile',
- method: 'GET'
- },
- response: {
- data: {
- "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
- "user": "testUser", "groups": ["opnfv-testapi-users",
- "opnfv-gerrit-testProject-submitters",
- "opnfv-gerrit-testProject2-submitters" ],
- "email": "testuser@test.com"
- }
- }
- },
- ]);
- });
-
- afterEach(function(){
- mock.teardown();
- });
-
- it( 'navigate to the project page', function() {
- browser.get(baseURL+"projects/testproject");
- var EC = browser.ExpectedConditions;
- browser.wait(EC.urlContains(baseURL+ 'projects/testproject'), 10000);
- });
-
- it('show the project details for user ', function(){
- var table = $$('.projects-table.ng-scope tr');
- var projectDetailsLable = ['Name','Description','Creation date']
- var projectDetails = ['testproject', 'dsfsd','2017-11-15 14:30:31.200259']
- table.each(function(row,index) {
- var rowElems = row.$$('td');
- expect(rowElems.count()).toBe(2);
- expect(rowElems.get(0).getText()).toMatch(projectDetailsLable[index]);
- expect(rowElems.get(1).getText()).toMatch(projectDetails[index]);
- });
- });
-
- it('should show the update & delete button', function(){
- var buttonUpdate = element(by.buttonText('Update Project'));
- var buttonDelete = element(by.buttonText('Delete Project'));
- expect(buttonUpdate.isDisplayed()).toBe(true);
- expect(buttonDelete.isDisplayed()).toBe(true);
- });
-
- it('show the update modal when user clicks the update button', function(){
- browser.get(baseURL+"projects/testproject");
- var buttonDelete = element(by.buttonText('Update Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var buttonCancel = element(by.buttonText('Cancel')).click();
- expect(elm.isPresent()).toEqual(false);
- });
-
- it('send a update request to server and show success when we click ok', function(){
- browser.get(baseURL+"projects/testproject");
- var buttonUpdate = element(by.buttonText('Update Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var name = element(by.model('updateModal.name'));
- var description = element(by.model('updateModal.description'));
- name.click().clear().sendKeys('testProject2');
- description.click().clear().sendKeys('demoDescription');
- var buttonOk = element(by.buttonText('Ok')).click();
- expect(element(by.cssContainingText(".alert.alert-success",
- "Update Success"))
- .isDisplayed()).toBe(true);
- });
-
- it('show error when server send a error response when we click ok', function(){
- browser.get(baseURL+"projects/testproject");
- var buttonUpdate = element(by.buttonText('Update Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "Update"), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var name = element(by.model('updateModal.name'));
- var description = element(by.model('updateModal.description'));
- name.click().clear().sendKeys('testProject1');
- description.click().clear().sendKeys('demoDescription');
- var buttonOk = element(by.buttonText('Ok')).click();
- expect(element(by.cssContainingText(".alert",
- "Error updating the existing Project from server: undefined"))
- .isDisplayed()).toBe(true);
- });
-
- it('show the confirm modal when user clicks the delete button', function(){
- var buttonDelete = element(by.buttonText('Delete Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var buttonCancel = element(by.buttonText('Cancel')).click();
- expect(elm.isPresent()).toEqual(false);
- });
-
- it('send a delete request to server when we click ok', function(){
- var buttonDelete = element(by.buttonText('Delete Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var buttonCancel = element(by.buttonText('Ok')).click();
- browser.wait(EC.urlContains(baseURL+ 'projects'), 10000);
- });
-
- it('show the error message when we click ok', function(){
- browser.get(baseURL+"projects/testproject1");
- var buttonDelete = element(by.buttonText('Delete Project')).click();
- var EC = protractor.ExpectedConditions;
- var elm = element(by.css(".modal-body"));
- browser.wait(EC.textToBePresentInElement(elm, "You are about to delete."), 5000);
- expect(elm.isDisplayed()).toBe(true);
- var buttonCancel = element(by.buttonText('Ok')).click();
- // browser.wait(EC.urlContains(baseURL+ 'projects'), 10000);
- expect(element(by.cssContainingText(".alert",
- "Error deleting project from server: undefined"))
- .isDisplayed()).toBe(true);
- // browser.pause();
- });
-
-}); \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js
index 64a5aeb..8b908c9 100644
--- a/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js
+++ b/testapi/opnfv_testapi/tests/UI/e2e/projectsControllerSpec.js
@@ -51,18 +51,30 @@ describe('testing the Projects Link for anonymous user', function () {
expect(buttonCreate.isDisplayed()).toBeFalsy();
});
- it('Show projects list when user comes to the projects page', function () {
- var firstBookName = element(by.repeater('(index, project) in ctrl.data.projects').
- row(0).column('{{project.name}}'));
- expect(firstBookName).toBeDefined();
+ it('Delete button is not visible for anonymous user ', function () {
+ browser.get(baseURL+'#/projects');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
});
- it('redirect to project page when user clicks a project',function(){
- var projectlink = element(by.linkText('testproject')).click();
- var EC = browser.ExpectedConditions;
- browser.wait(EC.urlContains(baseURL+ '/#/projects/testproject'), 10000);
+ it('Show projects list when anonymous user comes to the projects page', function () {
+ var row = element.all(by.repeater('(index, project) in ctrl.data.projects')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("testproject");
});
+ // it('redirect to project page when user clicks a project',function(){
+ // var projectlink = element(by.linkText('testproject')).click();
+ // var EC = browser.ExpectedConditions;
+ // browser.wait(EC.urlContains(baseURL+ '/#/projects/testproject'), 10000);
+ // });
+
+ it('delete Operation is not visible for anonymous user ', function () {
+ browser.get(baseURL+'#/projects');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBeFalsy();
+ });
+
});
describe('testing the Project Link for user who is not in submitter group', function () {
@@ -70,6 +82,26 @@ describe('testing the Project Link for user who is not in submitter group', func
mock([
{
request: {
+ path: '/api/v1/projects',
+ method: 'GET',
+ queryString: {
+ name: 'test'
+ }
+ },
+ response: {
+ data: {
+ "projects": [
+ {
+ "_id": "5a0c1c9a9a07c846d3a7247b",
+ "creation_date": "2017-11-15 16:23:14.217093",
+ "description": "sdgfd",
+ "name": "test"
+ }]
+ }
+ }
+ },
+ {
+ request: {
path: '/api/v1/profile',
method: 'GET'
},
@@ -80,6 +112,25 @@ describe('testing the Project Link for user who is not in submitter group', func
"email": "testuser@test.com"
}
}
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "projects": [
+ {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ ]
+ }
+ }
}
]);
});
@@ -106,6 +157,28 @@ describe('testing the Project Link for user who is not in submitter group', func
var buttonCreate = element(by.buttonText('Create'));
expect(buttonCreate.isDisplayed()).toBeFalsy();
});
+
+ it('Delete button is not visible for user ', function () {
+ browser.get(baseURL+'#/projects');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
+ });
+
+ it('delete Operation is not visible for user ', function () {
+ browser.get(baseURL+'#/projects');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBeFalsy();
+ });
+
+ it('Show relevant results to the filter', function () {
+ var filter = element(by.model('ctrl.filterText'));
+ filter.sendKeys('test');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click()
+ var row = element.all(by.repeater('(index, project) in ctrl.data.projects')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test");
+ });
})
describe('testing the Project Link for user who is in submitter group', function () {
@@ -139,6 +212,28 @@ describe('testing the Project Link for user who is in submitter group', function
},
{
request: {
+ path: '/api/v1/projects/vsfv',
+ method: 'DELETE'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/projects/testProject1"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/vsfv',
+ method: 'PUT'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/projects/testProject1"
+ }
+ }
+ },
+ {
+ request: {
path: '/api/v1/projects',
method: 'POST',
data: {
@@ -163,6 +258,23 @@ describe('testing the Project Link for user who is in submitter group', function
status : 403,
data : 'You do not have permission to perform this action'
}
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data : {
+ "projects": [
+ {
+ "_id": "5a0c1c9a9a07c846d3a7247b",
+ "creation_date": "2017-11-15 16:23:14.217093",
+ "description": "sdgfd",
+ "name": "vsfv"
+ }]
+ }
+ }
}
]);
});
@@ -190,53 +302,247 @@ describe('testing the Project Link for user who is in submitter group', function
expect(buttonCreate.isDisplayed()).toBe(true);
});
- it('Show error when user click the create button with a empty name', function () {
- browser.get(baseURL+ '/#/projects');
- var description = element(by.model('ctrl.description'));
- description.sendKeys('DemoDescription');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click();
- expect(element(by.cssContainingText(".alert","Name is missing."))
+ it('Delete button is not visible for anonymous user ', function () {
+ browser.get(baseURL+'#/projects');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBe(true);
+ });
+
+ it('delete Operation is not visible for user ', function () {
+ browser.get(baseURL+'#/projects');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Edit Operation is visible for user ', function () {
+ browser.get(baseURL+'#/projects');
+ var editOperation = element(by.css('a[title=Edit]'));
+ expect(editOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Create the Project', function () {
+ browser.get(baseURL+"#/projects");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('testproject');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Project is successfully created."))
.isDisplayed()).toBe(true);
- });
+ });
- it('Show error when user click the create button with an already existing name', function () {
- browser.get(baseURL+ '/#/projects');
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.description'));
- name.sendKeys('testProject2');
- details.sendKeys('demoDescription');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click();
- expect(element(by.cssContainingText(".alert",
- "Error creating the new Project from server:undefined"))
+ it('Show error if user doesnt have permission to Create the Project', function () {
+ browser.get(baseURL+"#/projects");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var description = element(by.model('ProjectModalCtrl.project.description'));
+ name.sendKeys('testProject2');
+ description.sendKeys('demoDescription');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true);
+ });
+
+ it('Showing error when creating with a empty name ', function () {
+ browser.get(baseURL+"#/projects");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Name is missing."))
.isDisplayed()).toBe(true);
});
- it('Show error when user try to create a project which he is not belonged to ', function () {
- browser.get(baseURL+ '/#/projects');
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.description'));
- name.sendKeys('testProject3');
- details.sendKeys('demoDescription');
- var buttonCreate = element(by.buttonText('Create'));
+ it('Show error when user click the create button with an already existing name', function () {
+ browser.get(baseURL+"#/projects");
+ var buttonCreate = element(by.buttonText('Create'));
buttonCreate.click();
- expect(element(by.cssContainingText(".alert",
- 'Error creating the new Project from server:"You do not have permission to perform this action"')).isDisplayed())
- .toBe(true);
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var description = element(by.model('ProjectModalCtrl.project.description'));
+ name.sendKeys('testProject3');
+ description.sendKeys('demoDescription');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true);
});
- it('Do not show error if input is acceptable', function () {
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.description'));
- name.sendKeys('testProject1');
- details.sendKeys('demoDescription');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click().then(function(){
- expect(element(by.cssContainingText(".alert",
- "Create Success"))
- .isDisplayed()).toBe(true);
- });
+ it('cancel the delete confimation modal of the project ', function () {
+ browser.get(baseURL+"#/projects");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonCancel = element(by.buttonText('Cancel'));
+ buttonCancel.click();
+ expect(buttonCancel.isPresent()).toBe(false);
+ });
+
+ it('Delete the projects ', function () {
+ browser.get(baseURL+"#/projects");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Projects is successfully deleted"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it(' Show error if user doesnt has permission to delete the projects ', function () {
+ mock.teardown();
+ mock([
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-testProject1-submitters",
+ "opnfv-gerrit-testProject2-submitters" ],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject3',
+ method: 'DELETE'
+ },
+ response: {
+ status: 403
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data : {
+ "projects": [
+ {
+ "_id": "5a0c1c9a9a07c846d3a7247b",
+ "creation_date": "2017-11-15 16:23:14.217093",
+ "description": "sdgfd",
+ "name": "testproject3"
+ }]
+ }
+ }
+ }
+ ]);
+ browser.get(baseURL+"#/projects");
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true);
+ });
+
+ it('cancel the Edit modal of the Project ', function () {
+ browser.get(baseURL+"#/projects");
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonCancel = element(by.buttonText('Cancel'));
+ buttonCancel.click();
+ expect(name.isPresent()).toBe(false);
+ });
+
+ it('Edit the Project ', function () {
+ browser.get(baseURL+"#/projects");
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click()
+ expect(element(by.cssContainingText(".alert","Project is successfully updated."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Show error if user doesnt has permission to edit the projects ', function () {
+ mock.teardown();
+ mock([
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-testProject1-submitters",
+ "opnfv-gerrit-testProject2-submitters" ],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject3',
+ method: 'PUT'
+ },
+ response: {
+ status: 403
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data : {
+ "projects": [
+ {
+ "_id": "5a0c1c9a9a07c846d3a7247b",
+ "creation_date": "2017-11-15 16:23:14.217093",
+ "description": "sdgfd",
+ "name": "testproject3"
+ }]
+ }
+ }
+ }
+ ]);
+ browser.get(baseURL+"#/projects");
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click()
+ expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true);
+ });
+
+ it('Batch Delete the projects ', function () {
+ browser.get(baseURL+"#/projects");
+ var checkBox = element(by.model('ctrl.checkBox[index]'));
+ checkBox.click();
+ var buttonDelete = element(by.buttonText('Delete'));;
+ buttonDelete.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Projects is successfully deleted"))
+ .isDisplayed()).toBe(true);
});
it('If backend is not responding then show error when user click the create button',function(){
@@ -258,13 +564,17 @@ describe('testing the Project Link for user who is in submitter group', function
}
}
]);
- browser.get(baseURL+ '/#/projects');
- var name = element(by.model('ctrl.name'));
- var details = element(by.model('ctrl.description'));
- name.sendKeys('testProject1');
+ browser.get(baseURL+"#/projects");
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('ProjectModalCtrl.project.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var details = element(by.model('ProjectModalCtrl.project.description'));
+ name.sendKeys('testproject');
details.sendKeys('demoDescription');
- var buttonCreate = element(by.buttonText('Create'));
- buttonCreate.click().then(function(){
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click().then(function(){
expect(element(by.css(".alert.alert-danger")).isDisplayed()).toBe(true);
});
});
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js
new file mode 100644
index 0000000..d6dfa1c
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/UI/e2e/resultsControllerSpec.js
@@ -0,0 +1,381 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000/"
+
+describe('testing the result page for anonymous user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f4",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1',
+ project: 'testproject'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f5",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1',
+ project: 'testproject',
+ case: 'testcase'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f6",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the results page for anonymous user', function() {
+ browser.get(baseURL+"#/results");
+ expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true);
+ });
+
+ it( 'navigate anonymous user to results page', function() {
+ browser.get(baseURL);
+ var resultLink = element(by.linkText('Results')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/results'), 10000);
+ });
+
+ it('Should show the results in results page for anonymous user ', function () {
+ browser.get(baseURL+"#/results");
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4");
+ });
+
+ it('Should show the results in results page related to the filters for anonymous user ', function () {
+ browser.get(baseURL+"#/results");
+ var filter = element(by.model('ctrl.filter'));
+ var filterText = element(by.model('ctrl.filterText'));
+ filter.sendKeys('project');
+ filterText.sendKeys('testproject');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click();
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5");
+ filter.sendKeys('case');
+ filterText.sendKeys('testcase')
+ buttonFilter.click();
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6");
+ });
+ it('Should not show the results in results page related to the filters for anonymous user ', function () {
+ browser.get(baseURL+"#/results");
+ var filter = element(by.model('ctrl.filter'));
+ var filterText = element(by.model('ctrl.filterText'));
+ filter.sendKeys('project');
+ filterText.sendKeys('testproject1');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click();
+ expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
+ .isDisplayed()).toBe(true);
+ });
+
+});
+
+describe('testing the result page for user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users"],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f4",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1',
+ project: 'testproject'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f5",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/results',
+ method: 'GET',
+ queryString: {
+ page: '1',
+ project: 'testproject',
+ case: 'testcase'
+ }
+ },
+ response: {
+ data: {
+ "pagination": {
+ "current_page": 1,
+ "total_pages": 1
+ },
+ "results": [
+ {
+ "project_name": "testproject",
+ "description": "Demo results",
+ "stop_date": "2017-12-28 16:08:43",
+ "case_name": "testcase",
+ "build_tag": null,
+ "user": null,
+ "installer": "fuel",
+ "scenario": "test-scenario",
+ "trust_indicator": null,
+ "public": "true",
+ "version": "euphrates",
+ "details": "",
+ "criteria": "PASS",
+ "_id": "5a45170bbb2092000e2643f6",
+ "start_date": "2017-12-28 14:44:27",
+ "pod_name": "testPod"
+ }
+ ]
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the results page for user', function() {
+ browser.get(baseURL+"#/results");
+ expect(element(by.cssContainingText(".ng-binding.ng-scope","Test Results")).isDisplayed()).toBe(true);
+ });
+
+ it( 'navigate user to testCase page', function() {
+ browser.get(baseURL);
+ var resultLink = element(by.linkText('Results')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/results'), 10000);
+ });
+
+ it('Should show the results in results page for user ', function () {
+ browser.get(baseURL+"#/results");
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4");
+ });
+
+ it('Should show the results in results page related to the filters for user ', function () {
+ browser.get(baseURL+"#/results");
+ var filter = element(by.model('ctrl.filter'));
+ var filterText = element(by.model('ctrl.filterText'));
+ filter.sendKeys('project');
+ filterText.sendKeys('testproject');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click();
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5");
+ filter.sendKeys('case');
+ filterText.sendKeys('testcase')
+ buttonFilter.click();
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f6");
+ });
+
+ it('Clear the filter', function () {
+ browser.get(baseURL+"#/results");
+ var filter = element(by.model('ctrl.filter'));
+ var filterText = element(by.model('ctrl.filterText'));
+ filter.sendKeys('project');
+ filterText.sendKeys('testproject');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click();
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f5");
+ var buttonClear = element(by.buttonText('Clear'));
+ buttonClear.click();
+ var row = element.all(by.repeater('(index, result) in ctrl.data.results')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("5a45170bbb2092000e2643f4");
+ });
+ it('Should not show the results in results page related to the filters for user ', function () {
+ browser.get(baseURL+"#/results");
+ var filter = element(by.model('ctrl.filter'));
+ var filterText = element(by.model('ctrl.filterText'));
+ filter.sendKeys('project');
+ filterText.sendKeys('testproject1');
+ var buttonFilter = element(by.buttonText('Filter'));
+ buttonFilter.click();
+ expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope'))
+ .isDisplayed()).toBe(true);
+ });
+
+}); \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js
new file mode 100644
index 0000000..f97a621
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js
@@ -0,0 +1,1041 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000/"
+
+describe('testing the scenarios page for anonymous user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/scenarios',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "scenarios": [
+ {
+ "installers": [
+ {
+ "installer": "fuel",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "dvs"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "score": "10/13"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "status": "sf"
+ },
+ {
+ "date": "2018-01-17T18:30:00.000Z",
+ "status": "df"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata",
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-19 13:22",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-22 18:17",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ },
+ {
+ "project": "sla",
+ "customs": [],
+ "scores": [
+ {
+ "date": "2018-01-16T18:30:00.000Z",
+ "score": "sdS"
+ }
+ ],
+ "trust_indicators": []
+ },
+ {
+ "project": "dvsd",
+ "customs": [],
+ "scores": [],
+ "trust_indicators": []
+ }
+ ]
+ },
+ {
+ "owner": "dfgvds",
+ "version": "df",
+ "projects": []
+ }
+ ]
+ },
+ {
+ "installer": "fuel2",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "tc002",
+ "tc005",
+ "tc010",
+ "tc011"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "_id": "5a50fcacsdgdsgdasgfvb861c",
+ "name": "test-scenario",
+ "creation_date": "2018-01-06 22:13:24.160407"
+ }
+ ]
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the scenarios page for anonymous user', function() {
+ browser.get(baseURL+"#/scenarios");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ var row = element.all(by.repeater('(index, scenario) in ctrl.data.scenarios')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test-scenario");
+ var scenarioLink = element(by.linkText('test-scenario')).click();
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ });
+
+ it( 'should not show the add installer option for anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[2]/button'))
+ expect(buttonAdd.isDisplayed()).toBe(false);
+ });
+
+ it( 'Expand installers by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installerShow.click();
+ var row = element.all(by.repeater('(indexI, installer) in ctrl.data.scenarios[0].installers')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("fuel");
+ });
+
+ it( 'should not show the delete installer option for anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[3]/button'))
+ expect(installerDelete.isDisplayed()).toBe(false);
+ });
+
+ it( 'Expand installer by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ expect(versionsShow.isDisplayed()).toBe(true)
+ });
+
+ it( 'Expand versions by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ expect(versionShow.isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand version by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ expect(projectsShow.isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand projects by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ expect(projectShow.isDisplayed()).toBe(true)
+ });
+
+ it( 'Expand project by anonymous user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[4]/td[2]/a/p'))
+ expect(customsShow.isDisplayed()).toBe(true)
+ var trustIndicatorsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/a/p'))
+ expect(trustIndicatorsShow.isDisplayed()).toBe(true)
+ var scoresShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/a/p'))
+ expect(scoresShow.isDisplayed()).toBe(true)
+ });
+
+});
+
+
+describe('testing the scenarios page for anonymous user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/scenarios',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "scenarios": [
+ {
+ "installers": [
+ {
+ "installer": "fuel",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "dvs"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "score": "10/13"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "status": "sf"
+ },
+ {
+ "date": "2018-01-17T18:30:00.000Z",
+ "status": "df"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata",
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-19 13:22",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-22 18:17",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ },
+ {
+ "project": "sla",
+ "customs": [],
+ "scores": [
+ {
+ "date": "2018-01-16T18:30:00.000Z",
+ "score": "sdS"
+ }
+ ],
+ "trust_indicators": []
+ },
+ {
+ "project": "dvsd",
+ "customs": [],
+ "scores": [],
+ "trust_indicators": []
+ }
+ ]
+ },
+ {
+ "owner": "dfgvds",
+ "version": "df",
+ "projects": []
+ }
+ ]
+ },
+ {
+ "installer": "fuel2",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "tc002",
+ "tc005",
+ "tc010",
+ "tc011"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "_id": "5a50fcacsdgdsgdasgfvb861c",
+ "name": "test-scenario",
+ "creation_date": "2018-01-06 22:13:24.160407"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users"],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/installers',
+ method: 'POST'
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/installers',
+ method: 'DELETE'
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/versions',
+ method: 'POST',
+ queryString: {
+ installer: 'fuel'
+ }
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/versions',
+ method: 'DELETE',
+ queryString: {
+ installer: 'fuel'
+ }
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/projects',
+ method: 'POST',
+ queryString: {
+ installer: 'fuel',
+ version: 'colorado'
+ }
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/projects',
+ method: 'DELETE',
+ queryString: {
+ installer: 'fuel',
+ version: 'colorado'
+ }
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/customs',
+ method: 'POST',
+ queryString: {
+ installer: 'fuel',
+ version: 'colorado',
+ project: 'yardstick'
+ }
+ },
+ response: {
+ status : 200
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario/customs',
+ method: 'DELETE',
+ queryString: {
+ installer: 'fuel',
+ version: 'colorado',
+ project: 'yardstick'
+ }
+ },
+ response: {
+ status : 200
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the scenarios page for user', function() {
+ browser.get(baseURL+"#/scenarios");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ var row = element.all(by.repeater('(index, scenario) in ctrl.data.scenarios')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test-scenario");
+ var scenarioLink = element(by.linkText('test-scenario')).click();
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ });
+
+ it( 'should not show the add installer option for user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[2]/button'))
+ expect(buttonAdd.isDisplayed()).toBe(true);
+ });
+
+ it('add installer', function(){
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[2]/button'))
+ buttonAdd.click();
+ var name = element(by.model('installerModalCtrl.installer.installer'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]'))
+ buttonOk.click()
+ expect(element(by.cssContainingText(".alert","Installers are successfully updated."))
+ .isDisplayed()).toBe(true);
+
+ });
+
+ it( 'Expand installers by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installerShow.click();
+ var row = element.all(by.repeater('(indexI, installer) in ctrl.data.scenarios[0].installers')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("fuel");
+ });
+
+ it( 'should show the delete installer option for user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[3]/button'))
+ expect(installerDelete.isDisplayed()).toBe(true);
+ });
+
+ it( 'delete installer', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[3]/button'))
+ installerDelete.click()
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Installer is successfully deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand installer by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ expect(versionsShow.isDisplayed()).toBe(true)
+ });
+
+ it( 'add version for an installer', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[2]/button'))
+ versionAdd.click()
+ var version = element(by.model('versionModalCtrl.version.version'));
+ browser.wait(EC.visibilityOf(version), 5000);
+ version.sendKeys('testV');
+ var owner = element(by.model('versionModalCtrl.version.owner'));
+ owner.sendKeys('testOwner');
+ var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]'))
+ buttonOk.click()
+ expect(element(by.cssContainingText(".alert","Versions are successfully updated."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand versions by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ expect(versionShow.isDisplayed()).toBe(true);
+ var installerAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[2]/button'))
+ var installerDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[3]/button'))
+ expect(installerAdd.isDisplayed()).toBe(false);
+ expect(installerDelete.isDisplayed()).toBe(false)
+ });
+
+ it( 'delete version', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var versionDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody[1]/tr[1]/td[3]/button'))
+ versionDelete.click()
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Versions are successfully deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand version by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ expect(projectsShow.isDisplayed()).toBe(true);
+ });
+
+ it( 'add project', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[2]/button'))
+ projectAdd.click()
+ var project = element(by.model('projectModalCtrl.project.project'));
+ browser.wait(EC.visibilityOf(project), 5000);
+ project.sendKeys('testP');
+ var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]'))
+ buttonOk.click()
+ expect(element(by.cssContainingText(".alert","Projects are successfully updated."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand projects by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ expect(projectShow.isDisplayed()).toBe(true)
+ var versionAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[2]/button'))
+ var versionDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[3]/button'))
+ expect(versionAdd.isDisplayed()).toBe(false)
+ expect(versionDelete.isDisplayed()).toBe(false)
+ });
+
+ it( 'delete project', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[1]/td[3]/button'))
+ projectDelete.click()
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Projects are successfully Deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Expand project by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[4]/td[2]/a/p'))
+ expect(customsShow.isDisplayed()).toBe(true)
+ var trustIndicatorsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/a/p'))
+ expect(trustIndicatorsShow.isDisplayed()).toBe(true)
+ var scoresShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/a/p'))
+ expect(scoresShow.isDisplayed()).toBe(true)
+ });
+
+ it( 'Expand trust indicator by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var trustIndicatorsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/a/p'))
+ trustIndicatorsShow.click();
+ var row = element.all(by.repeater('(indexTI, trust_indicator) in project.trust_indicators')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("silver");
+ });
+
+ it( 'Expand score by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var scoresShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[3]/td[2]/a/p'))
+ scoresShow.click();
+ var row = element.all(by.repeater('(indexSC, score) in project.scores')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("14/24");
+ });
+
+ it( 'Expand Customs by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/a/p'))
+ customsShow.click();
+ var row = element.all(by.repeater('(indexCU, custom) in project.customs')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("dvs");
+ var projectAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[2]/button'))
+ var projectDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[1]/td[3]/button'))
+ expect(projectDelete.isDisplayed()).toBe(false)
+ expect(projectAdd.isDisplayed()).toBe(false)
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/button'))
+ var buttonDelete = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/table/tbody/tr[1]/td[2]/button'))
+ expect(buttonAdd.isDisplayed()).toBe(true)
+ expect(buttonDelete.isDisplayed()).toBe(true)
+ });
+
+ it( 'Add Customs by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/a/p'))
+ customsShow.click();
+ var row = element.all(by.repeater('(indexCU, custom) in project.customs')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("dvs");
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/button'))
+ buttonAdd.click()
+ var custom = element(by.model('customModalCtrl.custom'));
+ browser.wait(EC.visibilityOf(custom), 5000);
+ custom.sendKeys('testC');
+ var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]'))
+ buttonOk.click()
+ expect(element(by.cssContainingText(".alert","Customs are successfully updated."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it( 'Delete Customs by user', function() {
+ browser.get(baseURL+"#/scenarios/test-scenario");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ var installersShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[1]/a/p'))
+ installersShow.click();
+ var installerShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ installerShow.click();
+ var versionsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[1]/a/p'))
+ versionsShow.click();
+ var versionShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ versionShow.click()
+ var projectsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[1]/a'))
+ projectsShow.click();
+ var projectShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody/tr[1]/td[2]/a'))
+ projectShow.click();
+ var customsShow = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/a/p'))
+ customsShow.click();
+ var row = element.all(by.repeater('(indexCU, custom) in project.customs')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(0).getText()).toContain("dvs");
+ var buttonAdd = element(by.xpath('//*[@id="ng-app"]/body/div/div[1]/div/table/tbody/tr[4]/td[2]/div[3]/div/table/tbody/tr[2]/td[2]/div[3]/div/table/tbody/tr[3]/td[2]/div[3]/div/table/tbody[1]/tr[4]/td[2]/table/tbody/tr[1]/td[2]/button'))
+ buttonAdd.click()
+ var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div[3]/button[1]'))
+ buttonOk.click()
+ expect(element(by.cssContainingText(".alert","Customs are successfully deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+}); \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/scenariosControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/scenariosControllerSpec.js
new file mode 100644
index 0000000..505b42f
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/UI/e2e/scenariosControllerSpec.js
@@ -0,0 +1,725 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000/"
+
+describe('testing the scenarios page for anonymous user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/scenarios',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "scenarios": [
+ {
+ "installers": [
+ {
+ "installer": "fuel",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "dvs"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "score": "10/13"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "status": "sf"
+ },
+ {
+ "date": "2018-01-17T18:30:00.000Z",
+ "status": "df"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata",
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-19 13:22",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-22 18:17",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ },
+ {
+ "project": "sla",
+ "customs": [],
+ "scores": [
+ {
+ "date": "2018-01-16T18:30:00.000Z",
+ "score": "sdS"
+ }
+ ],
+ "trust_indicators": []
+ },
+ {
+ "project": "dvsd",
+ "customs": [],
+ "scores": [],
+ "trust_indicators": []
+ }
+ ]
+ },
+ {
+ "owner": "dfgvds",
+ "version": "df",
+ "projects": []
+ }
+ ]
+ },
+ {
+ "installer": "fuel2",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "tc002",
+ "tc005",
+ "tc010",
+ "tc011"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "_id": "5a50fcacsdgdsgdasgfvb861c",
+ "name": "test-scenario",
+ "creation_date": "2018-01-06 22:13:24.160407"
+ }
+ ]
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the scenarios page for anonymous user', function() {
+ browser.get(baseURL+"#/scenarios");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ });
+
+ it( 'navigate anonymous user to scenarios page', function() {
+ browser.get(baseURL);
+ var resultLink = element(by.linkText('Scenarios')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ });
+
+ it('Should show the scenarios in scenarios page for anonymous user ', function () {
+ browser.get(baseURL+"#/scenarios");
+ var row = element.all(by.repeater('(index, scenario) in ctrl.data.scenarios')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test-scenario");
+ });
+
+ it('create button is not visible for anonymous user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
+ });
+ it('delete button is not visible for anonymous user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Delete'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
+ });
+
+});
+
+describe('testing the scenarios page for user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/scenarios',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "scenarios": [
+ {
+ "installers": [
+ {
+ "installer": "fuel",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "dvs"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "score": "10/13"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ },
+ {
+ "date": "2018-01-22T18:30:00.000Z",
+ "status": "sf"
+ },
+ {
+ "date": "2018-01-17T18:30:00.000Z",
+ "status": "df"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata",
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-19 13:22",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-22 18:17",
+ "score": "8/8"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ },
+ {
+ "project": "sla",
+ "customs": [],
+ "scores": [
+ {
+ "date": "2018-01-16T18:30:00.000Z",
+ "score": "sdS"
+ }
+ ],
+ "trust_indicators": []
+ },
+ {
+ "project": "dvsd",
+ "customs": [],
+ "scores": [],
+ "trust_indicators": []
+ }
+ ]
+ },
+ {
+ "owner": "dfgvds",
+ "version": "df",
+ "projects": []
+ }
+ ]
+ },
+ {
+ "installer": "fuel2",
+ "versions": [
+ {
+ "owner": "testUser",
+ "version": "colorado",
+ "projects": [
+ {
+ "project": "yardstick",
+ "customs": [
+ "tc002",
+ "tc005",
+ "tc010",
+ "tc011"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-11 01:45",
+ "score": "14/24"
+ },
+ {
+ "date": "2016-12-15 05:28",
+ "score": "17/24"
+ },
+ {
+ "date": "2016-12-17 03:41",
+ "score": "16/24"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ },
+ {
+ "date": "2016-12-25 08:22",
+ "status": "gold"
+ }
+ ]
+ },
+ {
+ "project": "functest",
+ "customs": [
+ "vping_ssh",
+ "vping_userdata"
+ ],
+ "scores": [
+ {
+ "date": "2016-12-09 11:28",
+ "score": "6/8"
+ },
+ {
+ "date": "2016-12-14 15:34",
+ "score": "8/8"
+ }
+ ],
+ "trust_indicators": [
+ {
+ "date": "2016-12-09 11:38",
+ "status": "silver"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "_id": "5a50fcacsdgdsgdasgfvb861c",
+ "name": "test-scenario",
+ "creation_date": "2018-01-06 22:13:24.160407"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users"],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios',
+ method: 'POST'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/scenarios/testScenario"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario',
+ method: 'DELETE'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/scenarios/testScenario"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/scenarios/test-scenario',
+ method: 'PUT'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/scenarios/testScenario"
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the scenarios page for user', function() {
+ browser.get(baseURL+"#/scenarios");
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ });
+
+ it( 'navigate user to scenarios page', function() {
+ browser.get(baseURL);
+ var resultLink = element(by.linkText('Scenarios')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios'), 10000);
+ });
+
+ it('Should show the scenarios in scenarios page for user ', function () {
+ browser.get(baseURL+"#/scenarios");
+ var row = element.all(by.repeater('(index, scenario) in ctrl.data.scenarios')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("test-scenario");
+ });
+
+ it('create button is not visible for user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBe(true);
+ });
+
+ it('delete button is not visible for user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBe(true);
+ });
+
+ it('craete scenarrio by user without installers ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create')).click();
+ var name = element(by.model('scenarioModalController.scenario.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('create scenarrio by user with installers ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create')).click();
+ var name = element(by.model('scenarioModalController.scenario.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonInstaller = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonInstaller.click();
+ var installer = element(by.model('installerModalCtrl.installer.installer'));
+ browser.wait(EC.visibilityOf(installer), 5000);
+ installer.sendKeys('testI');
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('create scenarrio by user with installers with versions ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create')).click();
+ var name = element(by.model('scenarioModalController.scenario.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonInstaller = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonInstaller.click();
+ var installer = element(by.model('installerModalCtrl.installer.installer'));
+ browser.wait(EC.visibilityOf(installer), 5000);
+ installer.sendKeys('testI');
+ var buttonVersion = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonVersion.click();
+ var version = element(by.model('versionModalCtrl.version.version'));
+ browser.wait(EC.visibilityOf(version), 5000);
+ version.sendKeys('testV');
+ var owner = element(by.model('versionModalCtrl.version.owner'));
+ owner.sendKeys('testOwner');
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[5]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('create scenarrio by user with installers with versions with project', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create')).click();
+ var name = element(by.model('scenarioModalController.scenario.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonInstaller = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonInstaller.click();
+ var installer = element(by.model('installerModalCtrl.installer.installer'));
+ browser.wait(EC.visibilityOf(installer), 5000);
+ installer.sendKeys('testI');
+ var buttonVersion = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonVersion.click();
+ var version = element(by.model('versionModalCtrl.version.version'));
+ browser.wait(EC.visibilityOf(version), 5000);
+ version.sendKeys('testV');
+ var owner = element(by.model('versionModalCtrl.version.owner'));
+ owner.sendKeys('testOwner');
+ var buttonProject = element(by.xpath('//*[@id="ng-app"]/body/div[5]/div/div/div/div[1]/div[1]/fieldset/div/div/div[3]/div[2]/button'))
+ buttonProject.click();
+ var project = element(by.model('projectModalCtrl.project.project'));
+ browser.wait(EC.visibilityOf(project), 5000);
+ project.sendKeys('testP');
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[6]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[5]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('create scenarrio by user with installers with versions with project with custom', function () {
+ browser.get(baseURL+'#/scenarios');
+ var buttonCreate = element(by.buttonText('Create')).click();
+ var name = element(by.model('scenarioModalController.scenario.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonInstaller = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonInstaller.click();
+ var installer = element(by.model('installerModalCtrl.installer.installer'));
+ browser.wait(EC.visibilityOf(installer), 5000);
+ installer.sendKeys('testI');
+ var buttonVersion = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonVersion.click();
+ var version = element(by.model('versionModalCtrl.version.version'));
+ browser.wait(EC.visibilityOf(version), 5000);
+ version.sendKeys('testV');
+ var owner = element(by.model('versionModalCtrl.version.owner'));
+ owner.sendKeys('testOwner');
+ var buttonProject = element(by.xpath('//*[@id="ng-app"]/body/div[5]/div/div/div/div[1]/div[1]/fieldset/div/div/div[3]/div[2]/button'))
+ buttonProject.click();
+ var project = element(by.model('projectModalCtrl.project.project'));
+ browser.wait(EC.visibilityOf(project), 5000);
+ project.sendKeys('testP');
+ var buttonCustom = element(by.xpath('//*[@id="ng-app"]/body/div[6]/div/div/div/div[1]/div[1]/fieldset/div/div/div[2]/div[2]/button'))
+ buttonCustom.click();
+ var custom = element(by.model('customModalCtrl.custom'));
+ browser.wait(EC.visibilityOf(custom), 5000);
+ custom.sendKeys('testC');
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[7]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[6]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[5]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.xpath('//*[@id="ng-app"]/body/div[4]/div/div/div/div[2]/button[1]'));
+ buttonOK.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('view scenarrio by user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var scenarioLink = element(by.linkText('test-scenario')).click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/scenarios/test-scenario'), 10000);
+ });
+
+ it('delete Operation is visible for user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBe(true);
+ });
+
+ it('edit Operation is visible for user ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var deleteOperation = element(by.css('a[title=Edit]'));
+ expect(deleteOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Delete the Scenario ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Batch Delete the scenarios ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var checkBox = element(by.model('ctrl.checkBox[index]'));
+ checkBox.click();
+ var buttonDelete = element(by.buttonText('Delete'));;
+ buttonDelete.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Scenario is successfully deleted."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Edit the scenarios ', function () {
+ browser.get(baseURL+'#/scenarios');
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('ScenarioNameUpdateCtrl.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test2');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click()
+ expect(element(by.cssContainingText(".alert","Scenario is successfully Updated."))
+ .isDisplayed()).toBe(true);
+ });
+
+}); \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/UI/e2e/testCasesControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/testCasesControllerSpec.js
new file mode 100644
index 0000000..d509c57
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/UI/e2e/testCasesControllerSpec.js
@@ -0,0 +1,650 @@
+'use strict';
+
+var mock = require('protractor-http-mock');
+var baseURL = "http://localhost:8000/"
+
+describe('testing the testCases page for anonymous user', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "projects": [
+ {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "testcases": [
+ {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases/testCase',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the testCases for anonymous user', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var row = element.all(by.repeater('(index, testcase) in testCasesCtrl.data.testcases')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("testCase");
+ });
+
+ it( 'navigate anonymous user to testCase page', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var testCase = element(by.linkText('testCase'));
+ testCase.click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/projects/testproject/testCase'), 10000);
+ });
+
+ it('create button is not visible for anonymous user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
+ });
+
+ it('Delete button is not visible for anonymous user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBeFalsy();
+ });
+
+ it('delete Operation is not visible for anonymous user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBeFalsy();
+ });
+
+ it('Edit Operation is not visible for anonymous user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var editOperation = element(by.css('a[title=Edit]'));
+ expect(editOperation.isDisplayed()).toBeFalsy();
+ });
+});
+
+describe('testing the testcaese page for user who is not in submitter group', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users"],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "projects": [
+ {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "testcases": [
+ {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases/testCase',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the testCases for user', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var row = element.all(by.repeater('(index, testcase) in testCasesCtrl.data.testcases')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("testCase");
+ });
+
+ it( 'navigate user to testCase page', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var testCase = element(by.linkText('testCase'));
+ testCase.click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/projects/testproject/testCase'), 10000);
+ });
+
+ it('create button is not visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBeFalsy();
+ });
+
+ it('Delete button is not visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBeFalsy();
+ });
+
+ it('delete Operation is not visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBeFalsy();
+ });
+
+ it('Edit Operation is not visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var editOperation = element(by.css('a[title=Edit]'));
+ expect(editOperation.isDisplayed()).toBeFalsy();
+ });
+})
+
+describe('testing the test cases page for user who is in submitter group', function () {
+ beforeEach(function(){
+ mock([
+ {
+ request: {
+ path: '/api/v1/profile',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed",
+ "user": "testUser", "groups": ["opnfv-testapi-users",
+ "opnfv-gerrit-testProject-submitters"],
+ "email": "testuser@test.com"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases',
+ method: 'POST'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/projects/testProject/cases/testCase"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases/testCase',
+ method: 'PUT'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/projects/testProject/cases/testCase"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases/testCase',
+ method: 'DELETE'
+ },
+ response: {
+ data: {
+ href: baseURL+"/api/v1/projects/testProject/cases/testCase"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testProject3/cases',
+ method: 'POST',
+ data: {
+ name: 'testCase2',
+ description : 'demoDescription',
+ }
+ },
+ response: {
+ status : 403,
+ data : 'You do not have permission to perform this action'
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "projects": [
+ {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "owner": "thuva4",
+ "_id": "5a0c022f9a07c846d3c2cc94",
+ "creation_date": "2017-11-15 14:30:31.200259",
+ "description": "dsfsd",
+ "name": "testproject"
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "testcases": [
+ {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ ]
+ }
+ }
+ },
+ {
+ request: {
+ path: '/api/v1/projects/testproject/cases/testCase',
+ method: 'GET'
+ },
+ response: {
+ data: {
+ "project_name": "testproject",
+ "run": null,
+ "description": null,
+ "tags": null,
+ "creation_date": "2017-12-20 18:47:04.025544",
+ "dependencies": null,
+ "tier": null,
+ "trust": null,
+ "blocking": null,
+ "name": "testCase",
+ "ci_loop": null,
+ "url": null,
+ "version": null,
+ "criteria": null,
+ "domains": null,
+ "_id": "5a3a62d09a07c836e06858fb",
+ "catalog_description": null
+ }
+ }
+ }
+ ]);
+ });
+
+ afterEach(function(){
+ mock.teardown();
+ });
+
+ it( 'should show the testCases for user', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var row = element.all(by.repeater('(index, testcase) in testCasesCtrl.data.testcases')).first();
+ var cells = row.all(by.tagName('td'));
+ expect(cells.get(1).getText()).toContain("testCase");
+ });
+
+ it( 'navigate user to testCase page', function() {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var testCase = element(by.linkText('testCase'));
+ testCase.click();
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/projects/testproject/testCase'), 10000);
+ });
+
+ it('create button is visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonCreate = element(by.buttonText('Create'));
+ expect(buttonCreate.isDisplayed()).toBe(true);
+ });
+
+ it('Delete button is visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonDelete = element(by.buttonText('Delete'));
+ expect(buttonDelete.isDisplayed()).toBe(true);
+ });
+
+ it('delete Operation is visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ expect(deleteOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Edit Operation is visible for user ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var editOperation = element(by.css('a[title=Edit]'));
+ expect(editOperation.isDisplayed()).toBe(true);
+ });
+
+ it('Create the test case', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('TestCaseModalCtrl.testcase.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Testcase is successfully created."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('Showing error when creating with a empty name ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var buttonCreate = element(by.buttonText('Create'));
+ buttonCreate.click();
+ var name = element(by.model('TestCaseModalCtrl.testcase.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Name is missing."))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('cancel the delete confimation modal of the test case ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonCancel = element(by.buttonText('Cancel'));
+ buttonCancel.click();
+ expect(buttonCancel.isPresent()).toBe(false);
+ });
+
+ it('Delete the test case ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var deleteOperation = element(by.css('a[title=Delete]'));
+ deleteOperation.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Test case is successfully deleted"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('cancel the Edit modal of the test case ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('TestCaseModalCtrl.testcase.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonCancel = element(by.buttonText('Cancel'));
+ buttonCancel.click();
+ expect(name.isPresent()).toBe(false);
+ });
+
+ it('Edit the test case ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var editOperation = element(by.css('a[title=Edit]'));
+ editOperation.click();
+ var name = element(by.model('TestCaseModalCtrl.testcase.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.visibilityOf(name), 5000);
+ name.sendKeys('test1');
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Test case is successfully updated"))
+ .isDisplayed()).toBe(true);
+ });
+
+ it('view the test case ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var viewOperation = element(by.linkText('testCase'));
+ viewOperation.click();
+ var name = element(by.model('TestCaseModalCtrl.testcase.name'));
+ var EC = browser.ExpectedConditions;
+ browser.wait(EC.urlContains(baseURL+ '#/projects/testproject/testCase'), 10000);
+ });
+
+ it('Batch Delete the test Cases ', function () {
+ browser.get(baseURL+"#/projects/testproject");
+ var testCases = element(by.linkText('Test Cases'));
+ testCases.click();
+ var checkBox = element(by.model('testCasesCtrl.checkBox[index]'));
+ checkBox.click();
+ var buttonDelete = element(by.buttonText('Delete'));;
+ buttonDelete.click();
+ var buttonOK = element(by.buttonText('Ok'));
+ buttonOK.click();
+ expect(element(by.cssContainingText(".alert","Test case is successfully deleted"))
+ .isDisplayed()).toBe(true);
+ });
+})
diff --git a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
index 39b7e6a..041e6e8 100644
--- a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
+++ b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py
@@ -178,6 +178,9 @@ class MemDb(object):
elif i_k == 'versions.projects.project':
return self._in_scenarios_project(i_v,
content)
+ elif isinstance(v, re._pattern_type):
+ if v.match(content.get(k, None)) is None:
+ return False
elif content.get(k, None) != v:
return False
@@ -285,6 +288,7 @@ pods = MemDb('pods')
projects = MemDb('projects')
testcases = MemDb('testcases')
results = MemDb('results')
+deployresults = MemDb('deployresults')
scenarios = MemDb('scenarios')
tokens = MemDb('tokens')
users = MemDb('users')
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_base.py b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
index 4e5c0d9..6436b8b 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
@@ -36,14 +36,14 @@ class TestBase(testing.AsyncHTTPTestCase):
role='community-ci',
_id=str(ObjectId()),
owner='ValidUser',
- create_date=str(datetime.now()))
+ creation_date=str(datetime.now()))
self.pod_e = pod_models.Pod(name='zte-pod2',
mode='metal',
details='zte pod 2',
role='production-ci',
_id=str(ObjectId()),
owner='ValidUser',
- create_date=str(datetime.now()))
+ creation_date=str(datetime.now()))
self.project_e = project_models.Project(
name='functest',
description='functest test',
@@ -81,6 +81,16 @@ class TestBase(testing.AsyncHTTPTestCase):
self.config_patcher.start()
self.db_patcher.start()
+ @staticmethod
+ def load_json(json_file):
+ abs_file = path.join(path.dirname(__file__),
+ '../templates',
+ json_file + '.json')
+ with open(abs_file, 'r') as f:
+ loader = json.load(f)
+ f.close()
+ return loader
+
def get_app(self):
from opnfv_testapi.cmd import server
return server.make_app()
@@ -210,4 +220,5 @@ class TestBase(testing.AsyncHTTPTestCase):
fake_pymongo.projects.clear()
fake_pymongo.testcases.clear()
fake_pymongo.results.clear()
+ fake_pymongo.deployresults.clear()
fake_pymongo.scenarios.clear()
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_deploy_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_deploy_result.py
new file mode 100644
index 0000000..65e765e
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_deploy_result.py
@@ -0,0 +1,201 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corporation
+# feng.xiaowei@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import copy
+from datetime import datetime
+from datetime import timedelta
+import httplib
+import urllib
+
+from opnfv_testapi.common import message
+from opnfv_testapi.models import deploy_result_models as drm
+from opnfv_testapi.tests.unit import executor
+from opnfv_testapi.tests.unit import fake_pymongo
+from opnfv_testapi.tests.unit.handlers import test_base as base
+
+
+class DeployResultBase(base.TestBase):
+ @executor.mock_valid_lfid()
+ def setUp(self):
+ super(DeployResultBase, self).setUp()
+ self.req_d = drm.DeployResultCreateRequest.from_dict(
+ self.load_json('deploy_result'))
+ self.req_d.start_date = str(datetime.now())
+ self.req_d.stop_date = str(datetime.now() + timedelta(minutes=1))
+ self.get_res = drm.DeployResult
+ self.list_res = drm.DeployResults
+ self.basePath = '/api/v1/deployresults'
+ fake_pymongo.pods.insert(self.pod_d.format())
+
+ def assert_res(self, deploy_result, req=None):
+ if req is None:
+ req = self.req_d
+ print req.format()
+ self.assertEqual(deploy_result, req)
+ self.assertIsNotNone(deploy_result._id)
+
+ def _create_d(self):
+ _, res = self.create_d()
+ return res.href.split('/')[-1]
+
+
+class DeployResultCreate(DeployResultBase):
+ @executor.create(httplib.BAD_REQUEST, message.no_body())
+ def test_nobody(self):
+ return None
+
+ @executor.create(httplib.BAD_REQUEST, message.missing('pod_name'))
+ def test_podNotProvided(self):
+ req = self.req_d
+ req.pod_name = None
+ return req
+
+ @executor.create(httplib.BAD_REQUEST, message.missing('installer'))
+ def test_installerNotProvided(self):
+ req = self.req_d
+ req.installer = None
+ return req
+
+ @executor.create(httplib.BAD_REQUEST, message.missing('scenario'))
+ def test_testcaseNotProvided(self):
+ req = self.req_d
+ req.scenario = None
+ return req
+
+ @executor.create(httplib.BAD_REQUEST,
+ message.invalid_value('criteria', ['PASS', 'FAIL']))
+ def test_invalid_criteria(self):
+ req = self.req_d
+ req.criteria = 'invalid'
+ return req
+
+ @executor.create(httplib.FORBIDDEN, message.not_found_base)
+ def test_noPod(self):
+ req = self.req_d
+ req.pod_name = 'notExistPod'
+ return req
+
+ @executor.create(httplib.OK, 'assert_href')
+ def test_success(self):
+ return self.req_d
+
+
+class DeployResultGet(DeployResultBase):
+ def setUp(self):
+ super(DeployResultGet, self).setUp()
+ self.req_10d_before = self._create_changed_date(days=-10)
+ self.req_d_id = self._create_d()
+ self.req_10d_later = self._create_changed_date(days=10)
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryInstaller(self):
+ return self._set_query('installer')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryVersion(self):
+ return self._set_query('version')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryPod(self):
+ return self._set_query('pod_name')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryJob(self):
+ return self._set_query('job_name')
+
+ @executor.query(httplib.OK, '_query_success', 1)
+ def test_queryBuildId(self):
+ return self._set_query('build_id')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryScenario(self):
+ return self._set_query('scenario')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryUpstreamJobName(self):
+ return self._set_query('upstream_job_name')
+
+ @executor.query(httplib.OK, '_query_success', 1)
+ def test_queryUpstreamBuildId(self):
+ return self._set_query('upstream_build_id')
+
+ @executor.query(httplib.OK, '_query_success', 3)
+ def test_queryCriteria(self):
+ return self._set_query('criteria')
+
+ @executor.query(httplib.BAD_REQUEST, message.must_int('period'))
+ def test_queryPeriodNotInt(self):
+ return self._set_query(period='a')
+
+ @executor.query(httplib.OK, '_query_period_one', 1)
+ def test_queryPeriodSuccess(self):
+ return self._set_query(period=5)
+
+ @executor.query(httplib.BAD_REQUEST, message.must_int('last'))
+ def test_queryLastNotInt(self):
+ return self._set_query(last='a')
+
+ @executor.query(httplib.OK, '_query_last_one', 1)
+ def test_queryLast(self):
+ return self._set_query(last=1)
+
+ @executor.query(httplib.OK, '_query_period_one', 1)
+ def test_combination(self):
+ return self._set_query('installer',
+ 'version',
+ 'pod_name',
+ 'job_name',
+ 'build_id',
+ 'scenario',
+ 'upstream_job_name',
+ 'upstream_build_id',
+ 'criteria',
+ period=5)
+
+ @executor.query(httplib.OK, '_query_success', 1)
+ def test_filterErrorStartdate(self):
+ self._create_error_start_date(None)
+ self._create_error_start_date('None')
+ self._create_error_start_date('null')
+ self._create_error_start_date('')
+ return self._set_query(period=5)
+
+ def _query_success(self, body, number):
+ self.assertEqual(number, len(body.deployresults))
+
+ def _query_last_one(self, body, number):
+ self.assertEqual(number, len(body.deployresults))
+ self.assert_res(body.deployresults[0], self.req_10d_later)
+
+ def _query_period_one(self, body, number):
+ self.assertEqual(number, len(body.deployresults))
+ self.assert_res(body.deployresults[0], self.req_d)
+
+ def _create_error_start_date(self, start_date):
+ req = copy.deepcopy(self.req_d)
+ req.start_date = start_date
+ self.create(req)
+ return req
+
+ def _create_changed_date(self, **kwargs):
+ req = copy.deepcopy(self.req_d)
+ req.build_id = req.build_id + kwargs.get('days')
+ req.upstream_build_id = req.upstream_build_id + kwargs.get('days')
+ req.start_date = datetime.now() + timedelta(**kwargs)
+ req.stop_date = str(req.start_date + timedelta(minutes=10))
+ req.start_date = str(req.start_date)
+ self.create(req)
+ return req
+
+ def _set_query(self, *args, **kwargs):
+ query = []
+ for arg in args:
+ query.append((arg, getattr(self.req_d, arg)))
+ for k, v in kwargs.iteritems():
+ query.append((k, v))
+ return urllib.urlencode(query)
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py b/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
index 95ed8ba..2818513 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
@@ -7,10 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import httplib
-import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.models import pod_models
+from opnfv_testapi.models import pod_models as pm
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
from opnfv_testapi.tests.unit.handlers import test_base as base
@@ -19,26 +18,16 @@ from opnfv_testapi.tests.unit.handlers import test_base as base
class TestPodBase(base.TestBase):
def setUp(self):
super(TestPodBase, self).setUp()
- self.get_res = pod_models.Pod
- self.list_res = pod_models.Pods
+ self.get_res = pm.Pod
+ self.list_res = pm.Pods
self.basePath = '/api/v1/pods'
- self.req_d = pod_models.PodCreateRequest(name=self.pod_d.name,
- mode=self.pod_d.mode,
- details=self.pod_d.details,
- role=self.pod_d.role)
- self.req_e = pod_models.PodCreateRequest(name=self.pod_e.name,
- mode=self.pod_e.mode,
- details=self.pod_e.details,
- role=self.pod_e.role)
+ self.req_d = pm.PodCreateRequest.from_dict(self.pod_d.format())
+ self.req_e = pm.PodCreateRequest.from_dict(self.pod_e.format())
def assert_get_body(self, pod, req=None):
if not req:
req = self.req_d
- self.assertEqual(pod.owner, 'ValidUser')
- self.assertEqual(pod.name, req.name)
- self.assertEqual(pod.mode, req.mode)
- self.assertEqual(pod.details, req.details)
- self.assertEqual(pod.role, req.role)
+ self.assertEqual(pod, pm.Pod(owner='ValidUser', **req.format()))
self.assertIsNotNone(pod.creation_date)
self.assertIsNotNone(pod._id)
@@ -61,12 +50,12 @@ class TestPodCreate(TestPodBase):
@executor.mock_valid_lfid()
@executor.create(httplib.BAD_REQUEST, message.missing('name'))
def test_emptyName(self):
- return pod_models.PodCreateRequest('')
+ return pm.PodCreateRequest('')
@executor.mock_valid_lfid()
@executor.create(httplib.BAD_REQUEST, message.missing('name'))
def test_noneName(self):
- return pod_models.PodCreateRequest(None)
+ return pm.PodCreateRequest(None)
@executor.mock_valid_lfid()
@executor.create(httplib.OK, 'assert_create_body')
@@ -99,7 +88,7 @@ class TestPodGet(TestPodBase):
@executor.get(httplib.OK, 'assert_get_body')
def test_getOne(self):
- return self.pod_d.name
+ return self.req_d.name
@executor.get(httplib.OK, '_assert_list')
def test_list(self):
@@ -108,11 +97,7 @@ class TestPodGet(TestPodBase):
def _assert_list(self, body):
self.assertEqual(len(body.pods), 2)
for pod in body.pods:
- if self.pod_d.name == pod.name:
+ if self.req_d.name == pod.name:
self.assert_get_body(pod)
else:
- self.assert_get_body(pod, self.pod_e)
-
-
-if __name__ == '__main__':
- unittest.main()
+ self.assert_get_body(pod, self.req_e)
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
index bd482a6..f1f055e 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
@@ -12,115 +12,35 @@ from datetime import timedelta
import httplib
import json
import urllib
-import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.models import result_models
-from opnfv_testapi.models import testcase_models
+from opnfv_testapi.models import result_models as rm
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
from opnfv_testapi.tests.unit.handlers import test_base as base
-class Details(object):
- def __init__(self, timestart=None, duration=None, status=None):
- self.timestart = timestart
- self.duration = duration
- self.status = status
- self.items = [{'item1': 1}, {'item2': 2}]
-
- def format(self):
- return {
- "timestart": self.timestart,
- "duration": self.duration,
- "status": self.status,
- 'items': [{'item1': 1}, {'item2': 2}]
- }
-
- @staticmethod
- def from_dict(a_dict):
-
- if a_dict is None:
- return None
-
- t = Details()
- t.timestart = a_dict.get('timestart')
- t.duration = a_dict.get('duration')
- t.status = a_dict.get('status')
- t.items = a_dict.get('items')
- return t
-
-
class TestResultBase(base.TestBase):
+ @executor.mock_valid_lfid()
def setUp(self):
super(TestResultBase, self).setUp()
- self.pod = self.pod_d.name
- self.project = 'functest'
- self.case = 'vPing'
- self.installer = 'fuel'
- self.version = 'C'
- self.build_tag = 'v3.0'
- self.scenario = 'odl-l2'
- self.criteria = 'PASS'
- self.trust_indicator = result_models.TI(0.7)
- self.start_date = str(datetime.now())
- self.stop_date = str(datetime.now() + timedelta(minutes=1))
- self.update_date = str(datetime.now() + timedelta(days=1))
- self.update_step = -0.05
- self.details = Details(timestart='0', duration='9s', status='OK')
- self.req_d = result_models.ResultCreateRequest(
- pod_name=self.pod,
- project_name=self.project,
- case_name=self.case,
- installer=self.installer,
- version=self.version,
- start_date=self.start_date,
- stop_date=self.stop_date,
- details=self.details.format(),
- build_tag=self.build_tag,
- scenario=self.scenario,
- criteria=self.criteria,
- trust_indicator=self.trust_indicator)
- self.get_res = result_models.TestResult
- self.list_res = result_models.TestResults
- self.update_res = result_models.TestResult
+ self.req_d = rm.ResultCreateRequest.from_dict(
+ self.load_json('test_result'))
+ self.req_d.start_date = str(datetime.now())
+ self.req_d.stop_date = str(datetime.now() + timedelta(minutes=1))
+ self.get_res = rm.TestResult
+ self.list_res = rm.TestResults
+ self.update_res = rm.TestResult
self.basePath = '/api/v1/results'
- fake_pymongo.projects.insert(self.project_e.format())
- self.req_testcase = testcase_models.TestcaseCreateRequest(
- self.case,
- '/cases/vping',
- 'vping-ssh test')
- fake_pymongo.pods.insert(self.pod_d.format())
- self.create_help('/api/v1/projects/%s/cases',
- self.req_testcase,
- self.project)
+ fake_pymongo.pods.insert({'name': self.req_d.pod_name})
+ fake_pymongo.projects.insert({'name': self.req_d.project_name})
+ fake_pymongo.testcases.insert({'name': self.req_d.case_name,
+ 'project_name': self.req_d.project_name})
def assert_res(self, result, req=None):
if req is None:
req = self.req_d
- self.assertEqual(result.pod_name, req.pod_name)
- self.assertEqual(result.project_name, req.project_name)
- self.assertEqual(result.case_name, req.case_name)
- self.assertEqual(result.installer, req.installer)
- self.assertEqual(result.version, req.version)
- details_req = Details.from_dict(req.details)
- details_res = Details.from_dict(result.details)
- self.assertEqual(details_res.duration, details_req.duration)
- self.assertEqual(details_res.timestart, details_req.timestart)
- self.assertEqual(details_res.status, details_req.status)
- self.assertEqual(details_res.items, details_req.items)
- self.assertEqual(result.build_tag, req.build_tag)
- self.assertEqual(result.scenario, req.scenario)
- self.assertEqual(result.criteria, req.criteria)
- self.assertEqual(result.start_date, req.start_date)
- self.assertEqual(result.stop_date, req.stop_date)
- self.assertIsNotNone(result._id)
- ti = result.trust_indicator
- self.assertEqual(ti.current, req.trust_indicator.current)
- if ti.histories:
- history = ti.histories[0]
- self.assertEqual(history.date, self.update_date)
- self.assertEqual(history.step, self.update_step)
+ self.assertEqual(result, req)
def _create_d(self):
_, res = self.create_d()
@@ -203,17 +123,8 @@ class TestResultCreate(TestResultBase):
@executor.create(httplib.OK, '_assert_no_ti')
def test_no_ti(self):
- req = result_models.ResultCreateRequest(pod_name=self.pod,
- project_name=self.project,
- case_name=self.case,
- installer=self.installer,
- version=self.version,
- start_date=self.start_date,
- stop_date=self.stop_date,
- details=self.details.format(),
- build_tag=self.build_tag,
- scenario=self.scenario,
- criteria=self.criteria)
+ req = copy.deepcopy(self.req_d)
+ req.trust_indicator = rm.TI(0)
self.actual_req = req
return req
@@ -369,8 +280,13 @@ class TestResultGet(TestResultBase):
def _set_query(self, *args, **kwargs):
def get_value(arg):
- return self.__getattribute__(arg) \
- if arg != 'trust_indicator' else self.trust_indicator.current
+ if arg in ['pod', 'project', 'case']:
+ return getattr(self.req_d, arg + '_name')
+ elif arg == 'trust_indicator':
+ return self.req_d.trust_indicator.current
+ else:
+ return getattr(self.req_d, arg)
+
query = []
for arg in args:
query.append((arg, get_value(arg)))
@@ -386,24 +302,15 @@ class TestResultUpdate(TestResultBase):
@executor.update(httplib.OK, '_assert_update_ti')
def test_success(self):
- new_ti = copy.deepcopy(self.trust_indicator)
- new_ti.current += self.update_step
- new_ti.histories.append(
- result_models.TIHistory(self.update_date, self.update_step))
- new_data = copy.deepcopy(self.req_d)
- new_data.trust_indicator = new_ti
- update = result_models.ResultUpdateRequest(trust_indicator=new_ti)
- self.update_req = new_data
+ update_date = str(datetime.now() + timedelta(days=1))
+ update_step = -0.05
+ self.after_update = copy.deepcopy(self.req_d)
+ self.after_update.trust_indicator.current += update_step
+ self.after_update.trust_indicator.histories.append(
+ rm.TIHistory(update_date, update_step))
+ update = rm.ResultUpdateRequest(
+ trust_indicator=self.after_update.trust_indicator)
return update, self.req_d_id
def _assert_update_ti(self, request, body):
- ti = body.trust_indicator
- self.assertEqual(ti.current, request.trust_indicator.current)
- if ti.histories:
- history = ti.histories[0]
- self.assertEqual(history.date, self.update_date)
- self.assertEqual(history.step, self.update_step)
-
-
-if __name__ == '__main__':
- unittest.main()
+ self.assert_res(body, self.after_update)
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
index de7777a..481078d 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
@@ -1,12 +1,10 @@
+from datetime import datetime
import functools
import httplib
-import json
-import os
-
-from datetime import datetime
from opnfv_testapi.common import message
-import opnfv_testapi.models.scenario_models as models
+import opnfv_testapi.models.scenario_models as sm
+from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit.handlers import test_base as base
@@ -17,26 +15,13 @@ def _none_default(check, default):
class TestScenarioBase(base.TestBase):
def setUp(self):
super(TestScenarioBase, self).setUp()
- self.get_res = models.Scenario
- self.list_res = models.Scenarios
+ self.get_res = sm.Scenario
+ self.list_res = sm.Scenarios
self.basePath = '/api/v1/scenarios'
- self.req_d = self._load_request('scenario-c1.json')
- self.req_2 = self._load_request('scenario-c2.json')
-
- def tearDown(self):
- pass
-
- def assert_body(self, project, req=None):
- pass
-
- @staticmethod
- def _load_request(f_req):
- abs_file = os.path.join(os.path.dirname(__file__), f_req)
- with open(abs_file, 'r') as f:
- loader = json.load(f)
- f.close()
- return loader
+ self.req_d = self.load_json('scenario-c1')
+ self.req_2 = self.load_json('scenario-c2')
+ @executor.mock_valid_lfid()
def create_return_name(self, req):
_, res = self.create(req)
return res.href.split('/')[-1]
@@ -47,7 +32,7 @@ class TestScenarioBase(base.TestBase):
req = self.req_d
self.assertIsNotNone(scenario._id)
self.assertIsNotNone(scenario.creation_date)
- self.assertEqual(scenario, models.Scenario.from_dict(req))
+ self.assertEqual(scenario, sm.Scenario.from_dict(req))
@staticmethod
def set_query(*args):
@@ -62,27 +47,32 @@ class TestScenarioBase(base.TestBase):
class TestScenarioCreate(TestScenarioBase):
+ @executor.mock_valid_lfid()
def test_withoutBody(self):
(code, body) = self.create()
self.assertEqual(code, httplib.BAD_REQUEST)
+ @executor.mock_valid_lfid()
def test_emptyName(self):
- req_empty = models.ScenarioCreateRequest('')
+ req_empty = sm.ScenarioCreateRequest('')
(code, body) = self.create(req_empty)
self.assertEqual(code, httplib.BAD_REQUEST)
self.assertIn(message.missing('name'), body)
+ @executor.mock_valid_lfid()
def test_noneName(self):
- req_none = models.ScenarioCreateRequest(None)
+ req_none = sm.ScenarioCreateRequest(None)
(code, body) = self.create(req_none)
self.assertEqual(code, httplib.BAD_REQUEST)
self.assertIn(message.missing('name'), body)
+ @executor.mock_valid_lfid()
def test_success(self):
(code, body) = self.create_d()
self.assertEqual(code, httplib.OK)
self.assert_create_body(body)
+ @executor.mock_valid_lfid()
def test_alreadyExist(self):
self.create_d()
(code, body) = self.create_d()
@@ -145,6 +135,7 @@ class TestScenarioDelete(TestScenarioBase):
code, body = self.delete('notFound')
self.assertEqual(code, httplib.NOT_FOUND)
+ @executor.mock_valid_lfid()
def test_success(self):
scenario = self.create_return_name(self.req_d)
code, _ = self.delete(scenario)
@@ -199,9 +190,10 @@ class TestScenarioUpdate(TestScenarioBase):
return wrapper
return _update_partial
+ @executor.mock_valid_lfid()
@update_partial('_add', '_success')
def test_addScore(self):
- add = models.ScenarioScore(date=str(datetime.now()), score='11/12')
+ add = sm.ScenarioScore(date=str(datetime.now()), score='11/12')
projects = self.req_d['installers'][0]['versions'][0]['projects']
functest = filter(lambda f: f['project'] == 'functest', projects)[0]
functest['scores'].append(add.format())
@@ -210,9 +202,10 @@ class TestScenarioUpdate(TestScenarioBase):
return add
+ @executor.mock_valid_lfid()
@update_partial('_add', '_success')
def test_addTrustIndicator(self):
- add = models.ScenarioTI(date=str(datetime.now()), status='gold')
+ add = sm.ScenarioTI(date=str(datetime.now()), status='gold')
projects = self.req_d['installers'][0]['versions'][0]['projects']
functest = filter(lambda f: f['project'] == 'functest', projects)[0]
functest['trust_indicators'].append(add.format())
@@ -221,6 +214,7 @@ class TestScenarioUpdate(TestScenarioBase):
return add
+ @executor.mock_valid_lfid()
@update_partial('_add', '_success')
def test_addCustoms(self):
adds = ['odl', 'parser', 'vping_ssh']
@@ -231,6 +225,7 @@ class TestScenarioUpdate(TestScenarioBase):
self.locate_project)
return adds
+ @executor.mock_valid_lfid()
@update_partial('_update', '_success')
def test_updateCustoms(self):
updates = ['odl', 'parser', 'vping_ssh']
@@ -242,6 +237,7 @@ class TestScenarioUpdate(TestScenarioBase):
return updates
+ @executor.mock_valid_lfid()
@update_partial('_delete', '_success')
def test_deleteCustoms(self):
deletes = ['vping_ssh']
@@ -253,46 +249,53 @@ class TestScenarioUpdate(TestScenarioBase):
return deletes
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_add', '_success')
def test_addProjects_succ(self):
- add = models.ScenarioProject(project='qtip').format()
+ add = sm.ScenarioProject(project='qtip').format()
self.req_d['installers'][0]['versions'][0]['projects'].append(add)
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_add', '_conflict')
def test_addProjects_already_exist(self):
- add = models.ScenarioProject(project='functest').format()
+ add = sm.ScenarioProject(project='functest').format()
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_add', '_bad_request')
def test_addProjects_bad_schema(self):
- add = models.ScenarioProject(project='functest').format()
+ add = sm.ScenarioProject(project='functest').format()
add['score'] = None
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_update', '_success')
def test_updateProjects_succ(self):
- update = models.ScenarioProject(project='qtip').format()
+ update = sm.ScenarioProject(project='qtip').format()
self.req_d['installers'][0]['versions'][0]['projects'] = [update]
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_update', '_conflict')
def test_updateProjects_duplicated(self):
- update = models.ScenarioProject(project='qtip').format()
+ update = sm.ScenarioProject(project='qtip').format()
return [update, update]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_update', '_bad_request')
def test_updateProjects_bad_schema(self):
- update = models.ScenarioProject(project='functest').format()
+ update = sm.ScenarioProject(project='functest').format()
update['score'] = None
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('projects')
@update_partial('_delete', '_success')
def test_deleteProjects(self):
@@ -303,54 +306,62 @@ class TestScenarioUpdate(TestScenarioBase):
projects)
return deletes
+ @executor.mock_valid_lfid()
@update_url_fixture('owner')
@update_partial('_update', '_success')
def test_changeOwner(self):
new_owner = 'new_owner'
- update = models.ScenarioChangeOwnerRequest(new_owner).format()
+ update = sm.ScenarioChangeOwnerRequest(new_owner).format()
self.req_d['installers'][0]['versions'][0]['owner'] = new_owner
return update
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_add', '_success')
def test_addVersions_succ(self):
- add = models.ScenarioVersion(version='Euphrates').format()
+ add = sm.ScenarioVersion(version='Euphrates').format()
self.req_d['installers'][0]['versions'].append(add)
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_add', '_conflict')
def test_addVersions_already_exist(self):
- add = models.ScenarioVersion(version='master').format()
+ add = sm.ScenarioVersion(version='master').format()
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_add', '_bad_request')
def test_addVersions_bad_schema(self):
- add = models.ScenarioVersion(version='euphrates').format()
+ add = sm.ScenarioVersion(version='euphrates').format()
add['notexist'] = None
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_update', '_success')
def test_updateVersions_succ(self):
- update = models.ScenarioVersion(version='euphrates').format()
+ update = sm.ScenarioVersion(version='euphrates').format()
self.req_d['installers'][0]['versions'] = [update]
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_update', '_conflict')
def test_updateVersions_duplicated(self):
- update = models.ScenarioVersion(version='euphrates').format()
+ update = sm.ScenarioVersion(version='euphrates').format()
return [update, update]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_update', '_bad_request')
def test_updateVersions_bad_schema(self):
- update = models.ScenarioVersion(version='euphrates').format()
+ update = sm.ScenarioVersion(version='euphrates').format()
update['not_owner'] = 'Iam'
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('versions')
@update_partial('_delete', '_success')
def test_deleteVersions(self):
@@ -361,46 +372,53 @@ class TestScenarioUpdate(TestScenarioBase):
versions)
return deletes
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_add', '_success')
def test_addInstallers_succ(self):
- add = models.ScenarioInstaller(installer='daisy').format()
+ add = sm.ScenarioInstaller(installer='daisy').format()
self.req_d['installers'].append(add)
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_add', '_conflict')
def test_addInstallers_already_exist(self):
- add = models.ScenarioInstaller(installer='apex').format()
+ add = sm.ScenarioInstaller(installer='apex').format()
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_add', '_bad_request')
def test_addInstallers_bad_schema(self):
- add = models.ScenarioInstaller(installer='daisy').format()
+ add = sm.ScenarioInstaller(installer='daisy').format()
add['not_exist'] = 'not_exist'
return [add]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_update', '_success')
def test_updateInstallers_succ(self):
- update = models.ScenarioInstaller(installer='daisy').format()
+ update = sm.ScenarioInstaller(installer='daisy').format()
self.req_d['installers'] = [update]
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_update', '_conflict')
def test_updateInstallers_duplicated(self):
- update = models.ScenarioInstaller(installer='daisy').format()
+ update = sm.ScenarioInstaller(installer='daisy').format()
return [update, update]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_update', '_bad_request')
def test_updateInstallers_bad_schema(self):
- update = models.ScenarioInstaller(installer='daisy').format()
+ update = sm.ScenarioInstaller(installer='daisy').format()
update['not_exist'] = 'not_exist'
return [update]
+ @executor.mock_valid_lfid()
@update_url_fixture('installers')
@update_partial('_delete', '_success')
def test_deleteInstallers(self):
@@ -411,19 +429,21 @@ class TestScenarioUpdate(TestScenarioBase):
installers)
return deletes
+ @executor.mock_valid_lfid()
@update_url_fixture('rename')
@update_partial('_update', '_success')
def test_renameScenario(self):
new_name = 'new_scenario_name'
- update = models.ScenarioUpdateRequest(name=new_name)
+ update = sm.ScenarioUpdateRequest(name=new_name)
self.req_d['name'] = new_name
return update
+ @executor.mock_valid_lfid()
@update_url_fixture('rename')
@update_partial('_update', '_forbidden')
def test_renameScenario_exist(self):
new_name = self.req_d['name']
- update = models.ScenarioUpdateRequest(name=new_name)
+ update = sm.ScenarioUpdateRequest(name=new_name)
return update
def _add(self, update_req):
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py b/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
index d5e32e3..9a2bf58 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
@@ -6,12 +6,10 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import copy
import httplib
-import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.models import testcase_models
+from opnfv_testapi.models import testcase_models as tcm
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
from opnfv_testapi.tests.unit.handlers import test_base as base
@@ -21,57 +19,56 @@ class TestCaseBase(base.TestBase):
def setUp(self):
super(TestCaseBase, self).setUp()
self.project = 'functest'
- self.req_d = testcase_models.TestcaseCreateRequest('vping_1',
- '/cases/vping_1',
- 'vping-ssh test')
- self.req_e = testcase_models.TestcaseCreateRequest('doctor_1',
- '/cases/doctor_1',
- 'create doctor')
- self.update_d = testcase_models.TestcaseUpdateRequest('vping_1',
- 'vping-ssh test',
- 'functest')
- self.update_e = testcase_models.TestcaseUpdateRequest('doctor_1',
- 'create doctor',
- 'functest')
- self.get_res = testcase_models.Testcase
- self.list_res = testcase_models.Testcases
- self.update_res = testcase_models.Testcase
+ self.req_d = tcm.TestcaseCreateRequest.from_dict(
+ self.load_json('testcase_d'))
+ self.req_e = tcm.TestcaseCreateRequest.from_dict(
+ self.load_json('testcase_e'))
+ self.update_req = tcm.TestcaseUpdateRequest(project_name=self.project,
+ **self.req_e.format())
+
+ self.get_res = tcm.Testcase
+ self.list_res = tcm.Testcases
+ self.update_res = tcm.Testcase
self.basePath = '/api/v1/projects/%s/cases'
fake_pymongo.projects.insert(self.project_e.format())
+ print self.req_d.format()
def assert_body(self, case, req=None):
if not req:
req = self.req_d
- self.assertEqual(case.name, req.name)
- self.assertEqual(case.description, req.description)
- self.assertEqual(case.url, req.url)
+ self.assertEqual(req,
+ tcm.TestcaseCreateRequest.from_dict(case.format()))
+ self.assertEqual(case.project_name, self.project)
self.assertIsNotNone(case._id)
self.assertIsNotNone(case.creation_date)
- def assert_update_body(self, old, new, req=None):
+ def assert_update_body(self, new_record, req=None):
if not req:
req = self.req_d
- self.assertEqual(new.name, req.name)
- self.assertEqual(new.description, req.description)
- self.assertEqual(new.url, old.url)
- self.assertIsNotNone(new._id)
- self.assertIsNotNone(new.creation_date)
+ self.assertEqual(req, new_record)
+ self.assertIsNotNone(new_record._id)
+ self.assertIsNotNone(new_record.creation_date)
+ @executor.mock_valid_lfid()
def create_d(self):
return super(TestCaseBase, self).create_d(self.project)
+ @executor.mock_valid_lfid()
def create_e(self):
return super(TestCaseBase, self).create_e(self.project)
def get(self, case=None):
return super(TestCaseBase, self).get(self.project, case)
+ @executor.mock_valid_lfid()
def create(self, req=None, *args):
return super(TestCaseBase, self).create(req, self.project)
+ @executor.mock_valid_lfid()
def update(self, new=None, case=None):
return super(TestCaseBase, self).update(new, self.project, case)
+ @executor.mock_valid_lfid()
def delete(self, case):
return super(TestCaseBase, self).delete(self.project, case)
@@ -88,12 +85,12 @@ class TestCaseCreate(TestCaseBase):
@executor.create(httplib.BAD_REQUEST, message.missing('name'))
def test_emptyName(self):
- req_empty = testcase_models.TestcaseCreateRequest('')
+ req_empty = tcm.TestcaseCreateRequest('')
return req_empty
@executor.create(httplib.BAD_REQUEST, message.missing('name'))
def test_noneName(self):
- req_none = testcase_models.TestcaseCreateRequest(None)
+ req_none = tcm.TestcaseCreateRequest(None)
return req_none
@executor.create(httplib.OK, '_assert_success')
@@ -146,31 +143,33 @@ class TestCaseUpdate(TestCaseBase):
@executor.update(httplib.NOT_FOUND, message.not_found_base)
def test_notFound(self):
- return self.update_e, 'notFound'
+ update = tcm.TestcaseUpdateRequest(description='update description')
+ return update, 'notFound'
@executor.update(httplib.FORBIDDEN, message.exist_base)
def test_newNameExist(self):
self.create_e()
- return self.update_e, self.req_d.name
+ return self.update_req, self.req_d.name
@executor.update(httplib.FORBIDDEN, message.no_update())
def test_noUpdate(self):
- return self.update_d, self.req_d.name
+ update = tcm.TestcaseUpdateRequest(project_name=self.project,
+ **self.req_d.format())
+ return update, self.req_d.name
@executor.update(httplib.OK, '_update_success')
def test_success(self):
- return self.update_e, self.req_d.name
+ return self.update_req, self.req_d.name
@executor.update(httplib.OK, '_update_success')
def test_with_dollar(self):
- update = copy.deepcopy(self.update_d)
- update.description = {'2. change': 'dollar change'}
- return update, self.req_d.name
+ self.update_req.description = {'2. change': 'dollar change'}
+ return self.update_req, self.req_d.name
def _update_success(self, request, body):
- self.assert_update_body(self.req_d, body, request)
+ self.assert_update_body(body, request)
_, new_body = self.get(request.name)
- self.assert_update_body(self.req_d, new_body, request)
+ self.assert_update_body(new_body, request)
class TestCaseDelete(TestCaseBase):
@@ -190,7 +189,3 @@ class TestCaseDelete(TestCaseBase):
self.assertEqual(body, '')
code, body = self.get(self.req_d.name)
self.assertEqual(code, httplib.NOT_FOUND)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/testapi/opnfv_testapi/tests/unit/templates/deploy_result.json b/testapi/opnfv_testapi/tests/unit/templates/deploy_result.json
new file mode 100644
index 0000000..8d4941d
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/unit/templates/deploy_result.json
@@ -0,0 +1,14 @@
+{
+ "build_id": 100,
+ "scenario": "os-nosdn-nofeature-ha",
+ "stop_date": "",
+ "start_date": "",
+ "upstream_job_name": "daisy-job-master",
+ "version": "master",
+ "pod_name": "zte-pod1",
+ "criteria": "PASS",
+ "installer": "daisy",
+ "upstream_build_id": 100,
+ "job_name": "daisy-deploy-job-master",
+ "details": ""
+} \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json b/testapi/opnfv_testapi/tests/unit/templates/scenario-c1.json
index 1878022..1878022 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json
+++ b/testapi/opnfv_testapi/tests/unit/templates/scenario-c1.json
diff --git a/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json b/testapi/opnfv_testapi/tests/unit/templates/scenario-c2.json
index 980051c..980051c 100644
--- a/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json
+++ b/testapi/opnfv_testapi/tests/unit/templates/scenario-c2.json
diff --git a/testapi/opnfv_testapi/tests/unit/templates/test_result.json b/testapi/opnfv_testapi/tests/unit/templates/test_result.json
new file mode 100644
index 0000000..b7cb910
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/unit/templates/test_result.json
@@ -0,0 +1,27 @@
+{
+ "project_name": "functest",
+ "scenario": "odl-l2",
+ "trust_indicator": {
+ "current": 0.7,
+ "histories": []
+ },
+ "case_name": "vPing",
+ "build_tag": "v3.0",
+ "public": "true",
+ "version": "C",
+ "details": {
+ "timestart": "0",
+ "duration": "9s",
+ "status": "OK",
+ "items": [
+ {"item1": 1},
+ {"item2": 2}
+ ]
+ },
+ "criteria": "PASS",
+ "installer": "fuel",
+ "pod_name": "zte-pod1",
+ "start_date": "",
+ "stop_date": "",
+ "user": ""
+} \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/unit/templates/testcase_d.json b/testapi/opnfv_testapi/tests/unit/templates/testcase_d.json
new file mode 100644
index 0000000..7c36cb8
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/unit/templates/testcase_d.json
@@ -0,0 +1,16 @@
+{
+ "run": "vping.sh",
+ "name": "vping_ssh",
+ "ci_loop": "daily",
+ "tags": "",
+ "url": "/cases/vping_ssh",
+ "blocking": "true",
+ "domains": "os",
+ "dependencies": "",
+ "version": "euphrates",
+ "criteria": "PASS/FAIL",
+ "tier": "smoke",
+ "trust": "Silver",
+ "catalog_description": "",
+ "description": "vping-ssh test"
+} \ No newline at end of file
diff --git a/testapi/opnfv_testapi/tests/unit/templates/testcase_e.json b/testapi/opnfv_testapi/tests/unit/templates/testcase_e.json
new file mode 100644
index 0000000..c031309
--- /dev/null
+++ b/testapi/opnfv_testapi/tests/unit/templates/testcase_e.json
@@ -0,0 +1,16 @@
+{
+ "run": "parser.sh",
+ "name": "parser-basics",
+ "ci_loop": "daily",
+ "tags": "",
+ "url": "/cases/parser",
+ "blocking": "false",
+ "domains": "vnf",
+ "dependencies": "",
+ "version": "master",
+ "criteria": "PASS/FAIL",
+ "tier": "features",
+ "trust": "Silver",
+ "catalog_description": "",
+ "description": "parser test"
+} \ No newline at end of file