def test_FindUpdatedPackageReturnsSamePackage(self): packageRepository = PackageRepository() packageRepository.Insert( PackageObjectMother.CreatePackageNoPickupsNoReturn()) packageRepository.Insert( PackageObjectMother.CreatePackageManyPickupNoReturn()) packageRepository.Insert( PackageObjectMother.CreatePackageManyPickupPackedNoReturn()) packageRepository.Insert( PackageObjectMother.CreateDeliveredPackageManyPickupPackedNoReturn( )) packageRepository.Insert( PackageObjectMother.CreatePackageManyPickupPackedUnconfirmedReturn( )) packageRepository.Insert( PackageObjectMother.CreatePackageManyPickupPackedConfirmedReturn()) packages = packageRepository.FindAll() package = packages[0] package.DeliveryDate = datetime(2018, 12, 30) package.GetStatus().NextDeliveryStep() return_ = package.GetReturn() if not return_: package.MakeReturn("Sample text") else: return_.Description = "Sample text" packageRepository.Update(package) packageAfterInsert = packageRepository.Find(package.PackageCode) assert packageAfterInsert.PackageCode == package.PackageCode assert packageAfterInsert.DeliveryDate == datetime(2018, 12, 30).date() assert packageAfterInsert.GetReturn().Description == "Sample text"
def test_GetAllReturnsProperlyPullsOutAllReturns(self): adminService = AdminService() packages = \ [PackageObjectMother.CreatePackageManyPickupNoReturn(), PackageObjectMother.CreatePackageManyPickupNoReturn(), PackageObjectMother.CreatePackageManyPickupPackedNoReturn(), PackageObjectMother.CreatePackageManyPickupPackedNoReturn(), PackageObjectMother.CreatePackageManyPickupPackedUnconfirmedReturn(), PackageObjectMother.CreatePackageManyPickupPackedUnconfirmedReturn(), PackageObjectMother.CreateDeliveredPackageManyPickupPackedNoReturn(), PackageObjectMother.CreateDeliveredPackageManyPickupPackedNoReturn() ] packageReturns = [package.GetReturn() for package in packages] with patch.object(PackageRepository, 'FindAll', return_value=packages): servicePackageReturns = adminService.GetAllReturns() for return_ in servicePackageReturns: assert return_ in packageReturns
def test_UpdateReturnUseProperRepositoryMethod(self): adminService = AdminService() package = PackageObjectMother.CreatePackageManyPickupPackedUnconfirmedReturn( ) return_ = package.GetReturn() with patch.object(PackageRepository, 'Update'): adminService.UpdateReturn(package, return_) PackageRepository.Update.assert_called_with(package)
def test_CreateAllObjectsFromObjectMother(self): p = PackageObjectMother.CreatePackageNoPickupsNoReturn() p = PackageObjectMother.CreatePackageManyPickupNoReturn() p = PackageObjectMother.CreatePackageManyPickupPackedNoReturn() p = PackageObjectMother.CreateDeliveredPackageManyPickupPackedNoReturn( ) p = PackageObjectMother.CreatePackageManyPickupPackedUnconfirmedReturn( ) p = PackageObjectMother.CreatePackageManyPickupPackedConfirmedReturn() p = PackageObjectMother.CreateUnpackedPickups() p = PackageObjectMother.CreatePackedPickups() p = PackageObjectMother.CreateUnconfirmedReturn() p = PackageObjectMother.CreateConfirmedReturn()