Commit 8c5b5136 authored by Michele Carignani's avatar Michele Carignani
Browse files

extend to geneate SOL003

parent e90bd61c
Loading
Loading
Loading
Loading
Loading
+19 −3
Original line number Original line Diff line number Diff line
# robot2doc
# robot2doc


A simple Docx generator for Robot Framework Test Suites
A simple Docx generator for Robot Framework Test Suites.


## Requirements
## Requirements


@@ -10,7 +10,10 @@ A simple Docx generator for Robot Framework Test Suites


## Usage
## Usage


    python main.py <robot-tests> [OUT_FILENAME [SECTION_TITLE]]

### Generate individual files

    python robot2doc/main.py <robot-tests> [OUT_FILENAME [SECTION_TITLE]]


Command line arguments:
Command line arguments:


@@ -18,6 +21,17 @@ Command line arguments:
* `OUT_FILENAME` filename for the output (e.g. `my-tests.docx`)
* `OUT_FILENAME` filename for the output (e.g. `my-tests.docx`)
* `SECTION_TITLE` the title for the section in the doc where the tests are included
* `SECTION_TITLE` the title for the section in the doc where the tests are included


### Gerenerate the complete test suite

    cd robot2doc
    python3 create_sols.py <api-tests-root> [<commit-or-tag>]

Command line arguments:
* `api-tests-root`: the root folder of the `api-tests` project
* `commit-or-tag`: the link or tag names to be used for the links to the repository. Deafault: `deadbeef`

## Configuration 

Other configurable paramenters may be found in `config.py`, such as:
Other configurable paramenters may be found in `config.py`, such as:


* ` DOC_CLAUSE_LVL_*`, the starting number for the sections numbering, with `LVL_1` being the number of the toplevel clause.
* ` DOC_CLAUSE_LVL_*`, the starting number for the sections numbering, with `LVL_1` being the number of the toplevel clause.
@@ -43,11 +57,13 @@ Example:
        Log    Test starts...
        Log    Test starts...
        Etc. etc.
        Etc. etc.


Note: each value (i.e. the text after `:`) should be starting with Capital letter. The tool will print a warning otherwise.

### Test ID
### Test ID


If one of the fields in the documentation is called `Test ID`, the string next to it is used as the reference number for the subclause of the document.
If one of the fields in the documentation is called `Test ID`, the string next to it is used as the reference number for the subclause of the document.


## Tests
## Test the software


Few tests for the internals are created in the `robot2doc` folder.
Few tests for the internals are created in the `robot2doc` folder.
To execute the tests you need to install the `pytest` module, then in the folder of the test
To execute the tests you need to install the `pytest` module, then in the folder of the test
+30 −15
Original line number Original line Diff line number Diff line
#!/env/python3
#!/env/python3
#
#
#  Usage: python main.py <FILE_OR_FOLDER> [OUTPUT_FILENAME [MAIN_TITLE]]
#  Usage: python3 create_sols.py ../../api-tests/   <commit-or-tag>
#
#


import os
import os
@@ -21,21 +21,31 @@ def is_interface_heading(ref):
def is_endpoint_heading(ref):
def is_endpoint_heading(ref):
    return ref.lvl() == 4
    return ref.lvl() == 4


def create_sol_002(sol_002_root, commit_id, output_dir):
def create_test_for_sol(solspec, all_tests_root, commit_id, output_dir):


    sol002_index = None
    indexes = {
        "SOL002" : 'sol_002_index.csv',
        "SOL003" : 'sol_003_index.csv',
        "SOL005" : 'sol_005_index.csv',
    }


    myf = open('sol_002_tree_ok.csv', 'r')
    if not solspec in indexes:
    sol002_index = csv.reader(myf)
        print("Error: Wrong SOL Specification: {}".format(solspec))
        return

    sol_index = None

    myf = open(indexes[solspec], 'r')
    sol_index = csv.reader(myf)


    if sol002_index is None:
    if sol_index is None:
        print("ERROR OPENING SOL002 INDEX")
        print("ERROR OPENING INDEX: {}".format(indexes[solspec]))
        return
        return


    spec = testspec.TestSpec()
    spec = testspec.TestSpec()
    current_folder = None
    current_folder = None


    for row in sol002_index:
    for row in sol_index:
        if len(row) < 3:
        if len(row) < 3:
            continue
            continue


