def create(request, values): """ Description: Creates a new build object and stores it in the database Params: $values - Hash: A reference to a hash with keys and values matching the fields of the build to be created. +-------------+----------------+-----------+---------------------------+ | Field | Type | Null | Description | +-------------+----------------+-----------+---------------------------+ | product | Integer/String | Required | ID or Name of product | | name | String | Required | | | description | String | Optional | | | is_active | Boolean | Optional | Defaults to True (1) | +-------------+----------------+-----------+---------------------------+ Returns: The newly created object hash. Example: # Create build by product ID and set the build active. >>> Build.create({'product': 234, 'name': 'tcms_testing', 'description': 'None', 'is_active': 1}) # Create build by product name and set the build to inactive. >>> Build.create({'product': 'TCMS', 'name': 'tcms_testing 2', 'description': 'None', 'is_active': 0}) """ if not values.get('product') or not values.get('name'): raise ValueError('Product and name are both required.') p = pre_check_product(values) return TestBuild.objects.create( product = p, name = values['name'], description = values.get('description'), is_active = values.get('is_active', True) ).serialize()
def check_product(request, name): """ Description: Looks up and returns a validated product. Params: $name - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Hash: Matching Product object hash or error if not found. Example: # Get with product ID >>> Product.check_product(61) # Get with product name >>> Product.check_product('Red Hat Enterprise Linux 5') """ p = pre_check_product(values = name) return p.serialize()
def check_build(request, name, product): """ Description: Looks up and returns a build by name. Params: $name - String: name of the build. $product - product_id of the product in the Database Returns: Hash: Matching Build object hash or error if not found. Example: # Get with product ID >>> Build.check_build('2008-02-25', 61) # Get with product name >>> Build.check_build('2008-02-25', 'Red Hat Enterprise Linux 5') """ p = pre_check_product(values = product) try: tb = TestBuild.objects.get(name = name, product = p) except TestBuild.DoesNotExist, error: return error
def check_component(request, name, product): """ Description: Looks up and returns a component by name. Params: $name - String: name of the category. $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Hash: Matching component object hash or error if not found. Example: # Get with product ID >>> Product.check_component('acpi', 61) # Get with product name >>> Product.check_component('acpi', 'Red Hat Enterprise Linux 5') """ from tcms.apps.management.models import Component p = pre_check_product(values = product) return Component.objects.get(name = name, product = p).serialize()
def check_category(request, name, product): """ Description: Looks up and returns a category by name. Params: $name - String: name of the category. $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Hash: Matching Category object hash or error if not found. Example: # Get with product ID >>> Product.check_category('Feature', 61) # Get with product name >>> Product.check_category('Feature', 'Red Hat Enterprise Linux 5') """ from tcms.apps.testcases.models import TestCaseCategory p = pre_check_product(values = product) return TestCaseCategory.objects.get(name = name, product = p).serialize()
def get_versions(request, product): """ Description: Get the list of versions associated with this product. Params: $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Array: Returns an array of Version objects. Example: # Get with product id >>> Product.get_runs(61) # Get with product name >>> Product.get_runs('Red Hat Enterprise Linux 5') """ from tcms.apps.management.models import Version p = pre_check_product(values = product) query = {'product': p} return Version.to_xmlrpc(query)
def get_categories(request, product): """ Description: Get the list of categories associated with this product. Params: $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Array: Returns an array of Case Category objects. Example: # Get with product id >>> Product.get_categories(61) # Get with product name >>> Product.get_categories('Red Hat Enterprise Linux 5') """ from tcms.apps.testcases.models import TestCaseCategory p = pre_check_product(values = product) query = {'product': p} return TestCaseCategory.to_xmlrpc(query)
def get_runs(request, product): """ Description: Get the list of runs associated with this product. Params: $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Array: Returns an array of Test Run objects. Example: # Get with product id >>> Product.get_runs(61) # Get with product name >>> Product.get_runs('Red Hat Enterprise Linux 5') """ from nitrate.apps.testruns.models import TestRun p = pre_check_product(values = product) query = {'build__product': p} return TestRun.to_xmlrpc(query)
def get_builds(request, product, is_active = True): """ Description: Get the list of builds associated with this product. Params: $product - Integer/String Integer: product_id of the product in the Database String: Product name $is_active - Boolean: True to only include builds where is_active is true. Default: True Returns: Array: Returns an array of Build objects. Example: # Get with product id including all builds >>> Product.get_builds(61) # Get with product name excluding all inactive builds >>> Product.get_builds('Red Hat Enterprise Linux 5', 0) """ from tcms.apps.management.models import TestBuild p = pre_check_product(values = product) query = {'product': p, 'is_active': is_active} return TestBuild.to_xmlrpc(query)