コード例 #1
0
    def test_clear_database(self):
        """This tests that the database is cleared """

        database.clear_database()
        real = database.show_available_products()
        expected = {}
        self.assertEqual(real, expected)
コード例 #2
0
 def test_import_data(self):
     """Testing import data"""
     db.clear_database()
     actual = db.import_data("csv_files", "products.csv", "customers.csv",
                             "rentals.csv")
     expected = ((5, 4, 5), (0, 0, 0))
     self.assertEqual(actual, expected)
コード例 #3
0
 def test_show_available_products(self):
     """Tests displaying available products"""
     database.clear_database()
     database.import_data('', 'test_files/products_test.csv',
                          'test_files/customers_test.csv',
                          'test_files/rentals_test.csv')
     real = database.show_available_products()
     expected = {
         'Couch': {
             'description': 'You sit on it',
             'product_type': 'living room',
             'quantity_available': '1'
         },
         'Desk': {
             'description': 'You do work at it',
             'product_type': 'bedroom',
             'quantity_available': '4'
         },
         'TV': {
             'description': 'You watch it',
             'product_type': 'den',
             'quantity_available': '3'
         },
         'Table': {
             'description': 'You eat at it',
             'product_type': 'dining room',
             'quantity_available': '2'
         }
     }
     self.assertEqual(real, expected)
コード例 #4
0
 def test_show_available_products(self):
     """Tetsing showing available products"""
     self.maxDiff = None
     db.clear_database()
     actual = db
     actual.import_data("csv_files", "products.csv", "customers.csv",
                        "rentals.csv")
     expected = {
         "51": {
             "description": "TV",
             "product_type": "Electric",
             "quantity_available": "4"
         },
         "325": {
             "description": "Laptop",
             "product_type": "Electric",
             "quantity_available": "112"
         },
         "223": {
             "description": "Table",
             "product_type": "Furniture",
             "quantity_available": "25"
         },
         "999": {
             "description": "Couch",
             "product_type": "Furniture",
             "quantity_available": "15"
         }
     }
     self.assertEqual(actual.show_available_products(), expected)
コード例 #5
0
def auto_train():
	clear_database()
	spams = []
	hams  = []
	add_files_in_list("corpus/spam.list", spams)
	add_files_in_list("corpus/ham.list", hams)
	train_from_corpus(spams, "spam")
	train_from_corpus(hams, "ham")
コード例 #6
0
ファイル: main.py プロジェクト: cobanov/duvar-app
def wipe():
    if request.method == "POST":
        password = request.form.get("password")
        if password == token:
            database.clear_database()
            flash("Silme İşlemi Başarılı")
            return redirect(url_for('home'))

    return render_template("wipe.html")
コード例 #7
0
def wipe():
    if request.method == "POST":
        password = request.form.get("password")
        if password == token:
            database.clear_database()
            return render_template("home.html",
                                   entries=database.retrieve_entries())

    return render_template("wipe.html")
コード例 #8
0
    def test_clear_database(self):
        """Tests if all data will be removed from HP Norton database."""

        database.clear_database()

        test = database.show_rentals()
        expected = {}

        self.assertEqual(test, expected)
コード例 #9
0
def clean_database(request):
    """ Clears database between each test """
    # Clears the local instance of the database.
    database.clear_database()

    # Clears the flask instance of the database if this
    # is a server test.
    module_prefix = str(request.module.__name__).split('_')
    if module_prefix[0] == "server":
        clear_request = urllib.request.Request(f"{URL}/workspace/reset",
                                               method="POST")
        urllib.request.urlopen(clear_request)
コード例 #10
0
    def test_import_data(self):
        """Tests the function for importing data"""

        database.clear_database()
        real = database.import_data('', 'test_files/products_test.csv',
                                    'test_files/customers_test.csv',
                                    'test_files/rentals_test.csv')
        expected = (4, 5, 4), (0, 0, 0)
        self.assertEqual(real, expected)

        real_negative = database.import_data('', 'test_files/madeup.csv',
                                             'test_files/doesntexist.csv',
                                             'test_files/fakefile.csv')
        expected_negative = (0, 0, 0), (1, 1, 1)
        self.assertEqual(real_negative, expected_negative)
コード例 #11
0
 def test_show_rentals(self):
     """Testing show rentals"""
     db.clear_database()
     actual = db
     actual.import_data("csv_files", "products.csv", "customers.csv",
                        "rentals.csv")
     expected = {
         "200": {
             "name": "Iron Man",
             "address": "17801 International Blvd, Seattle, WA 98101",
             "phone_number": "206-787-5388",
             "email": "*****@*****.**"
         },
         "300": {
             "name": "Ramkumar Rajanbabu",
             "address": "7525 166th Ave NE, Redmond, WA 98052",
             "phone_number": "425-556-2900",
             "email": "*****@*****.**"
         }
     }
     self.assertEqual(actual.show_rentals("999"), expected)
コード例 #12
0
    def test_show_rentals(self):
        """Tests displaying rentals of certain product ID"""
        database.clear_database()
        database.import_data('', 'test_files/products_test.csv',
                             'test_files/customers_test.csv',
                             'test_files/rentals_test.csv')

        real = database.show_rentals('Couch')
        expected = {
            '123': {
                'name': 'Luke Skywalker',
                'address': 'Tattooine',
                'phone': '1234567890',
                'email': '*****@*****.**'
            },
            '234': {
                'name': 'Sherlock Holmes',
                'address': 'London',
                'phone': '9857493647',
                'email': '*****@*****.**'
            }
        }
        self.assertEqual(real, expected)
コード例 #13
0
def workspace_reset():
    """
    Reset the database
    """
    database.clear_database()
    return dumps({})
コード例 #14
0
 def test_clear_database(self):
     """Test that clear_database empties database."""
     database.clear_database()
     available_products = database.show_available_products()
     self.assertEqual({}, available_products)