chefboyrd.tests package

Submodules

chefboyrd.tests.test_app module

Test the flask application with a real server

We use a real client and server to test requests and responses in this unittest file.abs

See methods for examples.

class chefboyrd.tests.test_app.ChefBoyRDTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Test the flask application

setUp()[source]

Sets up the database file

tearDown()[source]

Unlinks and deletes the app database

test_hello()[source]

Sample test for /test/hello route

chefboyrd.tests.test_fb module

Unittesting the functions in feedback_controller. Includes feedback analysis and storage and deletion of sms objects in the database

written by: Seo Bo Shim, Jarod Morin tested by: Seo Bo Shim, Jarod Morin debugged by: Seo Bo Shim, Jarod Morin

class chefboyrd.tests.test_fb.MyModuleTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

test_delete_twilio_feedback()[source]

Tests for correct performance of method that deletes feedback in the Twilio API and in our database

Passes when: Cannot delete sms data with invalid sid. Method to delete feedback handles errors appropriately

Fails when: The controller attempts to delete sms that does not exist. Or if there is a problem with interfacing with the Twilio API

test_feedback_analysis()[source]

Tests for correct performance of feedback analysis on known string inputs. Tests functionality of sms feedback use case, that the analysis is done accurately

Passes when: The feedback analysis algorithm correctly assigns appropriate flags to a set of example strings.

Fails when: The feedback analysis algorithm fails to assign correct flags to messages

test_update_db()[source]

Tests to make sure that Sms objects that are stored in the database are storing correctly. Tests the functionality of the Sms feedback use case: storing and accessing feedback

Passes when: The system can process Sms data that is sent and update the database. Can query with a date range while rejecting invalid dates. Can correctly read sms data

Fails when: System has errors in processing sms. Cannot read information from the Sms object The sms database is not empty when deleted and invalid date ranges are specified

test_word_freq_counter()[source]

Tests for correct performance of word frequency counter on known string inputs. Test for the sms feedback use case, where the result of the feedback analysis can then be displayed in a word cloud in the management’s feedback panel

Passes when: The word_frequency_counter can appropriately assign frequency values in the correct output format Handles invalid input with error

Fails when: The word_frequency_counter is not assigning correct frequency values to words Or does not respond appropriately to invalid input.

chefboyrd.tests.test_fb_data module

Includes the functions required to generate random sms messages in case Twilio is not available. This is to help test the functionality of how sms stored in the database is read and interpreted.

written by: Seo Bo Shim tested by: Seo Bo Shim debugged by: Seo Bo Shim

class chefboyrd.tests.test_fb_data.TestMessages(sid, date_sent, body, from_)[source]

Bases: object

Test class that emulates how twilio stores messages, so that this can be run to test the funtions without a connection to twilio

chefboyrd.tests.test_fb_data.auto_generate_sms_data(n=25, date_from=datetime.datetime(2017, 3, 4, 1, 12, 5, 569093))[source]

Helper function to generates random feedback data :param n: number of items to generate :type n: int :param date_from: starting date time. Ending date time used is datetime.now() :type date_from: datetime

Returns:message with same format as Twilio message to store in database
Return type:messages(TestMessage)
chefboyrd.tests.test_fb_data.random_word(allLists, max=13)[source]

Helper function to generate random sentence

Parameters:
  • allLists (List(str)) – List of strings of available words to use
  • max (int) – max length of the sentence
chefboyrd.tests.test_fb_data.test_sms_data(n, date_from)[source]

Creates n samples of SMS of a pre-determined body, listed in sample_messages If n is >5, then more sample feedback messages must be added to the list below

chefboyrd.tests.test_int module

Integration Tests which ensure all views are reachable from the homepage

class chefboyrd.tests.test_int.PageTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Testing for each of the pages and submission forms

login(uname, pw)[source]

Logs a user in

logout()[source]

Logs the user out

setUp()[source]

Setup the test client and application

tearDown()[source]

Unlink and remove DB from application

test_dashboard()[source]

Ensure sure we can reach the prediction page properly when logged in and out.

test_dashboard_post()[source]

Ensure sure we can POST to each of the dashboard types

test_homepage()[source]

Ensure sure we can reach the homepage while running

test_prediction()[source]

Ensure sure we can reach the prediction page properly when logged in and out.

test_table_manager()[source]

Ensure sure we can reach the table_manager page properly when logged in and out.

chefboyrd.tests.test_int_auth module

class chefboyrd.tests.test_int_auth.AuthTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

Authentication and Authorization Tests

login(uname, pw)[source]

Logs a user in

logout()[source]

Logs the user out

setUp()[source]

Setup for the database and test client

tearDown()[source]

Deletion and unlinking of the database file

test_login()[source]

Test login/logout functionality with different users

test_multi_role()[source]

Ensure that the role-required wrapper can handle multiple roles

test_roles()[source]

