예제 #1
0
class SeverityType(types.TypeDecorator):
    """Severity, or impact that an item may have on something if it did not exist."""

    impl = INTEGER
    enumerations = Enums("Unknown", "MajorLoss", "MinorLoss",
                         "MinorLossHasReplacement", "CauseDifficulty",
                         "Annoyance", "Trivial")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #2
0
class ValueType(types.TypeDecorator):
    """base types of attribute value types. Usually a value_type column
    name.
    """

    impl = INTEGER
    enumerations = Enums("object", "string", "unicode", "integer", "float",
                         "boolean")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #3
0
class LikelihoodType(types.TypeDecorator):
    """Approximate likelihood (probability quartile) that an event may occur."""

    impl = INTEGER
    enumerations = Enums("Unknown", "VeryLikely", "Likely", "Possible",
                         "Unlikely", "VeryUnlikely")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #4
0
class TestCaseType(types.TypeDecorator):
    """TestCase test type. Where in the cycle this test is applied."""

    impl = INTEGER
    enumerations = Enums("unit", "system", "integration", "regression",
                         "performance")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[1]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #5
0
    def _initfsm(self):
        # state names:
        [NAME,   SLASH,   QUOTE,   SLASHQUOTE,   PARAM,   PARAMNAME,   VALUE,
         ENDLINE,   PARAMVAL,   PARAMQUOTE,   VSLASH,
        ] = Enums(
        "NAME", "SLASH", "QUOTE", "SLASHQUOTE", "PARAM", "PARAMNAME", "VALUE",
        "ENDLINE", "PARAMVAL", "PARAMQUOTE", "VSLASH",
              )
        f = _RFC2822FSM(NAME)
        f.add_default_transition(self._error, NAME)
        # 
        f.add_transition_list(IANA_TOKEN, NAME, self._addtext, NAME)
        f.add_transition(":", NAME, self._endname, VALUE)
        f.add_transition(";", NAME, self._endname, PARAMNAME)
        f.add_transition_list(VALUE_CHAR, VALUE, self._addtext, VALUE)
        f.add_transition(CR, VALUE, None, ENDLINE)
        f.add_transition(LF, ENDLINE, self._doline, NAME)
        # parameters
        f.add_transition_list(IANA_TOKEN, PARAMNAME, self._addtext, PARAMNAME)
        f.add_transition("=", PARAMNAME, self._endparamname, PARAMVAL)

        f.add_transition_list(SAFE_CHAR, PARAMVAL, self._addtext, PARAMVAL)
        f.add_transition(",", PARAMVAL, self._nextparam, PARAMVAL)
        f.add_transition(";", PARAMVAL, self._nextparam, PARAMNAME)

        f.add_transition(DQUOTE, PARAMVAL, self._startquote, PARAMQUOTE)
        f.add_transition_list(QSAFE_CHAR, PARAMQUOTE, self._addtext, PARAMQUOTE)
        f.add_transition(DQUOTE, PARAMQUOTE, self._endquote, PARAMVAL)

        f.add_transition(":", PARAMVAL, self._nextparam, VALUE)

        # slashes
        f.add_transition("\\", VALUE, None, VSLASH)
        f.add_transition(ANY, VSLASH, self._slashescape, VALUE)
#       f.add_transition("\\", QUOTE, None, SLASHQUOTE)
#       f.add_transition(ANY, SLASHQUOTE, self._slashescape, QUOTE)
#       # double quotes 
#       f.add_transition(DQUOTE, xxx, None, QUOTE)
#       f.add_transition(DQUOTE, QUOTE, self._doublequote, xxx)
#       f.add_transition(ANY, QUOTE, self._addtext, QUOTE)
        f.reset()
        self._fsm = f
예제 #6
0
class PriorityType(types.TypeDecorator):
    """TestCase priority type."""

    impl = INTEGER
    enumerations = Enums("P_UNKNOWN", "P1", "P2", "P3", "P4", "P5")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #7
