How to use test_deleted method in pytest-django

Best Python code snippet using pytest-django_python

test_bakthat_swift.py

Source:test_bakthat_swift.py Github

copy

Full Screen

1# -*- encoding: utf-8 -*-2import bakthat3import tempfile4import hashlib5import os6import time7import unittest8import logging9log = logging.getLogger()10handler = logging.StreamHandler()11handler.setLevel(logging.DEBUG)12handler.addFilter(bakthat.BakthatFilter())13handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))14log.addHandler(handler)15log.setLevel(logging.DEBUG)16class BakthatSwiftBackendTestCase(unittest.TestCase):17 """This test cases use profile test_swift """18 def setUp(self):19 self.test_file = tempfile.NamedTemporaryFile()20 self.test_file.write("Bakthat Test File")21 self.test_file.seek(0)22 self.test_filename = self.test_file.name.split("/")[-1]23 self.test_hash = hashlib.sha1(self.test_file.read()).hexdigest()24 self.password = "bakthat_encrypted_test"25 self.test_profile = "test_swift"26 def test_swift_backup_restore(self):27 backup_data = bakthat.backup(self.test_file.name, "swift", password="",28 profile=self.test_profile)29 log.info(backup_data)30 #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",31 # profile=self.test_profile32 # )[0]["filename"],33 # self.test_filename)34 bakthat.restore(self.test_filename, "swift", profile=self.test_profile)35 restored_hash = hashlib.sha1(36 open(self.test_filename).read()).hexdigest()37 self.assertEqual(self.test_hash, restored_hash)38 os.remove(self.test_filename)39 bakthat.delete(backup_data["stored_filename"], "swift", profile=self.test_profile)40 #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",41 # profile=self.test_profile), [])42 def test_swift_delete_older_than(self):43 backup_res = bakthat.backup(self.test_file.name, "swift", password="",44 profile=self.test_profile)45 #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",46 # profile=self.test_profile47 # )[0]["filename"],48 # self.test_filename)49 bakthat.restore(self.test_filename, "swift",50 profile=self.test_profile)51 restored_hash = hashlib.sha1(52 open(self.test_filename).read()).hexdigest()53 self.assertEqual(self.test_hash, restored_hash)54 os.remove(self.test_filename)55 test_deleted = bakthat.delete_older_than(self.test_filename, "1Y",56 "swift",57 profile=self.test_profile)58 self.assertEqual(test_deleted, [])59 time.sleep(10)60 test_deleted = bakthat.delete_older_than(self.test_filename, "9s",61 "swift",62 profile=self.test_profile)63 key_deleted = test_deleted[0]64 self.assertEqual(key_deleted, backup_res["stored_filename"])65 #self.assertEqual(bakthat.match_filename(self.test_filename,66 # "swift",67 # profile=self.test_profile),68 # [])69 def test_swift_encrypted_backup_restore(self):70 backup_data = bakthat.backup(self.test_file.name, "swift", password=self.password,71 profile=self.test_profile)72 #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",73 # profile=self.test_profile)74 # [0]["filename"], self.test_filename)75 # Check if stored file is encrypted76 #self.assertTrue(bakthat.match_filename(self.test_filename, "swift",77 # profile=self.test_profile)78 # [0]["is_enc"])79 bakthat.restore(self.test_filename, "swift", password=self.password,80 profile=self.test_profile)81 restored_hash = hashlib.sha1(82 open(self.test_filename).read()).hexdigest()83 self.assertEqual(self.test_hash, restored_hash)84 os.remove(self.test_filename)85 bakthat.delete(backup_data["stored_filename"], "swift",86 profile=self.test_profile)87 #self.assertEqual(bakthat.match_filename(self.test_filename,88 # "swift",89 # profile=self.test_profile),90 # [])91if __name__ == '__main__':...

Full Screen

Full Screen

test_dao.py

Source:test_dao.py Github

copy

Full Screen

1import datetime2from test.base import BaseTestCase3from test.brac import BRACTestCase, brac_scope4from app.kits import model5from app.kits import dao6class TestKitDAOTestCase(BRACTestCase):7 def setUp(self):8 super(TestKitDAOTestCase, self).setUp()9 self.dao = dao.kit_dao10 self.kit_dao = dao.kit_type_dao11 def test_create(self):12 with brac_scope({'Kit':'CRUD'}):13 kit_type = model.KitType(name = 'Test',14 description='Kit Type for Unit Tests',15 welcome_screen='<h1>Welcome</h1>',16 finish_screen='<h1>By</h1>')17 self.kit_dao.create(kit_type)18 kit = model.Kit(owner_id='0000',19 registered=datetime.datetime.now(),20 barcode='123456789',21 kit_type = kit_type)22 kit_saved = self.dao.create(kit)23 self.assertIsNotNone(kit_saved.id)24 # Retrieve25 kit_retieved = self.dao.retrieve(kit_saved.id)26 self.assertIsNotNone(kit_retieved)27 self.assertEqual(kit_retieved, kit_saved)28 # Delete29 test_deleted = self.dao.delete(kit_retieved)30 self.assertIsNotNone(test_deleted)31 self.kit_dao.delete(kit_type)32class TestKitTypeDAO(BaseTestCase):33 def setUp(self):34 super(TestKitTypeDAO, self).setUp()35 self.dao = dao.kit_type_dao36 def test_create(self):37 kit_type = model.KitType(name = 'Test',38 description='Kit Type for Unit Tests',39 welcome_screen='<h1>Welcome</h1>',40 finish_screen='<h1>By</h1>')41 kit_saved = self.dao.create(kit_type)42 self.assertIsNotNone(kit_saved.id)43 # Retrieve44 kit_type_retieved = self.dao.retrieve(kit_saved.id)45 self.assertIsNotNone(kit_type_retieved)46 self.assertEqual(kit_type_retieved, kit_saved)47 # Delete48 test_deleted = self.dao.delete(kit_type_retieved)...

Full Screen

Full Screen

recognition.py

Source:recognition.py Github

copy

Full Screen

1import re2from typing import Dict3class NameRecognizer(object):4 def __init__(self, name_parser):5 self.parser = name_parser6 def __call__(self, text) -> Dict:7 text_cleaned, text_deleted = self.clear_data(text)8 model = {}9 _text = list(text_cleaned)10 for name in self.parser.findall(text_cleaned):11 name = name.fact12 for span in reversed(name.spans):13 del _text[span.start:span.stop]14 is_all_recognized = not (bool(''.join(_text).strip()) and text_deleted)15 return {16 'last': name.last,17 'first': name.first,18 'middle': name.middle,19 'is_all_recognized': is_all_recognized,20 }21 return model22 def clear_data(self, text):23 test_deleted = []24 searches = re.findall('\([^()]*\)', text)25 start = 026 for search in searches:27 start_index = text.index(search, start)28 start = start_index + len(search)29 test_deleted.append(30 {31 'start': start_index,32 'end': start_index + len(search) - 1,33 }34 )35 for search in searches:36 text = text.replace(search, '', 1)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-django automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful