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()
 def setUp(self):
     self.factory = APIRequestFactory()
     self.user1 = UserFactory()
     self.user2 = UserFactory()
     TransactionFactory(
         wallet_source=self.user1.wallet,
         wallet_dest=self.user2.wallet
     )
    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',
        )
    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()
 def setUp(self):
     self.users = UserFactory.create_batch(size=2)
     self.factory = APIRequestFactory()
     self.client = APIClient()
     token = Token(user=self.users[0])
     token.save()
     self.client.credentials(HTTP_AUTHORIZATION='Token ' + token.key)
Exemple #6
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)