@@ -46,18 +56,19 @@ def create_sol_002(sol_002_root, commit_id, output_dir):
            current_folder = row[2].strip()
            current_folder = row[2].strip()


        elif is_endpoint_heading(ref):
        elif is_endpoint_heading(ref):
            suite = TestSuiteBuilder().build(os.path.join(sol_002_root, current_folder, row[2].strip()))
            suite = TestSuiteBuilder().build(
            lib.gen_api_suite(ref, suite, spec, current_folder, commit_id, "SOL002")
                os.path.join(all_tests_root, solspec, current_folder, row[2].strip())
            )
            lib.gen_api_suite(ref, suite, spec, current_folder, commit_id, solspec)


    outfn = os.path.join(output_dir,"SOL002_attachment.docx")
    outfn = os.path.join(output_dir,"{}_attachment.docx".format(solspec))
    print("Writing SOL 002 definitions to: ", outfn)
    print("Writing {} definitions to: {}".format(solspec, outfn))
    spec.save(outfn)
    spec.save(outfn)



if __name__ == "__main__":
if __name__ == "__main__":


    if len(sys.argv) < 2:
    if len(sys.argv) < 2:
        print("Usage: robot2doc <sol_robot_root_dir> commit-id")
        print("Usage: robot2doc <sol_robot_root_dir> <commit-id>")
        sys.exit(-1)
        sys.exit(-1)


    ROOT = sys.argv[1]
    ROOT = sys.argv[1]
@@ -67,4 +78,8 @@ if __name__ == "__main__":


    print("Generating entire SOL tests")
    print("Generating entire SOL tests")


    create_sol_002(os.path.join(ROOT, "SOL002"), COMMIT_ID, "..")
    sol_specs = [ "SOL002", "SOL003"] # TODO "SOL005"]
 No newline at end of file

    for solspec in sol_specs:
        create_test_for_sol(solspec, ROOT, COMMIT_ID, "..")
+0 −2
Original line number Original line Diff line number Diff line
@@ -54,8 +54,6 @@ class DocReference():
    def from_str(string):
    def from_str(string):
        return DocReference(string.split("."))
        return DocReference(string.split("."))




def keyword_to_line(k):
def keyword_to_line(k):
    '''
    '''
    Takes a Robot Framework keyword object and returns
    Takes a Robot Framework keyword object and returns
