Example #1
0
def get_test_suites(serialno=None, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno, session=session)
    return session.query(TestSuiteResult).filter_by(
        serialno=serialno).order_by(desc(TestSuiteResult.created_at)).all()
Example #2
0
def invoices(invoice_sno=None):
    if invoice_sno is None:
        snos = dxcustoms.get_all_customs_invoice_serialnos()
        stage = {'snos': snos,
                 'crumbroot': '/sourcing',
                 'breadcrumbs': [Crumb(name="Sourcing", path=""),
                                 Crumb(name="Customs", path="customs/"),
                                 Crumb(name="Invoices", path="customs/inv/")],
                 }
        return render_template('customs_invoices.html', stage=stage,
                               pagetitle="Customs Document Sets")
    else:
        sno = serialnos.get_serialno_object(sno=invoice_sno)
        docs = docstore.get_docs_list_for_serialno(invoice_sno)
        invoice = dxcustoms.get_customs_invoice(invoice_sno)
        stage = {'sno': sno,
                 'docs': docs,
                 'invoice': invoice,
                 'crumbroot': '/sourcing',
                 'breadcrumbs': [Crumb(name="Sourcing", path=""),
                                 Crumb(name="Customs", path="customs/"),
                                 Crumb(name="Invoices", path="customs/invoice/"),  # noqa
                                 Crumb(name=invoice_sno, path="customs/invoice/" + invoice_sno)],  # noqa
                 }
        return render_template(
            'customs_invoice_detail.html', stage=stage,
            pagetitle=invoice_sno + " Customs Document Set"
        )
Example #3
0
def register_document(serialno=None, docpath=None, doctype=None,
                      efield=None, clobber=True, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if docpath is None:
        raise AttributeError('docpath cannot be None')
    if doctype is None:
        raise AttributeError('doctype cannot be None')

    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno,
                                                 session=session)

    try:
        q = session.query(DocStoreDocument).filter_by(
            serialno=serialno, docpath=docpath
        )
        existing = q.one()
    except NoResultFound:
        # default does not exist yet, so add it...
        session.add(
            DocStoreDocument(docpath=docpath, doctype=doctype,
                             efield=efield, serialno_id=serialno.id,
                             serialno=serialno)
        )
    else:
        if clobber is True:
            existing.serialno = serialno
            existing.doctype = doctype
            existing.docpath = docpath
            existing.efield = efield
            session.add(existing)
        else:
            raise ValueError("Document already exists, and clobber is False")
Example #4
0
def get_test_suite_descs(serialno=None, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno, session=session)
    return session.query(TestSuiteResult.desc,
                         TestSuiteResult.suite_class).filter_by(
                             serialno=serialno).distinct().all()
Example #5
0
def get_inventory_indent(serialno=None, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        try:
            serialno = serialnos.get_serialno_object(sno=serialno,
                                                     session=session)
        except SerialNoNotFound:
            raise IndentNotFound
    try:
        return session.query(InventoryIndent).filter_by(serialno=serialno).one()
    except NoResultFound:
        raise IndentNotFound
Example #6
0
def get_latest_test_result(serialno=None, test_class=None, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if test_class is None:
        raise AttributeError("testclass cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno, session=session)
    if not isinstance(test_class, str):
        test_class = repr(test_class.__class__)
    return session.query(TestResult).filter_by(
        test_class=test_class).join(TestSuiteResult).filter(
            TestSuiteResult.serialno == serialno).order_by(
                desc(TestResult.created_at)).first()
Example #7
0
def get_inventory_indent(serialno=None, session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        try:
            serialno = serialnos.get_serialno_object(sno=serialno,
                                                     session=session)
        except SerialNoNotFound:
            raise IndentNotFound
    try:
        return session.query(InventoryIndent).filter_by(
            serialno=serialno).one()
    except NoResultFound:
        raise IndentNotFound
Example #8
0
def get_latest_test_suite(serialno=None,
                          suite_class=None,
                          descr=None,
                          session=None):
    if serialno is None:
        raise AttributeError("serialno cannot be None")
    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno, session=session)
    q = session.query(TestSuiteResult).filter_by(serialno=serialno,
                                                 suite_class=suite_class)
    if descr is not None:
        q = q.filter_by(desc=descr)
    q = q.order_by(desc(TestSuiteResult.created_at))
    return q.first()
Example #9
0
def commit_test_suite(suiteobj=None, session=None):
    sno = serialnos.get_serialno_object(sno=suiteobj.serialno, session=session)
    passed = suiteobj.passed

    sro = TestSuiteResult(suite_class=repr(suiteobj.__class__),
                          passed=passed,
                          desc=suiteobj.desc,
                          title=suiteobj.title)
    sro.serialno = sno

    if suiteobj.ts is not None:
        sro.created_at = suiteobj.ts

    session.add(sro)
    for test in suiteobj.tests:
        if not test.skipped:
            sro.tests.append(
                create_test_model_obj(testobj=test, suite=sro,
                                      session=session))
Example #10
0
def get_serialno_doctype_documents(serialno=None, doctype=None,
                                   limit=None, one=False, session=None):
    q = session.query(DocStoreDocument)
    if serialno is not None:
        if not isinstance(serialno, SerialNumber):
            serialno = serialnos.get_serialno_object(sno=serialno,
                                                     session=session)
        q = q.filter_by(serialno=serialno)
    if doctype:
        q = q.filter(DocStoreDocument.doctype == doctype)

    q = q.order_by(desc(DocStoreDocument.created_at))
    if limit:
        q = q.limit(limit)
    if one is True:
        try:
            return q.one()
        except NoResultFound:
            raise DocumentNotFound
    return q.all()
Example #11
0
def invoices(invoice_sno=None):
    if invoice_sno is None:
        snos = dxcustoms.get_all_customs_invoice_serialnos()
        stage = {
            'snos':
            snos,
            'crumbroot':
            '/sourcing',
            'breadcrumbs': [
                Crumb(name="Sourcing", path=""),
                Crumb(name="Customs", path="customs/"),
                Crumb(name="Invoices", path="customs/inv/")
            ],
        }
        return render_template('customs_invoices.html',
                               stage=stage,
                               pagetitle="Customs Document Sets")
    else:
        sno = serialnos.get_serialno_object(sno=invoice_sno)
        docs = docstore.get_docs_list_for_serialno(invoice_sno)
        invoice = dxcustoms.get_customs_invoice(invoice_sno)
        stage = {
            'sno':
            sno,
            'docs':
            docs,
            'invoice':
            invoice,
            'crumbroot':
            '/sourcing',
            'breadcrumbs': [
                Crumb(name="Sourcing", path=""),
                Crumb(name="Customs", path="customs/"),
                Crumb(name="Invoices", path="customs/invoice/"),  # noqa
                Crumb(name=invoice_sno, path="customs/invoice/" + invoice_sno)
            ],  # noqa
        }
        return render_template('customs_invoice_detail.html',
                               stage=stage,
                               pagetitle=invoice_sno + " Customs Document Set")
Example #12
0
def get_sno_documents(serialno=None, session=None):
    if not isinstance(serialno, SerialNumber):
        serialno = serialnos.get_serialno_object(sno=serialno, session=session)
    return session.query(DocStoreDocument).filter_by(serialno=serialno).all()