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(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.º 3
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)