Exemplo n.º 1
0
    def test_GetAllLimitedPackages(self):
        with patch.object(
                PackageRepository,
                'Find',
                return_value=[
                    PackageObjectMother.CreatePackageManyPickupNoReturn(),
                    PackageObjectMother.CreatePackageManyPickupNoReturn(),
                    PackageObjectMother.CreatePackageManyPickupPackedNoReturn(
                    ),
                    PackageObjectMother.CreatePackageManyPickupPackedNoReturn(
                    ),
                    PackageObjectMother.
                    CreatePackageManyPickupPackedUnconfirmedReturn(),
                    PackageObjectMother.
                    CreatePackageManyPickupPackedUnconfirmedReturn(),
                    PackageObjectMother.
                    CreateDeliveredPackageManyPickupPackedNoReturn(),
                    PackageObjectMother.
                    CreateDeliveredPackageManyPickupPackedNoReturn(),
                ]):
            transportService = TransportService()
            statuses_obj = Package.FindAllLimitedPackageStatuses()
            statuses = [status.Name for status in statuses_obj]

            packages = transportService.GetAllLimitedPackages()

            for package in packages:
                self.assertIn(package.GetStatus().Name, statuses)
Exemplo n.º 2
0
    def test_GettingLimitedPackagesRepoReturnsStatusValidPackages(self):
        transportService = TransportService()
        statuses = Package.FindAllLimitedPackageStatuses()
        package = PackageObjectMother.CreatePackageNoPickupsNoReturn()

        for status in statuses:
            package.GetStatus().Name = status.Name
            with patch.object(PackageRepository, 'Find', return_value=package):
                self.assertEqual(package,
                                 transportService.GetLimitedPackage(32423))
Exemplo n.º 3
0
 def GetLimitedPackage(self, package_code):
     package = self.packageRepository.Find(package_code)
     if not package:
         return None
     valid_statuses_obj = Package.FindAllLimitedPackageStatuses()
     valid_statuses = []
     for status_obj in valid_statuses_obj:
         valid_statuses.append(status_obj.Name)
     if package.GetStatus().Name in valid_statuses:
         return package
     return None
Exemplo n.º 4
0
 def GetAllLimitedPackages(self):
     packages = self.packageRepository.FindAll()
     valid_statuses_obj = Package.FindAllLimitedPackageStatuses()
     valid_statuses = []
     for status_obj in valid_statuses_obj:
         valid_statuses.append(status_obj.Name)
     matched = []
     for package in packages:
         if package.GetStatus().Name in valid_statuses:
             matched.append(package)
     return matched
Exemplo n.º 5
0
    def test_GetLimitedPackageStatusesReturnsValidSortedStatuses(self):
        transportService = TransportService()
        validStatuses = Package.FindAllLimitedPackageStatuses()
        validStatusNames = [status.Name for status in validStatuses]

        statuses = transportService.GetLimitedPackageSatuses()

        for status in statuses:
            self.assertIn(status.Name, validStatusNames)
        for i in range(len(statuses) - 1):
            self.assertLess(statuses[i].DeliveryStep,
                            statuses[i + 1].DeliveryStep)
Exemplo n.º 6
0
 def GetLimitedPackageSatuses(self):
     return Package.FindAllLimitedPackageStatuses()