def handle(self, *args, **kwargs):
        UserFactory.create_batch(size=10)
        # CategoryFactory.create_batch(size=20)

        Category.objects.all().delete()
        for i in range(len(categories)):
            CategoryFactory(name=categories[i], name_es=categories[i],order=i)
        ServiceFactory.create_batch(size=50)

        # Create transactions
        count = Wallet.objects.count()
        random_index = randint(0, count - 1)
        for wallet in Wallet.objects.all():
            for i in range(4):
                random_index = randint(0, count - 2)
                dst_wallet = Wallet.objects.exclude(id=wallet.id)[random_index]
                val=randint(1, 2)
                new_transaction = Transaction.objects.create(
                    value=val,
                    wallet_dest=dst_wallet,
                    wallet_source=wallet,
                    balance_dest=dst_wallet.balance + val,
                    balance_source=wallet.balance - val,
                )
                new_transaction.save()
                wallet.balance-=val
                wallet.save()
                dst_wallet.balance+=val
                dst_wallet.save()
Ejemplo n.º 2
0
 def setUp(self):
     # call BaseServiceTestCase.setUp()
     super(TestServiceDelete, self).setUp()
     self.service = ServiceFactory(
         category=Category.objects.first(),
         author=self.users[0],
         title='1',
     )
Ejemplo n.º 3
0
class TestServiceDelete(BaseServiceTestCase):
    def setUp(self):
        # call BaseServiceTestCase.setUp()
        super(TestServiceDelete, self).setUp()
        self.service = ServiceFactory(
            category=Category.objects.first(),
            author=self.users[0],
            title='1',
        )

    def test_owner_deletes_service(self):
        """ This tests ask for all the services of a user
        """
        # Generate a request search for "testing" key word

        response = self.client.delete(
            reverse('api_service:delete',
                    kwargs={'uuid': str(self.service.uuid)}), )

        # Expect: expect queryset of services ordered by proximity
        #   self.make_user()
        self.assertEqual(response.status_code, 204)

    def test_not_owner_deletes_service(self):
        """ This tests ask for all the services of a user
        """
        # Generate a request search for "testing" key word

        self.service.author = self.users[1]
        self.service.save()

        response = self.client.delete(
            reverse('api_service:delete',
                    kwargs={'uuid': str(self.service.uuid)}), )

        # Expect: expect queryset of services ordered by proximity
        #   self.make_user()
        self.assertEqual(response.status_code, 404)

    def test_staff_deletes_service(self):
        """ This tests ask for all the services of a user
        """
        # Generate a request search for "testing" key word

        self.service.author = self.users[1]
        self.service.save()

        self.users[0].is_staff = True
        self.users[0].save()

        response = self.client.delete(
            reverse('api_service:delete',
                    kwargs={'uuid': str(self.service.uuid)}), )

        # Expect: expect queryset of services ordered by proximity
        #   self.make_user()
        self.assertEqual(response.status_code, 204)
Ejemplo n.º 4
0
    def setUp(self):
        # call BaseServiceTestCase.setUp()
        super(TestFeedServiceList, self).setUp()

        # Instantiate the view directly. Never do this outside a test!
        self.view = FeedServiceList()

        # Create self.users, Services & Categories for test cases
        self.users = UserFactory.create_batch(size=5)
        self.services = ServiceFactory.create_batch(
            size=5, category=Category.objects.first())

        # Assign each service to 1 of the self.users
        self.services[0].author = self.users[0]
        self.services[0].title = "1"
        self.services[0].description = "testing"
        self.services[0].save()
        self.services[1].author = self.users[1]
        self.services[1].title = "2"
        self.services[1].description = "testing"
        self.services[1].save()
        self.services[2].author = self.users[2]
        self.services[2].title = "3"
        self.services[2].description = "testing"
        self.services[2].save()
        self.services[3].author = self.users[3]
        self.services[3].title = "4"
        self.services[3].description = "testing"
        self.services[3].save()
        self.services[4].author = self.users[4]
        self.services[4].title = "5"
        self.services[4].description = "testing"
        self.services[4].save()
Ejemplo n.º 5
0
    def test_service_detail_with_no_photos(self):
        serv= ServiceFactory(
            category=Category.objects.first(),
            author=self.owner,
            title='1',
        )
        serv.photos.all().delete()

        photos = ServiceSerializer(serv).data['photos']
        self.assertEqual(
            photos[0]['photo'],
            '/media/' + settings.SERVICE_PLACEHOLDER_PHOTO
        )
Ejemplo n.º 6
0
    def setUp(self):
        # call BaseServiceTestCase.setUp()
        super(TestServiceDetail, self).setUp()

        location_madrid = Point(-3.8196228, 40.4378698) # Madrid 0
        location_paris = Point(2.3488, 48.8534) # Paris 1

        # Create self.users, Services & Categories for test cases
        self.user = UserFactory(location=location_madrid)
        self.owner= UserFactory(location=location_paris)
        self.service = ServiceFactory(
            category=Category.objects.first(),
            author=self.owner,
            title='1',
        )
Ejemplo n.º 7
0
 def handle(self, *args, **kwargs):
     UserFactory.create_batch(size=10)
     #        CategoryFactory.create_batch(size=20)
     for i in range(len(categories)):
         CategoryFactory(name=categories[i], order=i)
     ServiceFactory.create_batch(size=50)