teko-cli


Nameteko-cli JSON
Version 0.12.4 PyPI version JSON
download
home_pagehttps://git.teko.vn/vnpay-marketing-portal/teko-tools
SummaryTeko CLI tools
upload_time2023-05-11 08:00:32
maintainer
docs_urlNone
authorThuc Nguyen
requires_python
licenseMIT
keywords teko teko cli tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Teko CLI Tools

```
pip install teko-cli
```
This is a Python package that contains some classes and CLI tools to be used during development 
process at Teko Vietnam (https://teko.vn).

List of tools:

- Teko Jira Tools: for pushing test case/ test cycle
- Teko Jira Export Test: for pytest export jira test case/test cycle
- Teko Oas Tools: for validate auto doc match with defined doc


## 1 Installation

To use this tools, Python 3.6+ should be instaled. 

Install or upgrade to the latest version:

```shell
$ pip install -r requirements.txt
$ pip install --editable .
```

After successful installation, you should be able to use `teko` command in your 
console terminal:

```
$ teko
```

You should see this kind of help message:

```
Usage: teko [OPTIONS] COMMAND [ARGS]...

Options:
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.

  --help                          Show this message and exit.

Commands:
  cs
  jira
  oas
```

## Using Teko Jira tool

### 2.1 Configure Jira credential

This tool use username/password authentication to Jira server, Confluence documentation and working with one Jira project 
at the same time. Jira server authentication uses 4 environment variables below. 
You can set these variables to the your environment, or save it to `.env` file in working
directory:

Sample content of `.env` file:

```
JIRA_SERVER=jira.teko.vn
JIRA_PROJECT_KEY=<project-key>
JIRA_USERNAME=<jira-username>
JIRA_PASSWORD=<jira-password>
CONFLUENCE_USERNAME=<confluence-username>
CONFLUENCE_PASSWORD=<confluence-password>
```

### 2.2 Submit (create) list of testcases to a Jira Project

To push testcases to a Jira Project, you should prepare a `.yaml` 
or a `.json` file, containing list of testcases to be created in Jira, 
then use following command:

```
$ teko jira create-tests {testcase_file}
```

To see help message, use `--help` option: `teko jira create-tests --help`:

```
Usage: teko jira create-tests [OPTIONS] FILE



Arguments:
  FILE  The name of a testcase definition file  [required]

Options:
  --help  Show this message and exit.
```

**Note:** This tool uses test case `name` as identification, so existing tests with same `name` 
will be updated with the latest information. 

#### Sample testcases file

- `.yaml` file

```yaml
- name: Testcase 01
  issueLinks: [TESTING-4]
  objective: Test 01 Objective
  precondition: Test 01 Precondition
  testScript:
    type: PLAIN_TEXT
    text: >
      - init x and y <br/>
      - call func add(x, y)
  labels: [ABC, XYZ]
- name: Testcase 02
  issueLinks: [TESTING-4, TESTING-5]
  objective: Test 02 Objective
  precondition: Test 02 Precondition
  priority: Normal
  status: Draft
  testScript:
    type: STEP_BY_STEP
    steps:
    - description: <i>Step 1</i>
      testData: (x,y) = (1,3)
      expectedResult: <strong>4</strong>
    - description: Step 2
      testData: <code>(x,y) = (4,5)</code>
      expectedResult: 9
```

- Equivalent `.json` file:

```json
[
  {
    "name": "Testcase 01",
    "issueLinks": [
      "TESTING-4"
    ],
    "objective": "Test 01 Objective",
    "precondition": "Test 01 Precondition",
    "testScript": {
      "type": "PLAIN_TEXT",
      "text": "- init x and y <br/> - call func add(x, y)\n"
    },
    "labels": ["ABC", "XYZ"]
  },
  {
    "name": "Testcase 02",
    "issueLinks": [
      "TESTING-4",
      "TESTING-5"
    ],
    "objective": "Test 02 Objective",
    "precondition": "Test 02 Precondition",
    "priority": "Normal",
    "status": "Draft",
    "testScript": {
      "type": "STEP_BY_STEP",
      "steps": [
        {
          "description": "<i>Step 1</i>",
          "testData": "(x,y) = (1,3)",
          "expectedResult": "<strong>4</strong>"
        },
        {
          "description": "Step 2",
          "testData": "<code>(x,y) = (4,5)</code>",
          "expectedResult": "9"
        }
      ]
    }
  }
]
```

### 2.3 Create test cycle (testrun result) in a Jira Project

To create a testrun report (cycle) to a Jira Project, you should prepare a `.yaml` 
or a `.json` file, containing list of testcases and **their result** to be created 
in Jira, then use following command:

```
$ teko jira create-cycle {testcase_file}
```

#### Sample testrun (cycle) file

- `.yaml` file

```yaml
- name: Testcase 01
  testrun_folder: /Sprint 1
  testrun_status: Pass
  testrun_environment: Dev
  testrun_comment: The test has passed successfully
  testrun_duration: 300000
  testrun_date: "2020-12-31T23:59:59Z"  
- name: Testcase 02
  testrun_folder: /Sprint 2
  testrun_status: Fail
  testrun_environment: test1
  testrun_comment: The test has failed on some automation tool procedure
  testrun_duration: 30000
  testrun_date: "2020-12-31T23:59:59Z" 
```

- Equivalent `.json` file

```json
[
  {
    "name": "Testcase 01",
    "testrun_folder": "/Sprint 1",
    "testrun_status": "Pass",
    "testrun_environment": "Dev",
    "testrun_comment": "The test has passed successfully",
    "testrun_duration": 300000,
    "testrun_date": "2020-12-31T23:59:59Z"
  },
  {
    "name": "Testcase 02",
    "testrun_folder": "/Sprint 2",
    "testrun_status": "Fail",
    "testrun_environment": "test1",
    "testrun_comment": "The test has failed on some automation tool procedure",
    "testrun_duration": 30000,
    "testrun_date": "2020-12-31T23:59:59Z"
  }
]
```
**Note:**
-  Test run results are grouped into multiple cycles based on their common `testrun_folder`.
- `testrun_duration` is measured in milliseconds.
- `testrun_environment` is chosen from available environments that defined by users in the project. Do this by accessing **Configuration** in Tests Board on Jira.  

### Sample combined testcase file with test results
Both test case and test run use the **same structure**. 
So you can you a single combined the information and the result of a test into one wrapper for both operation: create tests and create cycles. 
This file can be **generated automatically** from *docstrings* and/or 
*annotation*/*decorator* in auto test code.

### 2.4 Sample combined testcase file with test results

- `.yaml` file

```yaml
- name: Testcase 01
  issueLinks: [TESTING-4]
  objective: Test 01 Objective
  precondition: Test 01 Precondition
  testScript:
    type: PLAIN_TEXT
    text: >
      - init x and y <br/>
      - call func add(x, y)
  labels: ABC, XYZ
  testrun_status: Pass
  testrun_environment: Dev
  testrun_comment: The test has passed successfully
  testrun_duration: 300000
  testrun_date: "2020-12-31T23:59:59Z" 
- name: Testcase 02
  issueLinks: [TESTING-4, TESTING-5]
  objective: Test 02 Objective
  precondition: Test 02 Precondition
  priority: Normal
  status: Draft
  testScript:
    type: STEP_BY_STEP
    steps:
    - description: <i>Step 1</i>
      testData: (x,y) = (1,3)
      expectedResult: <strong>4</strong>
    - description: Step 2
      testData: <code>(x,y) = (4,5)</code>
      expectedResult: 9
  testrun_status: Fail
  testrun_environment: test1
  testrun_comment: The test has failed on some automation tool procedure
  testrun_duration: 30000
  testrun_date: "2020-12-31T23:59:59Z"
```   

- Equivalent `.json` file

```json
[
  {
    "name": "Testcase 01",
    "issueLinks": [
      "TESTING-4"
    ],
    "objective": "Test 01 Objective",
    "precondition": "Test 01 Precondition",
    "testScript": {
      "type": "PLAIN_TEXT",
      "text": "- init x and y <br/> - call func add(x, y)\n"
    },
    "labels": ["ABC", "XYZ"],
    "testrun_status": "Pass",
    "testrun_environment": "Dev",
    "testrun_comment": "The test has passed successfully",
    "testrun_duration": 300000,
    "testrun_date": "2020-12-31T23:59:59Z"
  },
  {
    "name": "Testcase 02",
    "issueLinks": [
      "TESTING-4",
      "TESTING-5"
    ],
    "objective": "Test 02 Objective",
    "precondition": "Test 02 Precondition",
    "priority": "Normal",
    "status": "Draft",
    "testScript": {
      "type": "STEP_BY_STEP",
      "steps": [
        {
          "description": "<i>Step 1</i>",
          "testData": "(x,y) = (1,3)",
          "expectedResult": "<strong>4</strong>"
        },
        {
          "description": "Step 2",
          "testData": "<code>(x,y) = (4,5)</code>",
          "expectedResult": "9"
        }
      ]
    },
    "testrun_status": "Fail",
    "testrun_environment": "Test1",
    "testrun_comment": "The test has failed on some automation tool procedure",
    "testrun_duration": 30000,
    "testrun_date": "2020-12-31T23:59:59Z"
  }
]
```
## 3 Using export test
### 3.1 Configure
- Add to test setting `pytest_plugins = ["teko.utils.jira_export_test"]` . Example, add to `conftest.py`
- To use decorator: `from teko.utils.jira_export_test.wraper import jira_test`
- To use test script type STEP_BY_STEP: `from teko.models.jira_export_test.test_step import TestStep`
#### Env
- `$JIRA_TEST_CASE_ARTIFACT`: test_case file path, default is test_case.json
- `$JIRA_TEST_CYCLE_ARTIFACT`: test_cycle file path, default is test_cycle.json
- Optional: `$ENV` or `$ENVIRONMENT` for test cycle env. Default, detect env from `$CI_COMMIT_BRANCH`
### 3.2 Write test function
- example in `/sample/jira_export_test/`

Maybe you need push test to Jira with teko-tool, this is example gitlab-ci.yml
```
test:unittest:
  stage: test
  ...
  variables:
    JIRA_TEST_CASE_ARTIFACT: test_case.json
    JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json
  artifacts:
    paths:
      - $JIRA_TEST_CASE_ARTIFACT
      - $JIRA_TEST_CYCLE_ARTIFACT
    expire_in: 1 week
  allow_failure: false


report:push-test:
  stage: report
  image: python:3.7-slim
  variables:
    JIRA_TEST_CASE_ARTIFACT: test_case.json
    JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json
    JIRA_PROJECT_KEY: TESTING
    JIRA_SERVER: jira.teko.vn
    JIRA_USERNAME: changeme
    JIRA_PASSWORD: changeme
    CONFLUENCE_USERNAME: changeme
    CONFLUENCE_PASSWORD: changeme
  script:
    - pip install --upgrade --cache-dir=.pip teko-cli
    - teko jira create-tests $JIRA_TEST_CASE_ARTIFACT
    - teko jira create-cycle $JIRA_TEST_CYCLE_ARTIFACT
  cache:
    key: pip-cache
    paths: [ .pip ]
  allow_failure: true
  when: always
```

- Enviroment:
 - `$JIRA_TEST_CASE_ARTIFACT`: test_case file path, default is test_case.json
 - `$JIRA_TEST_CYCLE_ARTIFACT`: test_cycle file path, default is test_cycle.json
 - `$JIRA_SERVER`: jira.teko.vn
 - `$JIRA_PROJECT_KEY`: TESTING
 - `$JIRA_USERNAME`: tekobot
 - `$JIRA_PASSWORD`: *****
 - `$CONFLUENCE_USERNAME`: tekobot
 - `$CONFLUENCE_PASSWORD`: *****

## 4. Teko OAS tool

Open Api Specification tool
- OpenAPI spec parser and validator
- OpenAPI spec comparator
- OpenAPI gen html/pdf (coming soon)
```
$ teko oas
```

```
Usage: teko oas [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  diff
  parse
```
### 4.1 Parse and validate Openapi spec

This tool parse and validate Openapi spec with input is path to file json/yaml or link to file yaml (json: coming soon) openapi file.
```
$ teko oas parse <Path/Link to openapi file>
```
You can see errors if file's format is wrong:
```
$ teko oas parse sample/oas_tool/sample-doc-false-format.yaml
```

```
...
paths./api/v1/rule/{id}.get.parameters.0: Parameter paths./api/v1/rule/{id}.get.parameters.0 must be required since it is in the path
paths./api/v1/rule/{id}.get.parameters.3.schema: Expected paths./api/v1/rule/{id}.get.parameters.3.schema.default to be one of [<class 'int'>], got <class 'str'>

2 errors

```

### 4.2 Compare spec

This tool compare between generated spec (from code) and designed spec.

Input is two paths to file json/yaml or link to file yaml (json: coming soon) openapi files.
```
$ teko oas diff <Path/Link to designed spec> <Path/Link to generated spec> 
```

* Example result:
```
$ teko oas diff sample/oas_tool/sample-doc.yaml sample/oas_tool/sample-param-change.json
```
```commandline
[TEKO TOOL][INFO]:        OAS compare spec!
 difference
   paths
     /api/v1/rule/{id} GET
       parameters
         miss_param1
-         Class object
+         None
         miss_param2
-         Class object
+         None
         diff_param_type1
           schema
             type
-             boolean
+             string
             default
-             False
+             None
         diff_param_default_and_in_2
           in
-           header
+           query
           required
-           False
+           True
           schema
             default
-             False
+             True
 miss
 redundancy
[TEKO TOOL][INFO]:        Error: 7
[TEKO TOOL][INFO]:        Warning: 0

```

### 4.3 Unit test
Run pytest file "sample/oas_tool_test/test_compare.py" 
to check compare tool with specific cases and results.
```commandline
teko-tools $ pytest sample/oas_tool_test/test_compare.py
```


# Change log

## \[0.1.0\] - 2020-12-08
### Fixed
- Initiate 

## \[0.1.1\] - 2020-12-11
### Fixed
- First MVP

            

Raw data

            {
    "_id": null,
    "home_page": "https://git.teko.vn/vnpay-marketing-portal/teko-tools",
    "name": "teko-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Teko,Teko CLI tools",
    "author": "Thuc Nguyen",
    "author_email": "thuc.nc@teko.vn",
    "download_url": "https://files.pythonhosted.org/packages/eb/37/b99238f69a3cfc9d5ee80cad45866dda91717225940e350ac3b373dfed4a/teko-cli-0.12.4.tar.gz",
    "platform": null,
    "description": "# Teko CLI Tools\n\n```\npip install teko-cli\n```\nThis is a Python package that contains some classes and CLI tools to be used during development \nprocess at Teko Vietnam (https://teko.vn).\n\nList of tools:\n\n- Teko Jira Tools: for pushing test case/ test cycle\n- Teko Jira Export Test: for pytest export jira test case/test cycle\n- Teko Oas Tools: for validate auto doc match with defined doc\n\n\n## 1 Installation\n\nTo use this tools, Python 3.6+ should be instaled. \n\nInstall or upgrade to the latest version:\n\n```shell\n$ pip install -r requirements.txt\n$ pip install --editable .\n```\n\nAfter successful installation, you should be able to use `teko` command in your \nconsole terminal:\n\n```\n$ teko\n```\n\nYou should see this kind of help message:\n\n```\nUsage: teko [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --install-completion [bash|zsh|fish|powershell|pwsh]\n                                  Install completion for the specified shell.\n  --show-completion [bash|zsh|fish|powershell|pwsh]\n                                  Show completion for the specified shell, to\n                                  copy it or customize the installation.\n\n  --help                          Show this message and exit.\n\nCommands:\n  cs\n  jira\n  oas\n```\n\n## Using Teko Jira tool\n\n### 2.1 Configure Jira credential\n\nThis tool use username/password authentication to Jira server, Confluence documentation and working with one Jira project \nat the same time. Jira server authentication uses 4 environment variables below. \nYou can set these variables to the your environment, or save it to `.env` file in working\ndirectory:\n\nSample content of `.env` file:\n\n```\nJIRA_SERVER=jira.teko.vn\nJIRA_PROJECT_KEY=<project-key>\nJIRA_USERNAME=<jira-username>\nJIRA_PASSWORD=<jira-password>\nCONFLUENCE_USERNAME=<confluence-username>\nCONFLUENCE_PASSWORD=<confluence-password>\n```\n\n### 2.2 Submit (create) list of testcases to a Jira Project\n\nTo push testcases to a Jira Project, you should prepare a `.yaml` \nor a `.json` file, containing list of testcases to be created in Jira, \nthen use following command:\n\n```\n$ teko jira create-tests {testcase_file}\n```\n\nTo see help message, use `--help` option: `teko jira create-tests --help`:\n\n```\nUsage: teko jira create-tests [OPTIONS] FILE\n\n\n\nArguments:\n  FILE  The name of a testcase definition file  [required]\n\nOptions:\n  --help  Show this message and exit.\n```\n\n**Note:** This tool uses test case `name` as identification, so existing tests with same `name` \nwill be updated with the latest information. \n\n#### Sample testcases file\n\n- `.yaml` file\n\n```yaml\n- name: Testcase 01\n  issueLinks: [TESTING-4]\n  objective: Test 01 Objective\n  precondition: Test 01 Precondition\n  testScript:\n    type: PLAIN_TEXT\n    text: >\n      - init x and y <br/>\n      - call func add(x, y)\n  labels: [ABC, XYZ]\n- name: Testcase 02\n  issueLinks: [TESTING-4, TESTING-5]\n  objective: Test 02 Objective\n  precondition: Test 02 Precondition\n  priority: Normal\n  status: Draft\n  testScript:\n    type: STEP_BY_STEP\n    steps:\n    - description: <i>Step 1</i>\n      testData: (x,y) = (1,3)\n      expectedResult: <strong>4</strong>\n    - description: Step 2\n      testData: <code>(x,y) = (4,5)</code>\n      expectedResult: 9\n```\n\n- Equivalent `.json` file:\n\n```json\n[\n  {\n    \"name\": \"Testcase 01\",\n    \"issueLinks\": [\n      \"TESTING-4\"\n    ],\n    \"objective\": \"Test 01 Objective\",\n    \"precondition\": \"Test 01 Precondition\",\n    \"testScript\": {\n      \"type\": \"PLAIN_TEXT\",\n      \"text\": \"- init x and y <br/> - call func add(x, y)\\n\"\n    },\n    \"labels\": [\"ABC\", \"XYZ\"]\n  },\n  {\n    \"name\": \"Testcase 02\",\n    \"issueLinks\": [\n      \"TESTING-4\",\n      \"TESTING-5\"\n    ],\n    \"objective\": \"Test 02 Objective\",\n    \"precondition\": \"Test 02 Precondition\",\n    \"priority\": \"Normal\",\n    \"status\": \"Draft\",\n    \"testScript\": {\n      \"type\": \"STEP_BY_STEP\",\n      \"steps\": [\n        {\n          \"description\": \"<i>Step 1</i>\",\n          \"testData\": \"(x,y) = (1,3)\",\n          \"expectedResult\": \"<strong>4</strong>\"\n        },\n        {\n          \"description\": \"Step 2\",\n          \"testData\": \"<code>(x,y) = (4,5)</code>\",\n          \"expectedResult\": \"9\"\n        }\n      ]\n    }\n  }\n]\n```\n\n### 2.3 Create test cycle (testrun result) in a Jira Project\n\nTo create a testrun report (cycle) to a Jira Project, you should prepare a `.yaml` \nor a `.json` file, containing list of testcases and **their result** to be created \nin Jira, then use following command:\n\n```\n$ teko jira create-cycle {testcase_file}\n```\n\n#### Sample testrun (cycle) file\n\n- `.yaml` file\n\n```yaml\n- name: Testcase 01\n  testrun_folder: /Sprint 1\n  testrun_status: Pass\n  testrun_environment: Dev\n  testrun_comment: The test has passed successfully\n  testrun_duration: 300000\n  testrun_date: \"2020-12-31T23:59:59Z\"  \n- name: Testcase 02\n  testrun_folder: /Sprint 2\n  testrun_status: Fail\n  testrun_environment: test1\n  testrun_comment: The test has failed on some automation tool procedure\n  testrun_duration: 30000\n  testrun_date: \"2020-12-31T23:59:59Z\" \n```\n\n- Equivalent `.json` file\n\n```json\n[\n  {\n    \"name\": \"Testcase 01\",\n    \"testrun_folder\": \"/Sprint 1\",\n    \"testrun_status\": \"Pass\",\n    \"testrun_environment\": \"Dev\",\n    \"testrun_comment\": \"The test has passed successfully\",\n    \"testrun_duration\": 300000,\n    \"testrun_date\": \"2020-12-31T23:59:59Z\"\n  },\n  {\n    \"name\": \"Testcase 02\",\n    \"testrun_folder\": \"/Sprint 2\",\n    \"testrun_status\": \"Fail\",\n    \"testrun_environment\": \"test1\",\n    \"testrun_comment\": \"The test has failed on some automation tool procedure\",\n    \"testrun_duration\": 30000,\n    \"testrun_date\": \"2020-12-31T23:59:59Z\"\n  }\n]\n```\n**Note:**\n-  Test run results are grouped into multiple cycles based on their common `testrun_folder`.\n- `testrun_duration` is measured in milliseconds.\n- `testrun_environment` is chosen from available environments that defined by users in the project. Do this by accessing **Configuration** in Tests Board on Jira.  \n\n### Sample combined testcase file with test results\nBoth test case and test run use the **same structure**. \nSo you can you a single combined the information and the result of a test into one wrapper for both operation: create tests and create cycles. \nThis file can be **generated automatically** from *docstrings* and/or \n*annotation*/*decorator* in auto test code.\n\n### 2.4 Sample combined testcase file with test results\n\n- `.yaml` file\n\n```yaml\n- name: Testcase 01\n  issueLinks: [TESTING-4]\n  objective: Test 01 Objective\n  precondition: Test 01 Precondition\n  testScript:\n    type: PLAIN_TEXT\n    text: >\n      - init x and y <br/>\n      - call func add(x, y)\n  labels: ABC, XYZ\n  testrun_status: Pass\n  testrun_environment: Dev\n  testrun_comment: The test has passed successfully\n  testrun_duration: 300000\n  testrun_date: \"2020-12-31T23:59:59Z\" \n- name: Testcase 02\n  issueLinks: [TESTING-4, TESTING-5]\n  objective: Test 02 Objective\n  precondition: Test 02 Precondition\n  priority: Normal\n  status: Draft\n  testScript:\n    type: STEP_BY_STEP\n    steps:\n    - description: <i>Step 1</i>\n      testData: (x,y) = (1,3)\n      expectedResult: <strong>4</strong>\n    - description: Step 2\n      testData: <code>(x,y) = (4,5)</code>\n      expectedResult: 9\n  testrun_status: Fail\n  testrun_environment: test1\n  testrun_comment: The test has failed on some automation tool procedure\n  testrun_duration: 30000\n  testrun_date: \"2020-12-31T23:59:59Z\"\n```   \n\n- Equivalent `.json` file\n\n```json\n[\n  {\n    \"name\": \"Testcase 01\",\n    \"issueLinks\": [\n      \"TESTING-4\"\n    ],\n    \"objective\": \"Test 01 Objective\",\n    \"precondition\": \"Test 01 Precondition\",\n    \"testScript\": {\n      \"type\": \"PLAIN_TEXT\",\n      \"text\": \"- init x and y <br/> - call func add(x, y)\\n\"\n    },\n    \"labels\": [\"ABC\", \"XYZ\"],\n    \"testrun_status\": \"Pass\",\n    \"testrun_environment\": \"Dev\",\n    \"testrun_comment\": \"The test has passed successfully\",\n    \"testrun_duration\": 300000,\n    \"testrun_date\": \"2020-12-31T23:59:59Z\"\n  },\n  {\n    \"name\": \"Testcase 02\",\n    \"issueLinks\": [\n      \"TESTING-4\",\n      \"TESTING-5\"\n    ],\n    \"objective\": \"Test 02 Objective\",\n    \"precondition\": \"Test 02 Precondition\",\n    \"priority\": \"Normal\",\n    \"status\": \"Draft\",\n    \"testScript\": {\n      \"type\": \"STEP_BY_STEP\",\n      \"steps\": [\n        {\n          \"description\": \"<i>Step 1</i>\",\n          \"testData\": \"(x,y) = (1,3)\",\n          \"expectedResult\": \"<strong>4</strong>\"\n        },\n        {\n          \"description\": \"Step 2\",\n          \"testData\": \"<code>(x,y) = (4,5)</code>\",\n          \"expectedResult\": \"9\"\n        }\n      ]\n    },\n    \"testrun_status\": \"Fail\",\n    \"testrun_environment\": \"Test1\",\n    \"testrun_comment\": \"The test has failed on some automation tool procedure\",\n    \"testrun_duration\": 30000,\n    \"testrun_date\": \"2020-12-31T23:59:59Z\"\n  }\n]\n```\n## 3 Using export test\n### 3.1 Configure\n- Add to test setting `pytest_plugins = [\"teko.utils.jira_export_test\"]` . Example, add to `conftest.py`\n- To use decorator: `from teko.utils.jira_export_test.wraper import jira_test`\n- To use test script type STEP_BY_STEP: `from teko.models.jira_export_test.test_step import TestStep`\n#### Env\n- `$JIRA_TEST_CASE_ARTIFACT`: test_case file path, default is test_case.json\n- `$JIRA_TEST_CYCLE_ARTIFACT`: test_cycle file path, default is test_cycle.json\n- Optional: `$ENV` or `$ENVIRONMENT` for test cycle env. Default, detect env from `$CI_COMMIT_BRANCH`\n### 3.2 Write test function\n- example in `/sample/jira_export_test/`\n\nMaybe you need push test to Jira with teko-tool, this is example gitlab-ci.yml\n```\ntest:unittest:\n  stage: test\n  ...\n  variables:\n    JIRA_TEST_CASE_ARTIFACT: test_case.json\n    JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json\n  artifacts:\n    paths:\n      - $JIRA_TEST_CASE_ARTIFACT\n      - $JIRA_TEST_CYCLE_ARTIFACT\n    expire_in: 1 week\n  allow_failure: false\n\n\nreport:push-test:\n  stage: report\n  image: python:3.7-slim\n  variables:\n    JIRA_TEST_CASE_ARTIFACT: test_case.json\n    JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json\n    JIRA_PROJECT_KEY: TESTING\n    JIRA_SERVER: jira.teko.vn\n    JIRA_USERNAME: changeme\n    JIRA_PASSWORD: changeme\n    CONFLUENCE_USERNAME: changeme\n    CONFLUENCE_PASSWORD: changeme\n  script:\n    - pip install --upgrade --cache-dir=.pip teko-cli\n    - teko jira create-tests $JIRA_TEST_CASE_ARTIFACT\n    - teko jira create-cycle $JIRA_TEST_CYCLE_ARTIFACT\n  cache:\n    key: pip-cache\n    paths: [ .pip ]\n  allow_failure: true\n  when: always\n```\n\n- Enviroment:\n - `$JIRA_TEST_CASE_ARTIFACT`: test_case file path, default is test_case.json\n - `$JIRA_TEST_CYCLE_ARTIFACT`: test_cycle file path, default is test_cycle.json\n - `$JIRA_SERVER`: jira.teko.vn\n - `$JIRA_PROJECT_KEY`: TESTING\n - `$JIRA_USERNAME`: tekobot\n - `$JIRA_PASSWORD`: *****\n - `$CONFLUENCE_USERNAME`: tekobot\n - `$CONFLUENCE_PASSWORD`: *****\n\n## 4. Teko OAS tool\n\nOpen Api Specification tool\n- OpenAPI spec parser and validator\n- OpenAPI spec comparator\n- OpenAPI gen html/pdf (coming soon)\n```\n$ teko oas\n```\n\n```\nUsage: teko oas [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  diff\n  parse\n```\n### 4.1 Parse and validate Openapi spec\n\nThis tool parse and validate Openapi spec with input is path to file json/yaml or link to file yaml (json: coming soon) openapi file.\n```\n$ teko oas parse <Path/Link to openapi file>\n```\nYou can see errors if file's format is wrong:\n```\n$ teko oas parse sample/oas_tool/sample-doc-false-format.yaml\n```\n\n```\n...\npaths./api/v1/rule/{id}.get.parameters.0: Parameter paths./api/v1/rule/{id}.get.parameters.0 must be required since it is in the path\npaths./api/v1/rule/{id}.get.parameters.3.schema: Expected paths./api/v1/rule/{id}.get.parameters.3.schema.default to be one of [<class 'int'>], got <class 'str'>\n\n2 errors\n\n```\n\n### 4.2 Compare spec\n\nThis tool compare between generated spec (from code) and designed spec.\n\nInput is two paths to file json/yaml or link to file yaml (json: coming soon) openapi files.\n```\n$ teko oas diff <Path/Link to designed spec> <Path/Link to generated spec> \n```\n\n* Example result:\n```\n$ teko oas diff sample/oas_tool/sample-doc.yaml sample/oas_tool/sample-param-change.json\n```\n```commandline\n[TEKO TOOL][INFO]:        OAS compare spec!\n difference\n   paths\n     /api/v1/rule/{id} GET\n       parameters\n         miss_param1\n-         Class object\n+         None\n         miss_param2\n-         Class object\n+         None\n         diff_param_type1\n           schema\n             type\n-             boolean\n+             string\n             default\n-             False\n+             None\n         diff_param_default_and_in_2\n           in\n-           header\n+           query\n           required\n-           False\n+           True\n           schema\n             default\n-             False\n+             True\n miss\n redundancy\n[TEKO TOOL][INFO]:        Error: 7\n[TEKO TOOL][INFO]:        Warning: 0\n\n```\n\n### 4.3 Unit test\nRun pytest file \"sample/oas_tool_test/test_compare.py\" \nto check compare tool with specific cases and results.\n```commandline\nteko-tools $ pytest sample/oas_tool_test/test_compare.py\n```\n\n\n# Change log\n\n## \\[0.1.0\\] - 2020-12-08\n### Fixed\n- Initiate \n\n## \\[0.1.1\\] - 2020-12-11\n### Fixed\n- First MVP\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Teko CLI tools",
    "version": "0.12.4",
    "project_urls": {
        "Download": "https://pypi.org/project/teko/",
        "Homepage": "https://git.teko.vn/vnpay-marketing-portal/teko-tools"
    },
    "split_keywords": [
        "teko",
        "teko cli tools"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a23c4bfb4f3aad8be5b6f5572654863b3e7ee6352975927fdad757cccd3056da",
                "md5": "956ff0882ae1d5116aa6d29c60eebedb",
                "sha256": "56e9caa8ff7a45f2b6e9e8c6368e3fca19decaca587ca98f1fa728207d01a7e4"
            },
            "downloads": -1,
            "filename": "teko_cli-0.12.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "956ff0882ae1d5116aa6d29c60eebedb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 53661,
            "upload_time": "2023-05-11T08:00:29",
            "upload_time_iso_8601": "2023-05-11T08:00:29.286202Z",
            "url": "https://files.pythonhosted.org/packages/a2/3c/4bfb4f3aad8be5b6f5572654863b3e7ee6352975927fdad757cccd3056da/teko_cli-0.12.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb37b99238f69a3cfc9d5ee80cad45866dda91717225940e350ac3b373dfed4a",
                "md5": "0d0f76264bb0553163a40ad05b1ce2fc",
                "sha256": "8a578c19b87922544ca7681fcd3e198209ce2759f59f56b5d29ff27392521125"
            },
            "downloads": -1,
            "filename": "teko-cli-0.12.4.tar.gz",
            "has_sig": false,
            "md5_digest": "0d0f76264bb0553163a40ad05b1ce2fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 42996,
            "upload_time": "2023-05-11T08:00:32",
            "upload_time_iso_8601": "2023-05-11T08:00:32.029372Z",
            "url": "https://files.pythonhosted.org/packages/eb/37/b99238f69a3cfc9d5ee80cad45866dda91717225940e350ac3b373dfed4a/teko-cli-0.12.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-11 08:00:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "teko-cli"
}
        
Elapsed time: 0.08851s