Best Python code snippet using Kiwi_python
test_forms.py
Source:test_forms.py
...29 'dueDate': ''30 }31 form = TaskForm(data=data)32 self.assertTrue(form.is_valid())33 def test_wrong_date_format(self):34 """Test form for wrong task date format"""35 dueDate = timezone.now()36 data = {37 'task': fake.text()[0:100],38 'dueDate': "Not A Date Format"39 }40 form = TaskForm(data=data)41 self.assertFalse(form.is_valid())42 def test_valid_form(self):43 """Test form for valid task details"""44 dueDate = timezone.now()45 data = {46 'task': fake.text()[0:100],47 'dueDate': dueDate.strftime("%Y-%m-%d %H:%M:%S")48 }49 form = TaskForm(data=data)50 self.assertTrue(form.is_valid())51 52class EventFormTest(TestCase): 53 def test_empty_form(self):54 """Test form for empty data"""55 56 data = {57 'name': '',58 'date': ''59 }60 form = EventForm(data=data)61 self.assertFalse(form.is_valid())62 def test_empty(self):63 """Test form for empty event name"""64 date = timezone.now()65 data = {66 'name': '',67 'date': date.strftime("%Y-%m-%d %H:%M:%S")68 }69 form = EventForm(data=data)70 self.assertFalse(form.is_valid())71 def test_empty_date(self):72 """Test form for empty due date"""73 data = {74 'name': fake.text()[0:100],75 'date': ''76 }77 form = EventForm(data=data)78 self.assertFalse(form.is_valid())79 def test_wrong_date_format(self):80 """Test form for wrong date format"""81 date = timezone.now()82 data = {83 'name': fake.text()[0:100],84 'date': "Not A Date Format"85 }86 form = EventForm(data=data)87 self.assertFalse(form.is_valid())88 def test_valid_form(self):89 """Test form for valid event details"""90 date = timezone.now()91 data = {92 'name': fake.text()[0:100],93 'date': date.strftime("%Y-%m-%d %H:%M:%S")94 }95 form = EventForm(data=data)96 self.assertTrue(form.is_valid())97class NoteFormTest(TestCase):98 def test_empty_form(self):99 """Test form for empty data"""100 data = {101 'noteTitle': '',102 'note': '',103 'date': ''104 }105 form = NoteForm(data=data)106 self.assertFalse(form.is_valid())107 def test_empty_title(self):108 """Test form for empty noteTitle"""109 date = timezone.now()110 data = {111 'noteTitle': '',112 'note': fake.text()[0:100],113 'date': date.strftime("%Y-%m-%d %H:%M:%S")114 }115 form = EventForm(data=data)116 self.assertFalse(form.is_valid())117 def test_empty_note(self):118 """Test form for empty note"""119 date = timezone.now()120 data = {121 'noteTitle': fake.text()[0:100],122 'note': '',123 'date': date.strftime("%Y-%m-%d %H:%M:%S")124 }125 form = NoteForm(data=data)126 self.assertTrue(form.is_valid())127 def test_empty_date(self):128 """Test form for empty date"""129 data = {130 'noteTitle': fake.text()[0:100],131 'note': fake.text()[0:100],132 'date': ''133 }134 form = NoteForm(data=data)135 self.assertTrue(form.is_valid())136 def test_wrong_date_format(self):137 """Test form for wrong date format"""138 data = {139 'noteTitle': fake.text()[0:100],140 'note': fake.text()[0:100],141 'date': "Not A Date Format"142 }143 form = NoteForm(data=data)144 self.assertFalse(form.is_valid())145 def test_valid_form(self):146 """Test form for valid task details"""147 date = timezone.now()148 data = {149 'noteTitle': fake.text()[0:100],150 'note': fake.text()[0:100],...
test_DateValidator.py
Source:test_DateValidator.py
...28 test_string = "1999-01"29 result_string = "1999-01"30 self.assertEqual(DateValidator.extract_date_format(test_string), result_string)3132 def test_wrong_date_format(self):33 test_string = "1999-01-01-"34 result_string = False35 self.assertEqual(DateValidator.extract_date_format(test_string), result_string)3637
...
tests.py
Source:tests.py
1import unittest2from jpt import get_commission3class TestGetCommission(unittest.TestCase):4 def test_wrong_date_format(self):5 wrong_date = "2001-88-77"6 self.assertEqual(get_commission(wrong_date), "Please enter a valid date")7 def test_high_commission(self):8 high_commission_date = "2001-07-11"9 self.assertEqual(get_commission(high_commission_date), 15.0)10 def test_low_commission(self):11 low_commission_date = "2001-03-11"...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!