Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
Continuing my investigation I got the a following which does not work but should: from django.contrib.auth.models import User from django.test import TransactionTestCase from django.db import transaction class FooTest(TransactionTestCase): def test_bar(self): with transaction.atomic

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
The documentation states that "you cannot test that a block of code is executing within a transaction" while I am looking to "test a block of code that has a transaction". In any case, the issue here is that "transaction.atomic" does not work when neste

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
tials() > > I am testing that my permission routines work by creating a user, > assigning permissions to the user, retrieving the view and analyzing it. > That "assign_role" call of django-role-permissions uses > "transaction.atomic". Which, of c

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
ot; call of django-role-permissions uses "transaction.atomic". Which, of course, I would not want to change, as this is an external library. So I can't really remove usages of "transaction.atomic" On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:

Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
there must be many django app code that has `transaction.atomic` inside it, I never need to add `transaction.atomic` in my unit test code. If I need to simulate initial state by having some data inserted to database, I did that either using factoryboy or django ORM framework, but I see no point

Re: TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Uri Kogan
While this can be done in my code, there are libraries that the project use that have "transaction.atomic" in them. For example, pretty popular django-role-permissions. >From what I see in the documentation, there should be no problem to use transactions within transaction

Re: TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Aldian Fazrihady
I don't think the subclass of TestCase need to use transaction.atomic. Why can't you just remove the transaction.atomic? Regards, Aldian Fazrihady http://aldianfazrihady.com Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan menulis: > Hello, > > I am using TestCase and trying to create

TestCase failing when using transaction.atomic() inside test

2020-05-11 Thread Uri Kogan
Hello, I am using TestCase and trying to create an object during test. There is a log activated on MySQL server, so I see all the queries being executed there. This "transaction.atomic" sets a SAVEPOINT in the database thinking that the transaction is already started. T

Re: Transaction.atomic()

2019-09-23 Thread Jani Tiainen
And TL;DR; versio. Code which is wrapped within atomic transaction will guarantee that if code breaks changes are rolled back. ma 23. syysk. 2019 klo 15.42 Aryan Patel kirjoitti: > Hi colleagues, > > I want to understand if transaction.atomic() in django guarantees that the > clien

Re: Transaction.atomic()

2019-09-23 Thread Jason
no, atomic transactions are just for the database. It has nothing to do with a client, just the integrity of a data commit. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it,

Transaction.atomic()

2019-09-23 Thread Aryan Patel
Hi colleagues, I want to understand if transaction.atomic() in django guarantees that the client is getting status what the django is sending? This question is just for discussion whether the django builds a pipeline with the client and if the network broke down while the django is sending

Django @transaction.atomic() to prevent creating objects in concurrency

2018-04-20 Thread Aamu Padi
return attrs else: raise serializers.ValidationError("No seat value provided.") On the view, I am using *@transaction.atomic()* to make sure the ticket/s are created only if all of them are valid, or don't create ANY ticket if not valid. @transaction.atomic(

Re: Catching errors inside transaction.atomic()

2017-06-13 Thread Jani Tiainen
to handle smaller units of transactiond. 13.6.2017 17.52 "Alex Krupp" <alex.kr...@gmail.com> kirjoitti: The Django documentation gives a warning <https://docs.djangoproject.com/en/1.11/topics/db/transactions/#controlling-transactions-explicitly> to avoid catching errors ins

Catching errors inside transaction.atomic()

2017-06-13 Thread Alex Krupp
The Django documentation gives a warning <https://docs.djangoproject.com/en/1.11/topics/db/transactions/#controlling-transactions-explicitly> to avoid catching errors inside transaction.atomic() blocks, and to use nested transactions if you need to do so. But in the case where we have

Re: @transaction.atomic ignored?

2015-06-26 Thread Stephen J. Butler
@transaction.atomic will only look at the default database. Since you're using multiple ones I think you want something like: @transaction.atomic(using=DB1) @transaction.atomic(using=DB2) def process_all(): # On Fri, Jun 26, 2015 at 10:27 AM, Lene Preuss <lene.pre...@gmail.com>

@transaction.atomic ignored?

2015-06-26 Thread Lene Preuss
Hi, I want to write a large number of model instances to DB, in a multi-database setup. The way I am doing this is essentially: @transaction.atomic def process_all(): for record in Model.objects.using(DB1).all(): process_one(record) def process_one(record): do_something_with

Re: Weird issue with transaction.atomic in django 1.6

2014-02-26 Thread tapan pandita
> On Thursday, February 27, 2014 12:13:28 PM UTC+5:30, Anssi Kääriäinen > wrote: >> >> On Wednesday, February 26, 2014 11:58:54 PM UTC+2, tapan pandita wrote: >>> >>> I am using transaction.atomic as a context manager for transactions in >>> django 1.

Re: Weird issue with transaction.atomic in django 1.6

2014-02-26 Thread tapan pandita
gt;> I am using transaction.atomic as a context manager for transactions in >> django 1.6. There is a block of code which I want to be in a transaction >> which has a couple of network calls and some database writes. I am seeing >> very weird behaviour. Every once in while (may

Re: Weird issue with transaction.atomic in django 1.6

2014-02-26 Thread Anssi Kääriäinen
On Wednesday, February 26, 2014 11:58:54 PM UTC+2, tapan pandita wrote: > > I am using transaction.atomic as a context manager for transactions in > django 1.6. There is a block of code which I want to be in a transaction > which has a couple of network calls and some database

Weird issue with transaction.atomic in django 1.6

2014-02-26 Thread tapan pandita
I am using transaction.atomic as a context manager for transactions in django 1.6. There is a block of code which I want to be in a transaction which has a couple of network calls and some database writes. I am seeing very weird behaviour. Every once in while (maybe 1 in 20 times) I have noticed