Unit and functional tests

tests

admin_tests

class rfid_lock_management.tests.admin_tests.AccessTimeAdminTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

fixtures = ['initial.json']
setUp()[source]
tearDown()[source]
test_change_form_redirection()[source]

Check that if we try to go to an individual Access Time object’s change form, we’re redirected back to the change list.

test_lockuser_html_heading()[source]

Does the AccessTime change list page display LockUsers as links to their change pages?

class rfid_lock_management.tests.admin_tests.LockUserAdminActionsTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

fixtures = ['initial.json']
setUp()[source]
tearDown()[source]
test_deactivate()[source]

Deactivating selected lock users (admin action)

models_tests

class rfid_lock_management.tests.models_tests.AccessTimeModelTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_get_this_lockuser_html()[source]

Create AccessTime with specific lockuser; make sure get_this_lockuser_html returns the correct html

test_unicode()[source]

Test that custom __unicode__() returns the correctly formatted time

class rfid_lock_management.tests.models_tests.DoorModelTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_door_perm_creation()[source]

When a new Door is added, create a corresponding Permission (i.e. checking Door’s save() method)

test_unicode()[source]

Test that custom __unicode__() method returns name of Door

class rfid_lock_management.tests.models_tests.LockUserModelTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_creating_new_obj_and_saving_it_to_db()[source]

Create new LockUser, set attributes, save to database

test_custom_save_assign_keycard()[source]

Check that custom save assigns (creates and saves) new RFIDkeycard for this LockUser

test_custom_save_deactivate_keycard()[source]

Check that custom save deactivates current keycard

test_get_all_access_times()[source]

Are the access times (access_time field for AccessTime object) for this LockUser the same as those returned by get_all_access_times (or None)

test_get_all_rfids()[source]

Does get_all_rfids() returns all RFIDkeycards objects associated with Lockuser

test_get_all_rfids_html()[source]

Check that method returns the correctly formatted html string of all rfids, NOT including the current one

test_get_allowed_doors()[source]

Does get_allowed_doors() return the door(s), if any, that the lockuser is allowed to access

test_get_current_rfid()[source]
test_get_last_access_time()[source]

Is the last access time for this LockUser the same as that returned by get_last_access_time (or None)

test_is_active()[source]

Check if is_active() reflects whether the user is assigned a keycard

Check that method returns the correctly formatted html string

test_prettify_get_allowed_doors()[source]
test_prettify_get_current_rfid()[source]
test_prettify_get_last_access_time()[source]

Check that this method formats the last access time correctly

test_unicode()[source]

Test that custom __unicode__() – i.e. just obj_name – returns first and last name of lockuser

class rfid_lock_management.tests.models_tests.RFIDkeycardModelTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_deactivate()[source]

On deactivation, is RFIDkeycard object’s date revoked and revoker set correctly?

test_get_allowed_doors()[source]

Does get_allowed_doors() return the door(s), if any, that the associated lockuser is allowed to access

test_is_active()[source]
test_unicode()[source]

Test that custom __unicode__() method returns the rfid string.

views_tests

class rfid_lock_management.tests.views_tests.ChartDataTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

fixtures = ['initial.json']
setUp()[source]
test_chartify()[source]

Does chartify() return response with the correct(ly formatted) data for HighChart plot of access times?

class rfid_lock_management.tests.views_tests.NewKeycardScanTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_finished_new_keycard_scan()[source]

Everything went ok (no active keycard with this RFID num already; a NewKeycardScan object with this pk does exist and has an RFID num; not timed out), so can assign keycard.

test_finished_new_keycard_scan_keycard_with_same_rfid_exists()[source]

A keycard with the same RFID is already assigned to another lockuser

test_finished_new_keycard_scan_no_keycardscan_obj_with_pk()[source]

No NewKeycardScan object with the pk specified in the URL

test_finished_new_keycard_scan_obj_does_not_have_rfid()[source]

NewKeycardScan object did not get an RFID num

test_finished_new_keycard_scan_timed_out()[source]

Longer than x minutes to scan new card – timed out

test_initiate_new_keycard_scan()[source]

Lockuser with specified id exists, does not have assigned keycard: - check for appropriate response - and that a new NewKeycardScan object is created, - and it has correct attributes (waiting_for_scan = True;

assigner_user = request.user)
test_initiate_new_keycard_scan_but_lockuser_has_keycard()[source]

Lockuser with specified id already has an assigned keycard: check for appropriate response and that a new NewKeycardScan object is not created

test_initiate_new_keycard_scan_but_no_lockuser()[source]

Lockuser with specified id does not exist: - check for appropriate response - and that a new NewKeycardScan object is not created

templatetags_tests

class rfid_lock_management.tests.templatetags_tests.TemplateTagsTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
test_get_object_type()[source]

Test that get_object_type custom filter returns the object.

staff_users_tests

class rfid_lock_management.tests.staff_users_tests.StaffUserTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

setUp()[source]
tearDown()[source]
test_staff_only_user_can_only_see_doors_they_have_permission_for()[source]

Check that staff users can only see the doors they are permitted to manage.

lock_comm_tests

