mirror of
				https://github.com/enpaul/peewee-plus.git
				synced 2025-11-04 09:16:47 +00:00 
			
		
		
		
	Add tests for timedelta field
This commit is contained in:
		
							
								
								
									
										31
									
								
								tests/test_timedelta_field.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								tests/test_timedelta_field.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					# pylint: disable=redefined-outer-name
 | 
				
			||||||
 | 
					# pylint: disable=missing-class-docstring
 | 
				
			||||||
 | 
					# pylint: disable=too-few-public-methods
 | 
				
			||||||
 | 
					# pylint: disable=unused-import
 | 
				
			||||||
 | 
					import datetime
 | 
				
			||||||
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import peewee
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import peewee_plus
 | 
				
			||||||
 | 
					from .fixtures import fakedb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def test_conversion(fakedb):
 | 
				
			||||||
 | 
					    """Test basic usage of PathField for roundtrip compatibility"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class TestModel(peewee.Model):
 | 
				
			||||||
 | 
					        class Meta:
 | 
				
			||||||
 | 
					            database = fakedb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        name = peewee.CharField()
 | 
				
			||||||
 | 
					        some_timedelta = peewee_plus.TimedeltaField()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fakedb.create_tables([TestModel])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delta = datetime.timedelta(seconds=300)
 | 
				
			||||||
 | 
					    model = TestModel(name="one", some_timedelta=delta)
 | 
				
			||||||
 | 
					    model.save()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    new = TestModel.get(TestModel.name == "one")
 | 
				
			||||||
 | 
					    assert new.some_timedelta == delta
 | 
				
			||||||
		Reference in New Issue
	
	Block a user