Common Lisp Package: WEBLOCKS-TEST

README:

FUNCTION

Public

FIND-UI-ACTIONS (TYPE &KEY NAME ID CLASS (TEST #'EQUALP))

If called during an active unit test, looks for the action in the unit test database and returns the action (if found), or nil. If no active unit test is present, signals an error.

FIND-UI-FORM (&KEY ID CLASS (TEST #'EQUALP))

A wrapper for find-ui-action for forms. Returns the first form in the list, if any.

TEST-WEBLOCKS (&OPTIONAL (VERBOSE T))

Call this function to run all unit tests defined in 'weblocks-test' package. This function tests weblocks in a clean environment. See 'with-test-environment' for more details. Pass NIL as the optional arg to just return the results instead of DESCRIBE-ing them.

Private

%ENSURE-NODIFF (ACTUAL-VALUES EXPECTED-VALUES TEST-FORM &KEY (TEST *LIFT-EQUALITY-TEST*))

Helper for `ensure-nodiff'.

%ENSURE-SAME-HTML (ACTUAL-VALUES EXPECTED-VALUES TEST-FORM &REST %ENSURE-NODIFF-ARGS)

Helper for `ensure-same-html'.

ADDRESSES (&REST ARGS)

Returns a list of addresses.

CALL-WITH-FAKE-OUTPUT (THUNK)

Rebind `*weblocks-output-stream*' and others necessary, call THUNK, restore the old context, and answer the string of whatever was written to it in the meantime.

CALL-WITH-REQUEST (&REST ARGS)

Helper for `with-request''s expansion.

CALL-WITH-REQUEST-IN-WEBAPP-CONTEXT (THUNK METHOD PARAMETERS &KEY (URI NIL URI?))

Helper for `call-with-request'.

CALL-WITH-TEST-ENVIRONMENT (THUNK)

Helper for `with-test-environment'.

CALL-WITH-TEST-WEBAPP (THUNK &REST INITARGS &KEY FULL CLASS-NAME &ALLOW-OTHER-KEYS)

Helper for WITH-TEST-WEBAPP's expansion.

CALL/TEMPFILE (PROC &REST OPEN-ARGS)

Call PROC with an open temporary file stream, passing in OPEN-ARGS. Delete after exiting.

DIFF-STRINGS (OLD NEW)

Answer the result of running `*diff-shell-command*' on OLD and NEW strings.

DO-ACTION (ACTION-NAME &REST ARGS)

A friendlier interface for do-request-and-render-dirty.

DO-REQUEST (PARAMETERS)

Mocks up a submitted request for unit tests.

DO-REQUEST-AND-RENDER-DIRTY (PARAMETERS)

Calls `do-request' and then renders dirty widgets.

EMULATE-LIFT-KWARGS (KWARGS)

Quote arguments where appropriate for macroexpansion of ensure-* forms.

EVALUATE-FLASH-HOOKS

A utility function that evaluates hooks set up by the flash widget.

MAKE-REQUEST-AJAX

Adds appropriate headers to a request so it is considered to be an AJAX request.

MAKE-TEMPORARY-FILE (&REST OPEN-ARGS &KEY (DIRECTION OUTPUT) &ALLOW-OTHER-KEYS)

Answer a newly opened temporary file.

MAKE-VERSIONED-REGEX (NAME TYPE)

Used for checking potential local dependency path.

REDIRECT (URI &KEY (DEFER (AND (BOUNDP '*SESSION*) (BOUNDP '*REQUEST-HOOK*) POST-RENDER)) NEW-WINDOW-P (WINDOW-TITLE URI))

Redirects the client to a new URI. There are several modes of redirecting: Immediate redirect (:DEFER NIL): interrupt request processing at once and send either a `redirect' HTTP response (for normal requests) or an appropriate JSON command (for AJAX requests). Deferred redirect (:DEFER (:POST-ACTION|:POST-RENDER); the default being :POST-RENDER): like immediate redirecting but the execution will be deferred until action processing (POST-ACTION) or rendering (POST-RENDER) is finished. Redirect to new window (NEW-WINDOW=T): opens URI in a new window. The current request continues to be processed in a normal fashion. WINDOW-TITLE is the title of the new window, defaulting to the target URI. DEFER is disregarded in this case. NEW-WINDOW functionality will only work when Javascript is enabled.

SPAN-KEYWORD-PARAMS (IMPLICIT-PROGN)

Take the plist from the front of IMPLICIT-PROGN, and answer it and the remaining forms. Note that there must be at least one non-plist form, because we want to always maintain "returns value of last form" semantics to reduce any confusion caused by this syntax. Anyway, if you want to force interpretation of a keyword in IMPLICIT-PROGN as a prognable form, just quote it.

SUBTYPEP (TYPE1 TYPE2 &OPTIONAL ENVIRONMENT)

Return two values indicating the relationship between type1 and type2. If values are T and T, type1 definitely is a subtype of type2. If values are NIL and T, type1 definitely is not a subtype of type2. If values are NIL and NIL, it couldn't be determined.

TYPEP (OBJECT TYPE &OPTIONAL ENVIRONMENT)

Is OBJECT of type TYPE?

Undocumented

BROKEN-INIT-USER-SESSION (ROOTCOMP)

C-TMPNAM (RESULT)

CLASS-VISIBLE-SLOT-NAMES (OBJ &REST ARGS)

CREATE-SITE-LAYOUT

DATA-HEADER-TEMPLATE (ACTION BODY &KEY (DATA-CLASS-NAME employee) PRESLOTS (POSTSLOTS `((DIV CLASS ,submit ,(LINK-ACTION-TEMPLATE ACTION Modify CLASS modify)))))

DATASEQ-DATA-COUNT-FOO (OBJ SORT PAGINATION &KEY COUNTP)

DATASEQ-DATA-FOO (OBJ SORT PAGINATION &KEY COUNTP)

DUMMY-SYMBOL-FUNCTION (&REST ARGS)

ENSURE-GENERIC-FUNCTION (FUN-NAME &REST ALL-KEYS &KEY ENVIRONMENT DEFINITION-SOURCE &ALLOW-OTHER-KEYS)

FORM-HEADER-TEMPLATE (ACTION BODY &KEY (METHOD get) (TITLE-ACTION Modifying: ) PRESLOTS (POSTSLOTS '((DIV CLASS submit (INPUT NAME submit TYPE submit CLASS submit VALUE Submit ONCLICK disableIrrelevantButtons(this);) (INPUT NAME cancel TYPE submit CLASS submit cancel VALUE Cancel ONCLICK disableIrrelevantButtons(this);)))) (URI /foo/bar) ENCTYPE (USE-AJAX-P T) (DATA-CLASS-NAME employee) FORM-ID)

MAKE-TEMP-BUNDLES (DEPENDENCIES)

MAKE-TEST-DEPENDENCIES-1

MAKE-TEST-DEPENDENCIES-2

MAKE-TEST-DEPENDENCIES-3

MAKE-TEST-DEPENDENCIES-4

MAKE-TEST-NAV

MERGED-WITH-NEWLINE-EQUAL (PART-PATHS MERGED-PATH)

PAGINATION-GOTO-FORM-TEMPLATE (ACTION &KEY (PAGE-ONE-P NIL) (VALIDATEDP T) (URI /foo/bar))

PAGINATION-PAGE-INFO-TEMPLATE (CURRENT-PAGE TOTAL-PAGES)

REMOVE-ALL-METHODS (GF)

REMOVE-IMPORT-URLS (URLS)

RESET-SESSIONS

SEARCHBAR-TEMPLATE (FORM-ID SEARCH-ID SUBMIT-ID ACTION &KEY TOTAL-ITEMS-TEXT VALUE (URI /foo/bar))

SET-EQUAL-EQUAL (A B)

SET-EQUAL-URI= (A B)

SHELL-COMMAND-PROC

SIMPLE-TMPNAM

TABLE-HEADER-TEMPLATE (HEADERS ROWS &KEY SUMMARY PRETABLE POSTTABLE (TABLE-CLASS employee))

WITH-REQUEST-TEMPLATE (BODY &KEY (TITLE Hello) RENDER-DEBUG-TOOLBAR-P WIDGET-STYLESHEETS)

MACRO

Private

DEFJSTEST (NAME FORM VALUE)

Define a test in an appropriate testsuite called NAME, ensuring that FORM's values and the literal VALUES are equal.

DEFTEST (NAME FORM &REST VALUES)

Define a test in an appropriate testsuite called NAME, ensuring that FORM's values and the literal VALUES are equal.

DEFTEST-HTML (NAME FORM VALUE)

A helper macro for creating html test cases. The macro writes code that temporarily binds the output stream to a string stream and then compares the string to the expected result.

ENSURE-HTML-OUTPUT (FORM CL-WHOVIAN &REST ENSURE-SAME-HTML-ARGS)

As with `ensure-same-html', but capture the output during FORM instead, comparing it to CL-WHO-formatted CL-WHOVIAN. Remaining args are passed to `ensure-same-html'.

ENSURE-NODIFF (FORM VALUES &REST KEY-ARGS)

As with `ensure-same', but when the expected value is a string, use a special reporter that prints the output of `*diff-shell-command*' run on the expected and actual values. See `%ensure-nodiff' for available keyword args.

ENSURE-SAME-HTML (FORM VALUES &REST KEY-ARGS)

As with `ensure-nodiff', but first transforming the HTML strings into values more suitable for diffing. See `%ensure-nodiff' for available keyword args.

SET-SENSIBLE-SUITE

Set up a sensible testsuite to use as the testsuite for addtest forms that may not have a suite defined in-file, in the file in which I am expanded. Likely to work only at toplevel.

WITH-REQUEST (METHOD PARAMETERS &BODY BODY)

A helper macro for test cases across web requests. The macro sets up a request and a session, and executes code within their context. 'method' - A method with which the request was initiated (:get or :post) 'parameters' - An association list of parameters sent along with the request. Other parameters given as keywords on the front of BODY: URI - Set the Hunchentoot request URI to this.

WITH-TEST-ENVIRONMENT (&BODY BODY)

This macro takes steps to clear the environment for the unit tests. For example, if testing in the context of an application, it may interfere with the unit tests, so we remove the application. All changes are rolled back after the tests are done. Note, the steps that this macro takes may not be sufficient. If some tests fail, try to run the test suite without loading an application.

WITH-TEST-WEBAPP ((&REST INITARGS &KEY FULL CLASS-NAME &ALLOW-OTHER-KEYS) &BODY BODY)

A helper macro (and marker) for test cases calling functions that only work with a current webapp, in which BODY is evaluated in the context of a temporary `weblocks-webapp'. INITARGS are passed through to `make-instance'. If FULL is given, I will also start the webapp within BODY's context; if CLASS-NAME is given, I will ignore other INITARGS and either find or start a webapp with the class CLASS-NAME, setting it as the current webapp in my context.

Undocumented

DEFCLASS (&ENVIRONMENT ENV NAME DIRECT-SUPERCLASSES DIRECT-SLOTS &REST OPTIONS)

DEFGENERIC (&WHOLE FORM NAME (&REST ARGS) &BODY OPTIONS)

DEFMETHOD (&WHOLE FORM NAME &BODY BODY &ENVIRONMENT ENV)

OUTPUTS-NOTHING-P (&BODY BODY)

WITH-BUNDLE-SETUP (&BODY BODY)

WITH-TALLY-SETUP (&BODY BODY)

GENERIC-FUNCTION

Private

Undocumented

SUPPORTS-FILTER-P (STORE)

SLOT-ACCESSOR

Private

Undocumented

ADDRESS-CITY (OBJECT)

ADDRESS-STREET (OBJECT)

CONTENT-STREAM (OBJECT)

FIND-SLOT-DSD-TEST-A (OBJECT)

SETFFIND-SLOT-DSD-TEST-A (NEW-VALUE OBJECT)

FIND-SLOT-DSD-TEST-B (OBJECT)

SETFFIND-SLOT-DSD-TEST-B (NEW-VALUE OBJECT)

FIRST-NAME (OBJECT)

SETFFIRST-NAME (NEW-VALUE OBJECT)

GRADUATION-YEAR (OBJECT)

MANAGER (OBJECT)

SETFMANAGER (NEW-VALUE OBJECT)

NSP-FIRST-NAME (OBJECT)

SETFNSP-FIRST-NAME (NEW-VALUE OBJECT)

NSP-LAST-NAME (OBJECT)

SETFNSP-LAST-NAME (NEW-VALUE OBJECT)

UNBOUND-SLOTS-TEST-SLOT1 (OBJECT)

SETFUNBOUND-SLOTS-TEST-SLOT1 (NEW-VALUE OBJECT)

UNBOUND-SLOTS-TEST-SLOT2 (OBJECT)

SETFUNBOUND-SLOTS-TEST-SLOT2 (NEW-VALUE OBJECT)

UNIVERSITY (OBJECT)

VARIABLE

Private

*DIFF-SHELL-COMMAND*

Shell command used to compare the expected against actual output.

*DUMMY-ACTION*

A dummy action code for unit tests.

*RECOVERY-STRATEGIES*

Alist of strategies to try in turn when a test fails in `do-test'. Each cdr is passed a thunk that will perform the test and determine whether it succeeded. If one succeeds, the car is used as a label for the successful patched test when reporting it.

*TEST-WIDGET-ID*

Used to generate a unique ID for fixtures.

Undocumented

*BOB*

*CLOSE-HTML*

*EMPLOYEE1*

*EMPLOYEE2*

*EMPLOYEE3*

*EMPLOYEE4*

*HOME-ADDRESS*

*JOE*

*NOT-SEARCHABLE-STORE*

*SOME-COLLEGE*

*TEMP-BUNDLES-FOLDER*

*TEMP-MOD-RECORD-FOLDER*

*TEMP-VERSION-FILE*

*TEMP-VERSION-FOLDER*

*TEST-STORE*

*WORK-ADDRESS*

GENERATE-WIDGET-ID-ORIG

CLASS

Private

UNITTEST-REQUEST

A class used to mock hunchentoot requests in order to be able to unit test across requests.

UNITTEST-SERVER

A class used to mock hunchentoot server in order to be able to unit test across requests.

Undocumented

.APPLICATION-SUITE

.WEBLOCKS-SUITE

ADDRESS

ADDRESS-PARSER

APP-WITH-NOT-SEARCHABLE-STORE

APPLICATION-SUITE

BROKEN-INIT

BUNDLING-SUITE

COMPOSITE-SUITE

CONTROL-FLOW/CALL-ANSWER-SUITE

DATAFORM-SUITE

DEPENDENCIES-SUITE

DIRTIER

EDUCATED-EMPLOYEE

EDUCATION-HISTORY

EMPLOYEE

FIND-SLOT-DSD-TEST-A (OBJECT)

FIND-SLOT-DSD-TEST-B (OBJECT)

FIND-SLOT-DSD-TEST-C

HCR-HELLO-WEBAPP

HCR2-HELLO-WEBAPP

HELLO-WEBAPP

HELLO10-WEBAPP

HELLO2-WEBAPP

HELLO3-WEBAPP

HELLO4-WEBAPP

HELLO5-WEBAPP

HELLO6-WEBAPP

HELLO7-WEBAPP

HELLO8-WEBAPP

HELLO9-WEBAPP

HOST-1

HOST-2

HOST-3

HOST-4

NOT-SEARCHABLE-PERSON

PERSON

REQUEST-HANDLER-SUITE

REQUEST-SUITE

RWBG-1-DUMMY-FIELD

SERVER-SUITE

SESSION-SUITE

SLOT-EQUAL-TEST-CLASS

SNIPPETS/SUGGEST-SUITE

SOME-DATES

SOME-NAME

STANDARD-CLASS

STANDARD-GENERIC-FUNCTION

STORE/STORE-UTILS-SUITE

UNBOUND-SLOTS-TEST

URI-TOKENS-SUITE

UTILS/MISC-SUITE

VERSIONING-SUITE

VIEWS/FORMVIEW/FORMVIEW-SUITE

VIEWS/TYPES/PRESENTATIONS/DATE-SUITE

VIEWS/VIEW/UTILS-SUITE

WEBLOCKS-SUITE

WIDGETS/DATA-EDITOR-SUITE

WIDGETS/DATAEDIT/DATAEDIT-SUITE

WIDGETS/DATASEQ/DATASEQ-SUITE

WIDGETS/NAVIGATION-SUITE

WIDGETS/STATIC-SELECTOR-SUITE

WIDGETS/WIDGET/WIDGET-SUITE