def setUp(self): # Create and register a temporary database for use with our test instance of Silvr self.database_file_descriptor, silvr.app.config["DATABASE"] = tempfile.mkstemp() # Set the app to be in TESTING mode, preventing catching of errors so we get better data on them silvr.app.config["TESTING"] = True # Create and give ourselves a test_client self.app = silvr.app.test_client() # Now, init the database. This is safe because the DATABASE config key is now pointing to a temporary DB silvr.init_db() # Now look up and remember out creds self.username = silvr.app.config["USERNAME"] self.password = silvr.app.config["PASSWORD"]
def setUp(self): # Create and register a temporary database for use with our test instance of Silvr self.database_file_descriptor, silvr.app.config[ 'DATABASE'] = tempfile.mkstemp() # Set the app to be in TESTING mode, preventing catching of errors so we get better data on them silvr.app.config['TESTING'] = True # Create and give ourselves a test_client self.app = silvr.app.test_client() # Now, init the database. This is safe because the DATABASE config key is now pointing to a temporary DB silvr.init_db() # Now look up and remember out creds self.username = silvr.app.config['USERNAME'] self.password = silvr.app.config['PASSWORD']
def test_entries_delete(self): """ Ensure that deleting a post deletes the post :return: """ silvr.init_db() # Clear the database # Login and make a new post self.login(self.username, self.password) self.new_entry('DeleteMe', 'Text', category='Category') # Try to delete the post rv = self.app.get('/del/1') # Now logout AFTER deletion self.logout() rv = self.app.get('/') assert "DeleteMe" not in str(rv.data) # The post isn't still there
def test_entries_delete(self): """ Ensure that deleting a post deletes the post :return: """ silvr.init_db() # Clear the database # Login and make a new post self.login(self.username, self.password) self.new_entry("DeleteMe", "Text", category="Category") # Try to delete the post rv = self.app.get("/del/1") # Now logout AFTER deletion self.logout() rv = self.app.get("/") assert "DeleteMe" not in str(rv.data) # The post isn't still there
def test_entries_delete_requires_login(self): """ Ensure that deleting a post requires login :return: """ silvr.init_db() # Clear the database # Login and make a new post self.login(self.username, self.password) self.new_entry("DeleteMe", "Text", category="Category") # Now logout BEFORE deletion self.logout() rv = self.app.get("/del/1") assert "Unauthorized" in str(rv.data) # We were rejected when trying to delete the post rv = self.app.get("/") assert "DeleteMe" in str(rv.data) # The post is still there
def test_entries_delete_requires_login(self): """ Ensure that deleting a post requires login :return: """ silvr.init_db() # Clear the database # Login and make a new post self.login(self.username, self.password) self.new_entry('DeleteMe', 'Text', category='Category') # Now logout BEFORE deletion self.logout() rv = self.app.get('/del/1') assert "Unauthorized" in str( rv.data) # We were rejected when trying to delete the post rv = self.app.get('/') assert "DeleteMe" in str(rv.data) # The post is still there