Module licenseware.cli.unittest_file_creator.unittest_file_creator

Expand source code
import os
from licenseware.cli.base_creator import BaseCreator
from . import templates



class UnittestFileCreator(BaseCreator):

    def __init__(self, app_id: str):
        super().__init__(app_id)


    def create(self):

        testfiles_path = f"test_files/{self.entity_underscore}"

        if not os.path.exists(testfiles_path):
            os.makedirs(testfiles_path)

        fname = "test_" + self.entity_underscore + ".py"
        
        if not os.path.exists(os.path.join('./tests', fname)):    
            self.create_file(
                filename=fname,  
                filepath='./tests',
                template_filename="test_name.py.jinja",
                template_resource=templates
            )

Classes

class UnittestFileCreator (app_id: str)

This class uses the given entity_id which can be: uploader_id, report_id, app_id etc The entity_id will have multiple derivate shapes (see bellow transformations in the init method) which will be passed to jinja templates as template variables

Each file creation class should inherit (if possible) from this class.

As an example you can see licenseware/cli/uploader_creator package.

Expand source code
class UnittestFileCreator(BaseCreator):

    def __init__(self, app_id: str):
        super().__init__(app_id)


    def create(self):

        testfiles_path = f"test_files/{self.entity_underscore}"

        if not os.path.exists(testfiles_path):
            os.makedirs(testfiles_path)

        fname = "test_" + self.entity_underscore + ".py"
        
        if not os.path.exists(os.path.join('./tests', fname)):    
            self.create_file(
                filename=fname,  
                filepath='./tests',
                template_filename="test_name.py.jinja",
                template_resource=templates
            )

Ancestors

Methods

def create(self)
Expand source code
def create(self):

    testfiles_path = f"test_files/{self.entity_underscore}"

    if not os.path.exists(testfiles_path):
        os.makedirs(testfiles_path)

    fname = "test_" + self.entity_underscore + ".py"
    
    if not os.path.exists(os.path.join('./tests', fname)):    
        self.create_file(
            filename=fname,  
            filepath='./tests',
            template_filename="test_name.py.jinja",
            template_resource=templates
        )

Inherited members