diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index 319f2fb..0000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: Main branch workflow - -on: - push: - branches: - - main - -jobs: - release: - runs-on: [ubuntu-latest] - outputs: - project_version: ${{ steps.get_project_version.outputs.project_version }} - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.11 - uses: actions/setup-python@v1 - with: - python-version: '3.11' - - name: Get a project version - id: get_project_version - run: echo "::set-output name=project_version::$(make get-project-version)" - - name: Install project requirements - run: make install-requirements - - name: Make a release - env: - ACCESS_TOKEN: ${{secrets.GIT_HUB_ACCESS_TOKEN}} - run: | - project-version release \ - --provider=GitHub \ - --organization=dmytrostriletskyi \ - --repository=intentions \ - --branch=main \ - --project-version=${{ steps.get_project_version.outputs.project_version }} - deploy: - runs-on: [ubuntu-latest] - needs: [release] - outputs: - project_version: ${{ steps.get_project_version.outputs.project_version }} - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.11 - uses: actions/setup-python@v1 - with: - python-version: '3.11' - - name: Get a project version - id: get_project_version - run: echo "::set-output name=project_version::$(make get-project-version)" - - name: Install project requirements - run: make install-requirements - - name: Build the package - run: python3 setup.py sdist - - name: Deploy the package - run: | - twine upload \ - --username __token__ \ - --password ${{ secrets.PYPI_PASSWORD }} \ - dist/intentions-${{ steps.get_project_version.outputs.project_version }}.tar.gz diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml deleted file mode 100644 index b1f2dc1..0000000 --- a/.github/workflows/pull_request.yaml +++ /dev/null @@ -1,64 +0,0 @@ ---- -name: Pull request workflow - -on: - pull_request_target: - branches: - - main - -jobs: - check-project-version: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: ['3.11'] - outputs: - project_version: ${{ steps.get_project_version.outputs.project_version }} - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Get a version of the project - id: get_project_version - run: echo "::set-output name=project_version::$(make get-project-version)" - - name: Install project requirements - run: make install-requirements - - name: Check project version - env: - ACCESS_TOKEN: ${{secrets.GIT_HUB_ACCESS_TOKEN}} - run: | - project-version check \ - --provider=GitHub \ - --organization=dmytrostriletskyi \ - --repository=intentions \ - --base-branch=main \ - --head-branch=${{ github.head_ref }} - lint: - name: Lint the codebase (python-${{ matrix.python-version }} on ${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - python-version: ['3.11'] - outputs: - project_version: ${{ steps.get_project_version.outputs.project_version }} - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Get a version of the project - id: get_project_version - run: echo "::set-output name=project_version::$(make get-project-version)" - - name: Install project requirements - run: make install-requirements - - name: Check code quality - run: make check-code-quality diff --git a/.project-version b/.project-version index 5a5831a..d169b2f 100644 --- a/.project-version +++ b/.project-version @@ -1 +1 @@ -0.0.7 +0.0.8 diff --git a/fixtures/test_file.py b/fixtures/test_file.py index a75cf17..a563361 100644 --- a/fixtures/test_file.py +++ b/fixtures/test_file.py @@ -6,7 +6,7 @@ ) -@describe(object='Accounts Service', domain='accounts') +@describe(domain='accounts', component='accounts', layer='service') class TestAccountsService: def test_transfer_money_with_insufficient_balance(self): @@ -30,7 +30,7 @@ def test_transfer_money_with_sufficient_balance(self): pass -@describe(object='Accounts Service', domain='accounts') +@describe(domain='accounts', component='accounts', layer='service') def test_transfer_money_to_non_existing_receiver_account(): with when('Receiver account does not exist'): pass @@ -42,7 +42,7 @@ def test_transfer_money_to_non_existing_receiver_account(): pass -@describe(object='Investments Service', domain='investments') +@describe(domain='investments', component='investments', layer='service') class TestInvestmentsService: def test_invest_money_into_stocks(self): @@ -60,7 +60,7 @@ def test_invest_money_into_crypto(self): pass -@describe(object='Investments Service', domain='investments') +@describe(domain='investments', component='investments', layer='service') def test_invest_into_non_existing_stocks(): with when('Stock to buy does not exist'): pass @@ -83,6 +83,6 @@ def test_invest_into_non_existing_crypto(): pass -@describe(object='Investments Service', domain='investments') +@describe(domain='investments', component='investments', layer='service') def test_sum(): assert 4 == 2 + 2 diff --git a/intentions/main.py b/intentions/main.py index eb57a91..6e8b62b 100644 --- a/intentions/main.py +++ b/intentions/main.py @@ -58,7 +58,7 @@ class expect(AbstractIntention): """ -def describe(object: str, domain: str) -> Callable[[Callable[..., T]], Callable[..., T]]: # noqa: ARG001 +def describe(domain: str, component: str, layer: str) -> Callable[[Callable[..., T]], Callable[..., T]]: # noqa: ARG001 def decorator(func: [..., T]) -> Callable[..., T]: def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> T: result = func(*args, **kwargs) diff --git a/intentions/render/ast_.py b/intentions/render/ast_.py index 0c29c56..e6a3fc0 100644 --- a/intentions/render/ast_.py +++ b/intentions/render/ast_.py @@ -63,12 +63,14 @@ def get_describe(self, decorators: [ast.Call]) -> Optional[Describe]: if decorator.func.id != 'describe': continue - assert decorator.keywords[0].arg == 'object' # noqa: S101 - assert decorator.keywords[1].arg == 'domain' # noqa: S101 + assert decorator.keywords[0].arg == 'domain' # noqa: S101 + assert decorator.keywords[1].arg == 'component' # noqa: S101 + assert decorator.keywords[2].arg == 'layer' # noqa: S101 return Describe( - object=decorator.keywords[0].value.value, - domain=decorator.keywords[1].value.value, + domain=decorator.keywords[0].value.value, + component=decorator.keywords[1].value.value, + layer=decorator.keywords[2].value.value, ) return None diff --git a/intentions/render/dto.py b/intentions/render/dto.py index 0b1eac0..555909a 100644 --- a/intentions/render/dto.py +++ b/intentions/render/dto.py @@ -5,8 +5,9 @@ @dataclass class Describe: - object: str # noqa: A003 domain: str + component: str + layer: str @dataclass diff --git a/intentions/render/main.py b/intentions/render/main.py index 279e696..64431d6 100644 --- a/intentions/render/main.py +++ b/intentions/render/main.py @@ -92,8 +92,11 @@ def collect_test_cases(storage: dict, file: Path) -> None: if describe.domain not in storage: storage[describe.domain] = {} - if describe.object not in storage[describe.domain]: - storage[describe.domain][describe.object] = [] + if describe.component not in storage[describe.domain]: + storage[describe.domain][describe.component] = {} + + if describe.layer not in storage[describe.domain][describe.component]: + storage[describe.domain][describe.component][describe.layer] = [] test_function = TestCase( function_name=function_node.name, @@ -105,7 +108,7 @@ def collect_test_cases(storage: dict, file: Path) -> None: ) test_case_as_dict = asdict(test_function) - storage[describe.domain][describe.object].append(test_case_as_dict) + storage[describe.domain][describe.component][describe.layer].append(test_case_as_dict) def create_intentions_json(directory: str) -> None: diff --git a/tests/render/test_main.py b/tests/render/test_main.py index b805aa4..ce87f2a 100644 --- a/tests/render/test_main.py +++ b/tests/render/test_main.py @@ -25,8 +25,8 @@ def test_create_intentions_json(self, remove_intentions_json) -> None: assert intentions_json['investments'] is not None with expect('Each intentions JSON domain consist of its objects'): - assert intentions_json['accounts']['Accounts Service'] - assert intentions_json['investments']['Investments Service'] + assert intentions_json['accounts']['accounts']['service'] + assert intentions_json['investments']['investments']['service'] def test_create_intentions_json_accounts_service(self, remove_intentions_json) -> None: with when('Tests folder with tests for accounts service exist'): @@ -64,7 +64,7 @@ def test_create_intentions_json_accounts_service(self, remove_intentions_json) - ] } - assert expected_test_case in intentions_json['accounts']['Accounts Service'] + assert expected_test_case in intentions_json['accounts']['accounts']['service'] with expect('Test transfer money with sufficient balance test case is in accounts service test cases'): expected_test_case = { @@ -92,7 +92,7 @@ def test_create_intentions_json_accounts_service(self, remove_intentions_json) - ] } - assert expected_test_case in intentions_json['accounts']['Accounts Service'] + assert expected_test_case in intentions_json['accounts']['accounts']['service'] with expect('Test transfer money to non existing receiver account test case is in accounts service test cases'): expected_test_case = { @@ -120,7 +120,7 @@ def test_create_intentions_json_accounts_service(self, remove_intentions_json) - ] } - assert expected_test_case in intentions_json['accounts']['Accounts Service'] + assert expected_test_case in intentions_json['accounts']['accounts']['service'] def test_create_intentions_json_investments_service(self, remove_intentions_json) -> None: with when('Tests folder with tests for investments service exist'): @@ -153,7 +153,7 @@ def test_create_intentions_json_investments_service(self, remove_intentions_json ] } - assert expected_test_case in intentions_json['investments']['Investments Service'] + assert expected_test_case in intentions_json['investments']['investments']['service'] with expect('Invest money into crypto test case is in investments service test cases'): expected_test_case = { @@ -176,7 +176,7 @@ def test_create_intentions_json_investments_service(self, remove_intentions_json ] } - assert expected_test_case in intentions_json['investments']['Investments Service'] + assert expected_test_case in intentions_json['investments']['investments']['service'] with expect('Invest money into non-existing stocks test case is in investments service test cases'): expected_test_case = { @@ -204,7 +204,7 @@ def test_create_intentions_json_investments_service(self, remove_intentions_json ] } - assert expected_test_case in intentions_json['investments']['Investments Service'] + assert expected_test_case in intentions_json['investments']['investments']['service'] def test_create_intentions_json_ignore_test_cases_without_intentions(self, remove_intentions_json) -> None: with when('Tests folder with described test cases without intentions'): @@ -226,4 +226,4 @@ def test_create_intentions_json_ignore_test_cases_without_intentions(self, remov 'intentions': [], } - assert expected_test_case not in intentions_json['investments']['Investments Service'] + assert expected_test_case not in intentions_json['investments']['investments']['service']