+73 −0
Original line number Original line Diff line number Diff line
7,Or-Vnfm Reference Point, SOL003
7.3.1,VNF Lifecycle Management Interface, VNFLifecycleManagement-API
7.3.1.1,VnfInstances, VNFInstances.robot
7.3.1.2,Individual VNFInstance, IndividualVNFInstance.robot
7.3.1.3,Instantiate a VNF, InstantiateVNFTask.robot
7.3.1.4,Scale a vnfInstance, ScaleVNFTask.robot
7.3.1.5,Scale a vnfInstance to level, ScaleVNFToLevelTask.robot
7.3.1.6,Change deployment flavour of a vnfInstance,ChangeVNFFlavourTask.robot
7.3.1.7,Terminate a vnfInstance,TerminateVNFTask.robot
7.3.1.8,Heal a vnfInstance, HealVNFTask.robot
7.3.1.9,Operate a vnfInstance, OperateVNFTask.robot
7.3.1.10,Change external VNF connectivity, ChangeExternalVNFConnectivityTask.robot
7.3.1.11,VNF LCM Operation occurrences, VnfLcmOperationOccurences.robot
7.3.1.12,Individual VNF LCM Operation occurrence, IndividualVnfLcmOperationOccurence.robot
7.3.1.13,Retry operation task, RetryOperationTask.robot
7.3.1.14,Rollback operation task, RollbackOperationTask.robot
7.3.1.15,Fail operation task, FailOperationTask.robot
7.3.1.16,Cancel operation task, CancelOperationTask.robot
7.3.1.17,Subscriptions, Subscriptions.robot
7.3.1.18,Individual Subscription, IndividualSubscription.robot
7.3.1.19,Cancel VNF LCM Operation, CancelOperationWorkflow.robot
7.3.1.20,Change external connectivity of VNF Workflow, CancelOperationWorkflow.robot
7.3.1.21,Change VNF Flavour Workflow, ChangeVNFFlavourWorkflow.robot
7.3.1.22,Create VNF Instance Resource,CreateVNFWorkflow.robot
7.3.1.23,Delete VNF Instance Resource, DeleteVNFWorkflow.robot
7.3.1.24,Fail a VNF LCM Operation Workflow,FailOperationWorkflow.robot
7.3.1.25,Heal a VNF Instance,HealVNFWorkflow.robot
7.3.1.26,VNF Instantiation,InstantiateVNFTaskWorkflow.robot
7.3.1.27,Modify info of a VNF Instance, ModifyVNFInformationWorkflow.robot 
7.3.1.28,Operate a VNF Instance,OperateVNFWorkflow.robot
7.3.1.29,Retry VNF LCM Operation, RetryOperationWorkflow.robot
7.3.1.30,Rollback VNF LCM Operation, RollBackOperationWorkflow.robot
7.3.1.31,VNF Instance Scale To Level, ScaleVNFToLevelWorkflow.robot
7.3.1.32,VNF Instance Scale Out, ScaleVNFWorkflow.robot
7.3.1.33,Terminate a VNF Instance, TerminateVNFWorkflow.robot
7.3.1.34,Notification Endpoint, NotificationEndpoint.robot
7.3.2,VNF Lifecycle Operation Granting Interface, VNFLifecycleOperationGranting-API
7.3.2.1,Grants, Grants.robot
7.3.2.2,Individual Grant, IndividualGrant.robot
7.3.3,VNF Package Management Interface, VNFPackageManagement-API
7.3.3.1,VNF Packages Resource Endpoint, VNFPackages.robot
7.3.3.2,Individual VNF Package Resource Endpoint, IndividualVNFPackage.robot
7.3.3.3,VNF Package Content Resource Endpoint, VNFPackageContent.robot
7.3.3.4,VNFD In Individual VNF Package Resource Endpoint, VNFDInIndividualVNFPackage.robot
7.3.3.5,Individual VNF Package Artifact Resource Endpoint, VNFPackageArtifacts.robot
7.3.3.6,Subscriptions Resource Endpoint, Subscriptions.robot
7.3.3.7,Individual Subscription Resource Endpoint, IndividualSubscription.robot
7.3.3.8,Notification Endpoint, PackageManagementNotification.robot
7.3.4,VNF Performance Management Interface, VNFPerformanceManagement-API
7.3.4.1,PM Jobs Resource Endpoint, PMJobs.robot
7.3.4.2,Individual Pm Job Resource Endpoint, IndividualPmJob.robot
7.3.4.3,Individual Performance Report Resource Endpoint, IndividualReport.robot
7.3.4.4,Thresholds Resource Endpoint, Thresholds.robot
7.3.4.5,Individual Threshold Resource Endpoint, IndividualThreshold.robot
7.3.4.6,Subscriptions, Subscriptions.robot
7.3.4.7,Individual Subscription Resource Endpoint, IndividualSubscription.robot
7.3.4.8,Notification Endpoint,  PerformanceManagementNotification.robot 
7.3.5,VNF Fault Management interface, VNFFaultManagement-API
7.3.5.1,Alarms, Alarms.robot
7.3.5.2,Individual Alarm, IndividualAlarm.robot 
7.3.5.3,Subscriptions, Subscriptions.robot
7.3.5.4,Individual Subscription, IndividualSubscription.robot
7.3.5.5,Notification Endpoint, ../VNFFaultManagementNotification-API/NotificationEndpoint.robot
7.3.6,VNF Indicator Interface, VNFIndicator-API
7.3.6.1,VNF Indicators Resource Endpoint, VNFIndicators.robot
7.3.6.2,VNF Indicators Related to a VNF Instance Resource Endpoint, VnfIndicatorsInVnfInstanceId.robot
7.3.6.3,Individual VNF Indicator Resource Endpoint, IndividualVNFindicator.robot
7.3.6.4,Subscriptions Resource Endpoint, Subscriptions.robot
7.3.6.5,Individual Subscription Resource Endpoint, IndividualSubscription.robot
7.3.6.6,Notification Endpoint, VnfIndicatorNotification.robot
7.3.7,Virtualised Resources Quota Available Notification interface, VirtualisedResourcesQuotaAvailableNotification-API
7.3.7.1,Subscriptions, Subscriptions.robot
7.3.7.2,Individual Subscription, IndividualSubscription.robot