0
class TestCaseStatus(types.TypeDecorator):
    """TestCase status indicates test case lifecycle state."""

    impl = INTEGER
    enumerations = Enums("new", "reviewed", "deprecated")

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))
예제 #8
0
파일: test.py 프로젝트: wildone/pycopia
    def test_XHTML(self):
        """Construct an XHTML page. Verify visually."""
        htd = XHTML.new_document(dtds.XHTML)
        htd.title = "This is the title."
        htd.add_header(1, 'Main document & "stuff"')
        htd.new_para("This is a test. This is text.")
        htd.add_unordered_list(["List line one.", "list line two."])
        BR = htd.get_new_element("Br")
        A = htd.get_new_element("A", href="somelink.html")
        A.add_text("some link")
        p = htd.get_para()
        p.append(A)
        p.add_text(" This is ")
        b = p.bold("bold")
        p.add_text(" text. using ")
        stb = htd.get_new_element("B")
        stb.add_text("bold tags")
        p.text(stb)
        p.add_text(" Dynamic Date: ")
        p.append(XHTML.DynamicNode(thedate))
        rp = str(p)
        htd.append(POM.ASIS(rp))
        # table methods
        t = htd.add_table(border=1)
        t.summary = "This is a test table."
        t.caption("table caption")
        h = t.set_heading(2, "heading col 2")
        h.set_attribute("class", "headerclass")
        t.set_heading(1, "heading col 1")
        t.set_cell(1, 1, "row 1, col 1")
        t.set_cell(1, 2, "row 2, col 1")
        t.set_cell(2, 1, "row 1, col 2")
        t.set_cell(2, 2, "row 2, col 2")
        # sections
        div = htd.get_section("section1")
        div.add_header(1, "Div heading.")
        div.new_para("First div para.")
        htd.append(div)
        div2 = div.get_section("section2")
        div2.new_para("Second div para")
        div.append(div2)

        dl = div.add_definition_list()
        dl.add_definitions({
            "def1": "The definition of 1",
            "def2": "The definition of 2"
        })

        # using the nodemaker object
        NM = htd.nodemaker
        ul = NM(
            "Ul",
            None,
            NM("Li", None, "line 1"),
            NM("Li", None, "line 2"),
            NM("Li", None, "Date: ",
               NM("code", None, thedate)),  # another way to add dynamic node
        )
        htd.append(ul)
        htd.append(NM("JS", None, 'var a = new Array(8);'))
        # using the creator object.
        creator = htd.creator
        parts = creator([("Just", "just/"), "How will this turn out?",
                         ["It is hard to tell.", "Well, not too hard."]])

        htd.add_comment(
            "the name attribute is required for all but submit & reset")
        htd.append(parts)
        f = htd.add_form(action="http://localhost:4001/cgi-bin/testing.py",
                         method="post")

        f.add_textarea("mytextarea", """Default text in the textarea.""")
        f.append(BR)
        f.add_input(type="text", name="mytext", value="mytext text")
        f.append(BR)
        f.add_input(type="button",
                    name="button1",
                    src="button.png",
                    value="Button")
        f.append(BR)
        f.add_input(type="submit",
                    name="submit1",
                    src="submit.png",
                    value="Ok")
        f.append(BR)
        f.add_radiobuttons("radlist", ["one", "two", "three", "four"],
                           vertical=False)
        f.append(BR)
        f.add_checkboxes("checks", ["one", "two", "three", "four"],
                         vertical=True)
        f.append(BR)
        f.add_fileinput(name="myfile", default="/etc/hosts")
        f.append(BR)
        f.add_textinput(name="mytext", label="Enter text")
        f.append(BR)
        f.yes_no("What's it gonna be?")
        f.add_select([
            "one", "two", ("three", True), "four", {
                "agroup": ["group1", "group2"]
            }
        ],
                     name="myselect")
        f.append(BR)

        f.add_select(
            {
                "Group1":
                Enums("g1one", "g1two", "g1three") + [("g1four", True)],
                "Group2": Enums("g2one", "g2two", "g2three"),
                "Group3": Enums("g3one", "g3two", "g3three"),
            },
            name="useenums")
        f.append(BR)

        f.add_select(["mone", "mtwo", ("mthree", True), ("mfour", True)],
                     name="multiselect",
                     multiple=True)
        f.append(BR)

        set = f.add_fieldset("afieldset")
        set.add_textinput(name="settext", label="Enter set text")
        set.add_textinput(name="settext2",
                          label="Enter set text 2",
                          default="Default text.")
        set.append(BR)
        tbl = htd.new_table([1, 2, 3, 4, 5], [NULL, NULL, NULL],
                            ["col1", "col2", "col3"],
                            width="100%",
                            summary="autogenerated")

        gentable = table.GenericTable(["heading1", "heading2", "heading3"],
                                      title="Sample generic table")
        gentable.append([1, 2, 3])
        gentable.append([4, 5, 6])
        tbl2 = htd.new_table_from_GenericTable(gentable)
        # object
        subdoc = XHTML.new_document(dtds.XHTML)
        parts = subdoc.creator(
            ("Add a document object.", ["Some data.", "some more data.."]))
        subdoc.append(parts)
        sdfo = open("/tmp/subdoc.html", "w")
        subdoc.emit(sdfo)
        sdfo.close()
        htd.add_object(data="subdoc.html",
                       type=subdoc.MIMETYPE,
                       width="400px",
                       height="600px")
        htd.emit(sys.stdout)
        print "-----"
        fo = open(XHTMLFILENAME, "w")
        bw = POM.BeautifulWriter(fo, XHTML.INLINE)
        htd.emit(bw)
        fo.close()
        print "----- Form values:"
        print f.fetch_form_values()
        print "----- Form elements:"
        felems = f.fetch_form_elements()
        for name, elemlist in felems.items():
            print repr(name), ": ", repr(elemlist)
            print
        # visually verify the page.
        webbrowser.open("file://%s" % (XHTMLFILENAME, ))
예제 #9
0
def make_states(*args):
    "converts an argument list of strings to a list of Enum. Use as state transitions."
    return Enums(list(map(str, args)))
예제 #10
0
파일: types.py 프로젝트: bharathi26/pycopia
        return cls.enumerations.find(value)

    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))


TESTRESULTS = Enums(PASSED=1, FAILED=0, INCOMPLETE=-1, ABORT=-2, NA=-3, EXPECTED_FAIL=-4)
TESTRESULTS.sort()


class TestResultType(types.TypeDecorator):
    """Possible status of test case or test runner objects."""

    impl = INTEGER
    enumerations = TESTRESULTS

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod
    def process_result_value(cls, value, dialect):
        return cls.enumerations.find(value)
예제 #11
0
    @classmethod
    def get_choices(cls):
        return cls.enumerations.choices

    @classmethod
    def get_default(cls):
        return cls.enumerations[0]

    @classmethod
    def validate(cls, value):
        return cls.enumerations.find(int(value))


TESTRESULTS = Enums(PASSED=1,
                    FAILED=0,
                    INCOMPLETE=-1,
                    ABORT=-2,
                    NA=-3,
                    EXPECTED_FAIL=-4)
TESTRESULTS.sort()


class TestResultType(types.TypeDecorator):
    """Possible status of test case or test runner objects."""

    impl = INTEGER
    enumerations = TESTRESULTS

    def process_bind_param(self, value, dialect):
        return int(value)

    @classmethod