Test the role requirement wrapper to make sure role-based authorization works as expected.

chefboyrd.tests.test_int_auth.req_login()[source]

Route which requires a user to be loggd in to access

chefboyrd.tests.test_int_auth.req_multi_role()[source]

Route which requires one of a list of roles to access

chefboyrd.tests.test_int_auth.req_roles()[source]

Rout which requires a single role to be accessed

chefboyrd.tests.test_predict module

Test some model creation and methods

class chefboyrd.tests.test_predict.ModelTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

classmethod setUp()[source]

Sets up the database and tables for the test application

classmethod tearDown()[source]

Deletes and unlinks the temporary database file

test_create_foreign_key_obj()[source]

Ensures that we can create an item with a foreign key field

Passes when: We can create a new mealingredient in the MealIngredients table which has specific attributes that we are able to retrieve after creation.

Fails when: We are unable to select the proper MealIngredient from the table

test_create_meal()[source]

Ensures that we can make at least one meal in the database.

Passes when: We can successfully add a new meal to the database and retrieve it back from the database after inserting it.

Fails when: We can’t retrieve a meal from the Meals table which matches the newly inserted meal. It will also fail if there is more than one meal in the database with the same name.

test_create_tab()[source]

Ensures that tab creation works

Passes when: We can successfully create a new tab and assert that it is the only tab contained within the tabs table.

Fails when: There are more tabs in the Tabs table which have 10 people in a party or there are no tabs which have 12 people which had no reservation

test_generate_data(orders)[source]

Ensures that we can successfully create orders when generating data

Passes when: Data is generated by calling Orders.create()

Fails when: Orders.create() is not called when generating data

test_get_dotw()[source]

Ensures that we can reliably get the day of the week using the get_dotw_orders function

Passes when: We get ensure all orders returned reside on the same date and the correct day of the week.

Fails when: We don’t retrieve the correct day of the week OR we return tabs which are not on the same day and does not raise errors on bad inputs

test_get_earliest_datetime()[source]

Ensures that we always retrieve the earliest datetime from a given set of data

Passes when: The datetime returned from data_controller.get_earliest_datetime is the very earliest datetime in the input set from a set of generated data which has datetime.now() as the earliest time

Fails when: The earliest date retrieved is not equal to datetime.now()

test_get_meals()[source]

Enures that the get_meals_in_range function gets only the meals within the correct range

Passes when: We ensure we retrieve meals which include the daterange specified

Fails when: We are unable to retrieve the meals within the date range.

test_get_tab_range()[source]

Tests that we get only the tabs within a specific range

Accomplishes this by creating a set of tabs and inserting them into the table. Then we pick a few ranges of those times including the very beginning and very last dates to ensure we cover edge cases and return the correct number of tabs for the gien time ranges.

Passes when: We ensure that all tabs (and only the tabs) which were created within a certain datetime range are returned

Fails when: We find a tab which does not reside within a date range.

test_order_range()[source]

Tests the get_orders_date_range function.

Tests all edge cases to make sure that the constraints are not broken

We accomplish this by creating a set of tabs with different dates and ensures that given certain inputs we return none, all, or a subset of the tabs which we had just inserted.

Passes When we can ensure all orders created over a given range can be returned through mulitple queries as well as ensuring dates which fall outside our query range are not returned.BaseException

Fails when: We do not return orders that all fall within our queried range or if we do not return all orders in the range.

test_polynomialModel()[source]

Test the polynomial model for correct output

Passes when: polynomial model outputs the correct prediction value of 7 given the set if input parameters iv=[1, 2, 3] and ip=[1, 1, 1, 1]

Fails when: the polynomial model outputs the incorrect prediction

test_sinusoidalModel()[source]

Tests our sinusoidal model for the correct output

chefboyrd.tests.test_reservation module

Test some model creation and methods

class chefboyrd.tests.test_reservation.ModelTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

classmethod setUp()[source]
classmethod tearDown()[source]
test_book_first_available_table()[source]

Another test to get first table at a different date

test_book_table_for_2_hours()[source]

Attempts to book a reservation for 2 hours

test_get_first_table_available()[source]

This tests that we successfully created the table, and are able to book this table.

test_get_first_table_available_unavailable_1()[source]

The setup already books the 4 people table from 19:00 to 20:30

test_get_first_table_available_unavailable_2()[source]

The setup already books the 4 people table from 19:00 to 20:30

test_get_first_table_available_unavailable_3()[source]

The setup already books the 4 people table from 19:00 to 20:30

test_get_first_table_available_unavailable_4()[source]

The setup already books the 4 people table from 19:00 to 20:30

test_unavailable_tables_1_hour_before_closing()[source]

Attempts to get a table 1 hour before closing, but there is not enough time

test_unavailable_tables_1_hour_before_opening()[source]

Attempts to make a booking before the restaurant opens

Module contents