Exemple #1
0
    def test_ChangePackageStatusForwardAndBackward(self):
        package = PackageObjectMother.CreatePackageNoPickupsNoReturn()
        package2 = PackageObjectMother.CreatePackageNoPickupsNoReturn()
        statuses = Package.FindAllPackageStatuses()
        statusNames = [status.Name for status in statuses]

        for i in range(10):
            for j in range(i):
                package.GetStatus().NextDeliveryStep()
            assert package.GetStatus().Name in statusNames
            for j in range(i):
                package.GetStatus().PrevDeliveryStep()
            assert package.GetStatus().Name == package2.GetStatus().Name
Exemple #2
0
    def test_ChangingPackageStatuses(self):
        # DeliveryStep = 0, first status
        package = PackageObjectMother.CreatePackageNoPickupsNoReturn()
        package2 = PackageObjectMother.CreatePackageNoPickupsNoReturn()
        statuses = Package.FindAllPackageStatuses()

        for status in statuses:
            package.GetStatus().Name = status.Name
            self.assertEqual(package.GetStatus().Name,
                             package2.GetStatus().Name)
            self.assertEqual(package.GetStatus().DeliveryStep,
                             package2.GetStatus().DeliveryStep)
            package2.GetStatus().NextDeliveryStep()
Exemple #3
0
    def test_UniquePackageCodes(self):
        packages = []
        for i in range(1000):
            packages.append(
                PackageObjectMother.CreatePackageNoPickupsNoReturn())

        self.assertEqual(len(packages), len(set(packages)))
Exemple #4
0
    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"
Exemple #5
0
    def test_AddPickupsCheckNotPacked(self):
        package = PackageObjectMother.CreatePackageNoPickupsNoReturn()

        package.AddDeliveryProduct("Pan Tadeusz", 1)
        package.AddDeliveryProduct("Biblia", 3)
        package.AddDeliveryProduct(".net oczami developera", 1)

        pickups = package.GetPackageProducts()
        for pickup in pickups:
            self.assertEqual(pickup.IsPacked, False)
Exemple #6
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))
Exemple #7
0
 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()
Exemple #8
0
    def test_AllDeliveryStepsDuringSuccessfulDelivery(self):
        package = PackageObjectMother.CreatePackageNoPickupsNoReturn()

        package.AddDeliveryProduct("Pan Tadeusz", 1)
        package.AddDeliveryProduct("Biblia", 3)
        package.AddDeliveryProduct(".net oczami developera", 1)
        package.GetStatus().NextDeliveryStep()
        package.MarkPackedProduct("Pan Tadeusz")
        package.MarkPackedProduct("Biblia")
        package.MarkPackedProduct(".net oczami developera")
        package.GetStatus().NextDeliveryStep()
        # Status == Dostarczone
        package.GetStatus().NextDeliveryStep()
        package.DeliveryDate = datetime.now()

        self.assertEqual(package.GetReturn(), None)
        self.assertEqual(package.GetStatus().Name, DELIVERY_SUCCESS_STATUS)
        self.assertEqual(package.DeliveryDate.date(), datetime.now().date())