class rfid_lock_management.tests.lock_comm_tests.LockCommunicationTests(methodName='runTest')[source]

Bases: django.test.testcases.TestCase

fixtures = ['initial.json']
setUp()[source]
test_all_allowed_existing_door()[source]

get all allowed RFIDs for existing door

test_all_allowed_inactive_not_allowed()[source]

list of allowed RFIDs does not contain any inactive ones

test_all_allowed_non_existing_door()[source]

get all allowed RFIDs for door that does not exist

test_all_allowed_wrong_format()[source]

get all allowed RFIDs for door in wrong format (incorrect url)

test_authent_but_waiting_for_scan()[source]

Check: since the latest NewKeycardScan object is waiting_for_scan, don’t attempt to authenticate, just return 0; do not create an AccessTime

test_authent_rfid()[source]

RFID associated with door, is active

test_authent_rfid__wrong_door()[source]

RFID not associated with door 2, is active

test_authent_rfid_does_not_exist()[source]

RFID does not exist

test_authent_rfid_door_does_not_exist()[source]

Door does not exist

test_authent_rfid_door_wrong_format_in_url()[source]

Door id in wrong format (i.e. URL is in the wrong format, so not found error)

test_authent_rfid_inactive_right_door()[source]

RFID was associated with door, but now inactive

test_authent_rfid_wrong_format_in_url()[source]

RFID is in wrong format (i.e. url wrong format, so not found error)

lock_comm_tests_helpers

functional_tests

class rfid_lock_management.tests.functional_tests.AccessTimeList(methodName='runTest')[source]

Bases: django.test.testcases.LiveServerTestCase

fixtures = ['initial.json']
setUp()[source]

Start up Selenium WebDriver browser instance

tearDown()[source]

Shut down Selenium WebDriver browser instance

test_access_time_change_list()[source]
class rfid_lock_management.tests.functional_tests.GeneralFunctionalTests(methodName='runTest')[source]

Bases: django.test.testcases.LiveServerTestCase

fixtures = ['initial.json']
setUp()[source]

Start up Selenium WebDriver browser instance

tearDown()[source]

Shut down Selenium WebDriver browser instance

test_keycard_deactivation()[source]

Change form for an active (i.e. has assigned keycard) lock user: after checking ‘Deactivate current keycard’ and saving, does the change list show the deactivation/saved message? Does the change list show this lockuser as inactive? Back on the change form, there should not be an assigned keycard (Current RFID: None) and ‘Deactivate current keycard’ should be unchecked.

test_keycard_deactivation_but_some_doors_permitted()[source]

Tests is the situation where the lock user is permitted access to some door(s), but not the one(s) the staff user is allowed access to. That is, on the change form, there will be no checked Door(s), so checking ‘Deactive keycard’ should not deactivate the keycard.

test_lockuser_change_form()[source]

Is this the change_form for the right lock user?

test_no_delete_button_lockuser_change_form()[source]

Check that staff users do not see a ‘delete’ button/link on the form page for an individual Lock User. (This is for an existing LockUser – when adding a LockUser there would not be a ‘delete’ link/button in any case.)

class rfid_lock_management.tests.functional_tests.LogIn(methodName='runTest')[source]

Bases: django.test.testcases.LiveServerTestCase

fixtures = ['initial.json']
setUp()[source]

Start up Selenium WebDriver browser instance

tearDown()[source]

Shut down Selenium WebDriver browser instance

test_can_do_stuff_in_browser()[source]

Logging in; making sure correct user and other info displayed

functional_create_assign_walkthrough

class rfid_lock_management.tests.functional_create_assign_walkthrough.CreateLockUserAssignKeycardWalkthrough(methodName='runTest')[source]

Bases: django.test.testcases.LiveServerTestCase

fixtures = ['initial.json']
setUp()[source]
tearDown()[source]

Shut down Selenium WebDriver browser instance

test_create_new_lockuser_and_assign_keycard_walkthrough()[source]

This is a walkthrough for: adding a lockuser to the system, and assigning a keycard. The sequence of events:

Staff user... - logs in - (main page loads (currently /lockadmin/rfid_lock_management/)) - clicks ‘New user’ button - (add form loads (/lockadmin/rfid_lock_management/lockuser/add/) ) - fills out all fields - selects a door checkbox - clicks <input type=”submit” value=”Save and continue editing”

name=”_continue” class=”btn”>
  • clicks <input type=”button” class=”btn” id=”add_keycard_button” value=”Assign keycard”>

  • <to do at this point – will find_element_by_* find the element below if the enclosing div is not visible, since it itself is not explicitly set to not be visible? Depending on answer, might have to insert new events/checks in here............. >

  • clicks <input type=”button” class=”btn” id=”start_button” value=”Scan new card”>

  • opens new browser window and goes to address e.g. http://192.168.x.x:port_num/checkdoor//checkrfid (obv use liveserver variable)

  • back to previous window

  • clicks <input type=”button” class=”btn” id=”done_button” value=”Done”>

  • clicks <input type=”submit” value=”Save” class=”btn” name=”_save”>

  • (change list loads)

    • change list table should have the correct line with the lock user’s

    information, status, RFID, etc. *