Re: Creating my first test case, failing.

2024-03-27 Thread Muhammad Juwaini Abdul Rahman
Obviously. You need to know how your routers generate the URL endpoint.

After reading DRF, my best guess would be either 'courses-list' or 
'course-list'.

On Tuesday 26 March 2024 at 19:33:07 UTC+8 Filbert wrote:

> *sigh* same error:
> django.urls.exceptions.NoReverseMatch: Reverse for* 'courses-create' *not 
> found. 'courses-create' is not a valid view function or pattern name.
>
> On Tuesday, March 26, 2024 at 7:28:45 AM UTC-4 Muhammad Juwaini Abdul 
> Rahman wrote:
>
>> It's not reverse('courses') alone. Probably reverse('courses-create') or 
>> something like that.
>>
>> On Tue, 26 Mar 2024 at 18:55, Filbert  wrote:
>>
>>> Consider this what seems to be a simple Django/DRF API which works:
>>>
>>> class CourseViewSet(viewsets.ModelViewSet):
>>>   queryset = Course.objects.all()
>>>   serializer_class = CourseSerializer
>>>
>>> router = DefaultRouter()
>>> router.register(r'courses', CourseViewSet)
>>>
>>> urlpatterns = [
>>>path('', include(router.urls)),
>>> ]
>>>
>>> POST to: *http://localhost:9000/courses/ 
>>> * works from cURL
>>>
>>> But this code:
>>> class CourseAPITest(TestCase):
>>>   def setUp(self):
>>> self.client = APIClient()
>>> self.course_data = {'description': 'course number 1', 'name': 'intro 
>>> to something'}
>>> self.response = self.client.post(reverse('courses'),  
>>> self.course_data, 
>>> format='json')
>>>
>>> Gives me the error:
>>>
>>> *django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found. 
>>> 'courses' is not a valid view function or pattern name.*
>>>
>>> -- 
>>> 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, send 
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b46d66f-d08b-4f6f-ba41-8204126d49b3n%40googlegroups.com.


Re: Creating my first test case, failing.

2024-03-26 Thread Bayodele Oguntomiloye
Check your url. This error usually show up when  there's no url with the
name provided for the reverse function

On Tue, Mar 26, 2024, 11:55 AM Filbert  wrote:

> Consider this what seems to be a simple Django/DRF API which works:
>
> class CourseViewSet(viewsets.ModelViewSet):
>   queryset = Course.objects.all()
>   serializer_class = CourseSerializer
>
> router = DefaultRouter()
> router.register(r'courses', CourseViewSet)
>
> urlpatterns = [
>path('', include(router.urls)),
> ]
>
> POST to: *http://localhost:9000/courses/ *
> works from cURL
>
> But this code:
> class CourseAPITest(TestCase):
>   def setUp(self):
> self.client = APIClient()
> self.course_data = {'description': 'course number 1', 'name': 'intro
> to something'}
> self.response = self.client.post(reverse('courses'),  
> self.course_data,
> format='json')
>
> Gives me the error:
>
> *django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found.
> 'courses' is not a valid view function or pattern name.*
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com
> 
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACABt6T%2BpX5_OnWh_mmBvtwHUV%3DisZPsJdmS%2Bes2aZpOssWPhQ%40mail.gmail.com.


Re: Creating my first test case, failing.

2024-03-26 Thread Gajanan Kathar
Use "basename" parameter while registering router.

router.register(r'courses', CourseViewSet, basename="courses")

And then reverse using this basename and operation like "courses-list".

On Tue, 26 Mar, 2024, 17:03 Filbert,  wrote:

> *sigh* same error:
> django.urls.exceptions.NoReverseMatch: Reverse for* 'courses-create' *not
> found. 'courses-create' is not a valid view function or pattern name.
>
> On Tuesday, March 26, 2024 at 7:28:45 AM UTC-4 Muhammad Juwaini Abdul
> Rahman wrote:
>
>> It's not reverse('courses') alone. Probably reverse('courses-create') or
>> something like that.
>>
>> On Tue, 26 Mar 2024 at 18:55, Filbert  wrote:
>>
>>> Consider this what seems to be a simple Django/DRF API which works:
>>>
>>> class CourseViewSet(viewsets.ModelViewSet):
>>>   queryset = Course.objects.all()
>>>   serializer_class = CourseSerializer
>>>
>>> router = DefaultRouter()
>>> router.register(r'courses', CourseViewSet)
>>>
>>> urlpatterns = [
>>>path('', include(router.urls)),
>>> ]
>>>
>>> POST to: *http://localhost:9000/courses/
>>> * works from cURL
>>>
>>> But this code:
>>> class CourseAPITest(TestCase):
>>>   def setUp(self):
>>> self.client = APIClient()
>>> self.course_data = {'description': 'course number 1', 'name': 'intro
>>> to something'}
>>> self.response = self.client.post(reverse('courses'),  
>>> self.course_data,
>>> format='json')
>>>
>>> Gives me the error:
>>>
>>> *django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found.
>>> 'courses' is not a valid view function or pattern name.*
>>>
>>> --
>>> 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, send
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6360925a-32c8-41c5-966e-d71aa4161489n%40googlegroups.com
> 
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOLgeEFVyE79A0wUphpBqXMRutD5x57%3DW7bMV0sN-qq6trD2MA%40mail.gmail.com.


Re: Creating my first test case, failing.

2024-03-26 Thread Filbert
*sigh* same error:
django.urls.exceptions.NoReverseMatch: Reverse for* 'courses-create' *not 
found. 'courses-create' is not a valid view function or pattern name.

On Tuesday, March 26, 2024 at 7:28:45 AM UTC-4 Muhammad Juwaini Abdul 
Rahman wrote:

> It's not reverse('courses') alone. Probably reverse('courses-create') or 
> something like that.
>
> On Tue, 26 Mar 2024 at 18:55, Filbert  wrote:
>
>> Consider this what seems to be a simple Django/DRF API which works:
>>
>> class CourseViewSet(viewsets.ModelViewSet):
>>   queryset = Course.objects.all()
>>   serializer_class = CourseSerializer
>>
>> router = DefaultRouter()
>> router.register(r'courses', CourseViewSet)
>>
>> urlpatterns = [
>>path('', include(router.urls)),
>> ]
>>
>> POST to: *http://localhost:9000/courses/ 
>> * works from cURL
>>
>> But this code:
>> class CourseAPITest(TestCase):
>>   def setUp(self):
>> self.client = APIClient()
>> self.course_data = {'description': 'course number 1', 'name': 'intro 
>> to something'}
>> self.response = self.client.post(reverse('courses'),  
>> self.course_data, 
>> format='json')
>>
>> Gives me the error:
>>
>> *django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found. 
>> 'courses' is not a valid view function or pattern name.*
>>
>> -- 
>> 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, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6360925a-32c8-41c5-966e-d71aa4161489n%40googlegroups.com.


Re: Creating my first test case, failing.

2024-03-26 Thread Muhammad Juwaini Abdul Rahman
It's not reverse('courses') alone. Probably reverse('courses-create') or
something like that.

On Tue, 26 Mar 2024 at 18:55, Filbert  wrote:

> Consider this what seems to be a simple Django/DRF API which works:
>
> class CourseViewSet(viewsets.ModelViewSet):
>   queryset = Course.objects.all()
>   serializer_class = CourseSerializer
>
> router = DefaultRouter()
> router.register(r'courses', CourseViewSet)
>
> urlpatterns = [
>path('', include(router.urls)),
> ]
>
> POST to: *http://localhost:9000/courses/ *
> works from cURL
>
> But this code:
> class CourseAPITest(TestCase):
>   def setUp(self):
> self.client = APIClient()
> self.course_data = {'description': 'course number 1', 'name': 'intro
> to something'}
> self.response = self.client.post(reverse('courses'),  
> self.course_data,
> format='json')
>
> Gives me the error:
>
> *django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found.
> 'courses' is not a valid view function or pattern name.*
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com
> 
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFKhtoQZb1G4LDN_X-7nXJ2JMB9e%3Dz909y%3DLtNa%3D6410kmo%3DOA%40mail.gmail.com.


Creating my first test case, failing.

2024-03-26 Thread Filbert
Consider this what seems to be a simple Django/DRF API which works:

class CourseViewSet(viewsets.ModelViewSet):
  queryset = Course.objects.all()
  serializer_class = CourseSerializer

router = DefaultRouter()
router.register(r'courses', CourseViewSet)

urlpatterns = [
   path('', include(router.urls)),
]

POST to: *http://localhost:9000/courses/* works from cURL

But this code:
class CourseAPITest(TestCase):
  def setUp(self):
self.client = APIClient()
self.course_data = {'description': 'course number 1', 'name': 'intro to 
something'}
self.response = self.client.post(reverse('courses'),  
self.course_data, 
format='json')

Gives me the error:

*django.urls.exceptions.NoReverseMatch: Reverse for 'courses' not found. 
'courses' is not a valid view function or pattern name.*

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21615aab-a01a-4a1c-bc79-ed88908cafbbn%40googlegroups.com.


Re: Keeping/accessing the data Django generates during a test run

2023-12-05 Thread Juan diego Jacobo hernandez
Yes thanks

(null)


El El mar, 5 de dic de 2023 a la(s) 13:41, dilo...@gmail.com <
dilou...@gmail.com> escribió:

> HelloI am running into the same problem but I do not understand what needs
> to be done. I use keepdb but how can I get the database cursor connection.
> Do I need to modify the test script?
> Thanks for your help.
>
> Le mercredi 13 février 2019 à 10:54:04 UTC+1, Anton Melser a écrit :
>
>> When you use django unittests commit is made as no-op. Use --keepdb and
>>> at the end of your tests run SQL commit against your database cursor
>>> connection.
>>>
>>
>> Awesome, exactly the info I was missing. Thanks for your help.
>> Cheers,
>> Anton
>>
>
>> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/80b4d9ea-e502-4ac5-8032-81ec0a99f4ffn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/80b4d9ea-e502-4ac5-8032-81ec0a99f4ffn%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE4dRnL6WGQhmp6piJWwQs9EZJsGNK8YR5OCVx_fNCpnT3gC2A%40mail.gmail.com.


Re: Keeping/accessing the data Django generates during a test run

2023-12-05 Thread dilo...@gmail.com
HelloI am running into the same problem but I do not understand what needs 
to be done. I use keepdb but how can I get the database cursor connection. 
Do I need to modify the test script?
Thanks for your help.

Le mercredi 13 février 2019 à 10:54:04 UTC+1, Anton Melser a écrit :

> When you use django unittests commit is made as no-op. Use --keepdb and at 
>> the end of your tests run SQL commit against your database cursor 
>> connection.
>>
>  
> Awesome, exactly the info I was missing. Thanks for your help.
> Cheers,
> Anton
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/80b4d9ea-e502-4ac5-8032-81ec0a99f4ffn%40googlegroups.com.


question-test

2023-10-17 Thread 'RAUL OLAZAGOITIA' via Django users
Hi group
I am reaching out to try and ask for django common issues.
Can't see your comments on the group. can you help me?

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKhDVWy2f03h_xPtH3EMGZsY73LQXv6d-MK5HHCyTJT4Knp9mA%40mail.gmail.com.


Re: Unit test to make sure correct template is returned from a specific URL?

2023-09-25 Thread Abhishek ozha
got some issues in unit test in django,could anypone have a look


On Monday, September 25, 2023 at 7:28:31 PM UTC+5:45 Simon Connah wrote:

> Thank you very much!
>
> --- Original Message ---
>
> On Monday, September 25th, 2023 at 14:07, Muhammad Juwaini Abdul Rahman <
> juw...@gmail.com> wrote:
>
> Use assertTemplateUsed.
>
>
> https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
>
> On Sun, 24 Sept 2023 at 22:37, 'Simon Connah' via Django users <
> django...@googlegroups.com> wrote:
>
>> I can write a unit test which checks say the title on a page and compares 
>> it to a string but that is really prone to breakage. What I want to do 
>> instead is to check that the template that is returned by the URL is the 
>> same one that is expected in the unit test. Is there an easy way to do this?
>>
>> -- 
>> 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, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/MnCVU2YvJzLiFdMPPAVBwMY7SMosqS5wvqopbySnD05i7BTc375v_Bo5GB4VlUQSd5K2OwsiblAbxsfsz7in96L4_Ou4RTRm0jwVN3aMp54%3D%40protonmail.com
>> .
>>
> -- 
> 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, send an 
> email to django-users...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAFKhtoRiz4mr69ZLu7_wCxVFXgjnvmAW3JCoYdcDrx%2Bwu94vrw%40mail.gmail.com
> .
>
>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dff18872-c958-4f7e-ba64-f4e993fa468an%40googlegroups.com.


Re: Unit test to make sure correct template is returned from a specific URL?

2023-09-25 Thread 'Simon Connah' via Django users
Thank you very much!


--- Original Message ---
On Monday, September 25th, 2023 at 14:07, Muhammad Juwaini Abdul Rahman 
 wrote:


> Use assertTemplateUsed.
> https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed
> 

> On Sun, 24 Sept 2023 at 22:37, 'Simon Connah' via Django users 
>  wrote:
> 

> > I can write a unit test which checks say the title on a page and compares 
> > it to a string but that is really prone to breakage. What I want to do 
> > instead is to check that the template that is returned by the URL is the 
> > same one that is expected in the unit test. Is there an easy way to do this?
> > 

> > --
> > 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, send an 
> > email to django-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/MnCVU2YvJzLiFdMPPAVBwMY7SMosqS5wvqopbySnD05i7BTc375v_Bo5GB4VlUQSd5K2OwsiblAbxsfsz7in96L4_Ou4RTRm0jwVN3aMp54%3D%40protonmail.com.
> 

> --
> 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, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAFKhtoRiz4mr69ZLu7_wCxVFXgjnvmAW3JCoYdcDrx%2Bwu94vrw%40mail.gmail.com.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/O_3E4w3kT2FE_XgQrWGfQFM_DcKq_syuWJ0eEuZ0zJfIPnZ6rzbF80z28SORLG9r7rik-evYNQhGnchpIcEDOP9zqIX9n_xOntOTHDAbv4M%3D%40protonmail.com.


signature.asc
Description: OpenPGP digital signature


Re: Unit test to make sure correct template is returned from a specific URL?

2023-09-25 Thread Muhammad Juwaini Abdul Rahman
Use assertTemplateUsed.

https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed

On Sun, 24 Sept 2023 at 22:37, 'Simon Connah' via Django users <
django-users@googlegroups.com> wrote:

> I can write a unit test which checks say the title on a page and compares
> it to a string but that is really prone to breakage. What I want to do
> instead is to check that the template that is returned by the URL is the
> same one that is expected in the unit test. Is there an easy way to do this?
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/MnCVU2YvJzLiFdMPPAVBwMY7SMosqS5wvqopbySnD05i7BTc375v_Bo5GB4VlUQSd5K2OwsiblAbxsfsz7in96L4_Ou4RTRm0jwVN3aMp54%3D%40protonmail.com
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFKhtoRiz4mr69ZLu7_wCxVFXgjnvmAW3JCoYdcDrx%2Bwu94vrw%40mail.gmail.com.


Unit test to make sure correct template is returned from a specific URL?

2023-09-24 Thread 'Simon Connah' via Django users
I can write a unit test which checks say the title on a page and compares it to 
a string but that is really prone to breakage. What I want to do instead is to 
check that the template that is returned by the URL is the same one that is 
expected in the unit test. Is there an easy way to do this?

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/MnCVU2YvJzLiFdMPPAVBwMY7SMosqS5wvqopbySnD05i7BTc375v_Bo5GB4VlUQSd5K2OwsiblAbxsfsz7in96L4_Ou4RTRm0jwVN3aMp54%3D%40protonmail.com.


signature.asc
Description: OpenPGP digital signature


Re: Unit test is written but coverage report says there are missing statements

2023-01-13 Thread shahil joshi
when i am running the test its storing the inner functional data to main db 
not test db why ?

On Monday, January 9, 2023 at 2:32:20 PM UTC+5:30 sencer...@gmail.com wrote:

> Hi,
>
> I try to get coverage reports using a simple django model.
> Unit test for model was written but report says there are missing 
> statements.
>
> *The model:*
>
> from django.db import models
> from model_utils import FieldTracker
>
> from generics.base_model import BaseModelMixin
>
> class AModel(BaseModelMixin):
> record_name = models.CharField(max_length=255)
> tracker = FieldTracker()
>
> class Meta(BaseModelMixin.Meta):
> db_table = 'a_model_records'
>
> def __str__(self):
> record_name = self.record_name
> if record_name is None:
>     record_name = "N/A"
> return record_name
>
>
> *The unit test:*
>
> class TestAModel(TestCase):
>
> def setUp(self):
> super().setUp()
>
> def test_allowed_domain_model(self):
> record_name = "some name"
> is_active = True
>
> user = User.objects.first()
> record = AModel.objects.create(
>
> record_name=record_name,
> is_active=is_active,
> created_by_id=user.id,
> )
>
> self.assertEqual(str(record), record_name)
> self.assertEqual(record.name, record_name)
> self.assertEqual(record.is_active, is_active)
>
>
> *The command line code I run:*
>
> source activate
> set -a
> source local.env
> set +a
> coverage run --source="unit_test_app" --rcfile=.coveragerc 
> project/manage.py test -v 2
> coverage report
> coverage html
>
> *The coverage configuration is like this:*
>
> [run]
> omit=
> */migrations/*
> */tests/*
> */manage.py
> */apps.py
> */settings.py
> */urls.py
> */filters.py
> */serializers.py
> */generics/*
>
> [report]
> show_missing = true
>
>
> *Coverage result shows 1 missing:*
>
> [image: image.png]
>
> This is the simplest example.
> There are many ignored functions by coverage which descends percentage 
> average, but actually covered by unit tests.
> Why does coverage act like this?
>
> Kind regards,
> Sencer HAMARAT
>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/89acdec2-b889-47a8-b146-8179db80d8a4n%40googlegroups.com.


Anyone testing async views with django test client?

2022-09-20 Thread 'SP' via Django users
My async  CBV works when accessed through my url endpoint with REQUESTS 
package.  But with the django test client it seems to think the database 
doesn't contain the information I'm trying to pull using ORM. I've 
confirmed that the data DOES exist in the newly recreated DB (populated 
with fixtures in my TestCase based class. 

Any suggestions would be appreciated!

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1e727d43-93ae-462d-985f-853f3ed418ccn%40googlegroups.com.


Re: Having Trouble Creating a Test Database

2022-06-07 Thread Mark Phillips
Yes. All migrations have been done.




On Tue, Jun 7, 2022, 9:01 AM Sebastian Jung 
wrote:

> Do you have make manage.py migrate and afzer this manage.py makemigrations?
>
> Mark Phillips  schrieb am Di., 7. Juni 2022,
> 17:02:
>
>> I can't seem to be able to create a test database for my django project.
>> I get this error:
>>
>> django.db.utils.ProgrammingError: (1146, "Table
>> 'test_hopi_django.CurrentArticle' doesn't exist")
>>
>> I have full details at
>> https://stackoverflow.com/questions/72521409/cant-create-django-test-database
>>  if
>> anyone can help.
>>
>> Thanks!
>>
>> Mark
>>
>> --
>> 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, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKGT9mzijrc%3DXNS2cUvuLZ8o8KniTWvTHic-Qicw_Jat-ztYxQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKGT9mzijrc%3DXNS2cUvuLZ8o8KniTWvTHic-Qicw_Jat-ztYxQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEqej2P4Awv-nPP86_Km5UkZa9ToPBfFEe%2BBcy5mE4UQ0-RfCw%40mail.gmail.com.


Re: Having Trouble Creating a Test Database

2022-06-07 Thread atoosa Keshavarz
Hi
Why do not you use mock for data base
?
If you use mock data base you do not need test data base and your data base
will not be change

On Tue, 7 Jun 2022, 7:32 pm Mark Phillips, 
wrote:

> I can't seem to be able to create a test database for my django project. I
> get this error:
>
> django.db.utils.ProgrammingError: (1146, "Table
> 'test_hopi_django.CurrentArticle' doesn't exist")
>
> I have full details at
> https://stackoverflow.com/questions/72521409/cant-create-django-test-database 
> if
> anyone can help.
>
> Thanks!
>
> Mark
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKjZekPLRqO3kavteb%3Da4pt2RMrNSDW1wLtUhs6i_1haBFyEOg%40mail.gmail.com.


Re: Having Trouble Creating a Test Database

2022-06-07 Thread Sebastian Jung
Do you have make manage.py migrate and afzer this manage.py makemigrations?

Mark Phillips  schrieb am Di., 7. Juni 2022,
17:02:

> I can't seem to be able to create a test database for my django project. I
> get this error:
>
> django.db.utils.ProgrammingError: (1146, "Table
> 'test_hopi_django.CurrentArticle' doesn't exist")
>
> I have full details at
> https://stackoverflow.com/questions/72521409/cant-create-django-test-database 
> if
> anyone can help.
>
> Thanks!
>
> Mark
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKGT9mzijrc%3DXNS2cUvuLZ8o8KniTWvTHic-Qicw_Jat-ztYxQ%40mail.gmail.com.


Having Trouble Creating a Test Database

2022-06-07 Thread Mark Phillips
I can't seem to be able to create a test database for my django project. I
get this error:

django.db.utils.ProgrammingError: (1146, "Table
'test_hopi_django.CurrentArticle' doesn't exist")

I have full details at
https://stackoverflow.com/questions/72521409/cant-create-django-test-database
if
anyone can help.

Thanks!

Mark

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEqej2Mucd0G9%3DRfS4df26HbgVAPvuPMRgisPVvy3otowamVPQ%40mail.gmail.com.


How to test urls

2022-03-23 Thread Prashanth Patelc
Hi all,

how test the urls in django rest , i need each url response how to write
one file for each url response

need to write a URL in our application, which will return working or
something as a response  ?

* not test cases

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMCU6CrXiOE2YLjzfN7ObnHSzeqg-_eytqvnc%2BPFLOwT08hr_Q%40mail.gmail.com.


Re: Got an error creating the test database: database "" already exists

2022-03-17 Thread Salima Begum
Hi,
I am using django version 3.2.9 and Yes above you mentioned like that only
i am running migrations.
1. python manage.py makemigrations
2. python manage.py migrate
No, I am not using django build in user model. I am using my custom one.


a

On Thu, Mar 17, 2022 at 7:37 PM DJANGO DEVELOPER 
wrote:

> what version of Django are you using? and how did you make migrations?
> Should be like this:
> 1 - python manage.py makemigrations
> 2 - python manage.py migrate
> are you using custom user model? or django's built in User model?
>
> On Thu, Mar 17, 2022 at 3:42 PM Prashanth Patelc <
> prashanthpat...@gmail.com> wrote:
>
>> Check your settings.py once
>> Add auth_user='app.UserModel'
>>
>> Or
>> 1) delete database and migrations
>> 2) create new db
>> 3) python manage.py makemigration
>> 4) python manage.py migrate
>>
>>
>> On Thu, Mar 17, 2022, 9:35 AM Avinash Alanjakar <
>> avinashalanj...@gmail.com> wrote:
>>
>>>
>>> Their are lots of pre-bulit apps in django so you need to migrate them
>>> first.
>>> In your case you are using the authentication with migrating their
>>> tables with database.
>>>
>>> Try to run command in this sequence. This might be solve your problem.
>>>
>>>
>>> python manage.py migrate
>>>
>>> python manage.py makemigrations
>>>
>>> python manage.py migrate
>>>
>>>
>>> Thanks,
>>> Avinash
>>>
>>> On Thu, 17 Mar, 2022, 8:53 am Salima Begum, <
>>> salim...@rohteksolutions.com> wrote:
>>>
>>>> Yes I run migrations still I am seeing the new issue below
>>>> ```
>>>> django.db.utils.ProgrammingError: relation "auth_user" does not exist
>>>> ```
>>>> Thank you
>>>> ~Salima
>>>>
>>>> On Wed, Mar 16, 2022 at 9:23 PM DJANGO DEVELOPER <
>>>> abubakarbr...@gmail.com> wrote:
>>>>
>>>>> you need to run migrations first and then run the tests. if the issue
>>>>> still persists. let me know
>>>>>
>>>>> On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung <
>>>>> sebastian.ju...@gmail.com> wrote:
>>>>>
>>>>>> Hey salima,
>>>>>>
>>>>>> This error is strange. Django try to use a Relation in postgresql
>>>>>> which doesn't exist.
>>>>>>
>>>>>> I have only tip that you cam reset database. I would delete database
>>>>>> in postgresql and create it new with psql tool. After this you must reset
>>>>>> all migrations:
>>>>>>
>>>>>>
>>>>>> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>>>>>>
>>>>>> And after this when you migrate it, then structure is created in new
>>>>>> database.
>>>>>>
>>>>>> I am sorry i have no idea how yoz can fix relation exception manual.
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>>
>>>>>> Salima Begum  schrieb am Mi., 16. März
>>>>>> 2022, 06:51:
>>>>>>
>>>>>>> Hi all,
>>>>>>> After writing test cases I run test cases I am getting an error below
>>>>>>> ```
>>>>>>> Python manage.py behave
>>>>>>> ```
>>>>>>> After running the above command I am getting this error.
>>>>>>> ```
>>>>>>> Creating test database for alias 'default'...
>>>>>>> Got an error creating the test database: database "test_newDataBase"
>>>>>>> already exists
>>>>>>>
>>>>>>> Type 'yes' if you would like to try deleting the test database
>>>>>>> 'test_newDataBase', or 'no' to cancel: yes
>>>>>>> Destroying old test database for alias 'default'...
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "C:\Users\USER
>>>>>>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>>>>>>> line 86, in _execute
>>>>>>> return self.cursor.execute(sql, params)
>>>>>>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does
>>>>>>> n

Re: Got an error creating the test database: database "" already exists

2022-03-17 Thread DJANGO DEVELOPER
what version of Django are you using? and how did you make migrations?
Should be like this:
1 - python manage.py makemigrations
2 - python manage.py migrate
are you using custom user model? or django's built in User model?

On Thu, Mar 17, 2022 at 3:42 PM Prashanth Patelc 
wrote:

> Check your settings.py once
> Add auth_user='app.UserModel'
>
> Or
> 1) delete database and migrations
> 2) create new db
> 3) python manage.py makemigration
> 4) python manage.py migrate
>
>
> On Thu, Mar 17, 2022, 9:35 AM Avinash Alanjakar 
> wrote:
>
>>
>> Their are lots of pre-bulit apps in django so you need to migrate them
>> first.
>> In your case you are using the authentication with migrating their tables
>> with database.
>>
>> Try to run command in this sequence. This might be solve your problem.
>>
>>
>> python manage.py migrate
>>
>> python manage.py makemigrations
>>
>> python manage.py migrate
>>
>>
>> Thanks,
>> Avinash
>>
>> On Thu, 17 Mar, 2022, 8:53 am Salima Begum, 
>> wrote:
>>
>>> Yes I run migrations still I am seeing the new issue below
>>> ```
>>> django.db.utils.ProgrammingError: relation "auth_user" does not exist
>>> ```
>>> Thank you
>>> ~Salima
>>>
>>> On Wed, Mar 16, 2022 at 9:23 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
>>>> you need to run migrations first and then run the tests. if the issue
>>>> still persists. let me know
>>>>
>>>> On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung <
>>>> sebastian.ju...@gmail.com> wrote:
>>>>
>>>>> Hey salima,
>>>>>
>>>>> This error is strange. Django try to use a Relation in postgresql
>>>>> which doesn't exist.
>>>>>
>>>>> I have only tip that you cam reset database. I would delete database
>>>>> in postgresql and create it new with psql tool. After this you must reset
>>>>> all migrations:
>>>>>
>>>>>
>>>>> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>>>>>
>>>>> And after this when you migrate it, then structure is created in new
>>>>> database.
>>>>>
>>>>> I am sorry i have no idea how yoz can fix relation exception manual.
>>>>>
>>>>> Regards
>>>>>
>>>>>
>>>>> Salima Begum  schrieb am Mi., 16. März
>>>>> 2022, 06:51:
>>>>>
>>>>>> Hi all,
>>>>>> After writing test cases I run test cases I am getting an error below
>>>>>> ```
>>>>>> Python manage.py behave
>>>>>> ```
>>>>>> After running the above command I am getting this error.
>>>>>> ```
>>>>>> Creating test database for alias 'default'...
>>>>>> Got an error creating the test database: database "test_newDataBase"
>>>>>> already exists
>>>>>>
>>>>>> Type 'yes' if you would like to try deleting the test database
>>>>>> 'test_newDataBase', or 'no' to cancel: yes
>>>>>> Destroying old test database for alias 'default'...
>>>>>> Traceback (most recent call last):
>>>>>>   File "C:\Users\USER
>>>>>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>>>>>> line 86, in _execute
>>>>>> return self.cursor.execute(sql, params)
>>>>>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does
>>>>>> not exist
>>>>>> .
>>>>>> .
>>>>>> django.db.utils.ProgrammingError: relation "trades_vk_trade_table"
>>>>>> does not exist
>>>>>> ```
>>>>>> Please help me to resolve this issue.
>>>>>>
>>>>>> Thank you
>>>>>> ~Salima
>>>>>>
>>>>>> --
>>>>>> 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,
>>>>>> send an email to django-users+unsubscr...@googlegroups.com.
>>>>>> To view this

Re: Got an error creating the test database: database "" already exists

2022-03-17 Thread Prashanth Patelc
Check your settings.py once
Add auth_user='app.UserModel'

Or
1) delete database and migrations
2) create new db
3) python manage.py makemigration
4) python manage.py migrate


On Thu, Mar 17, 2022, 9:35 AM Avinash Alanjakar 
wrote:

>
> Their are lots of pre-bulit apps in django so you need to migrate them
> first.
> In your case you are using the authentication with migrating their tables
> with database.
>
> Try to run command in this sequence. This might be solve your problem.
>
>
> python manage.py migrate
>
> python manage.py makemigrations
>
> python manage.py migrate
>
>
> Thanks,
> Avinash
>
> On Thu, 17 Mar, 2022, 8:53 am Salima Begum, 
> wrote:
>
>> Yes I run migrations still I am seeing the new issue below
>> ```
>> django.db.utils.ProgrammingError: relation "auth_user" does not exist
>> ```
>> Thank you
>> ~Salima
>>
>> On Wed, Mar 16, 2022 at 9:23 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> you need to run migrations first and then run the tests. if the issue
>>> still persists. let me know
>>>
>>> On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung <
>>> sebastian.ju...@gmail.com> wrote:
>>>
>>>> Hey salima,
>>>>
>>>> This error is strange. Django try to use a Relation in postgresql which
>>>> doesn't exist.
>>>>
>>>> I have only tip that you cam reset database. I would delete database in
>>>> postgresql and create it new with psql tool. After this you must reset all
>>>> migrations:
>>>>
>>>>
>>>> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>>>>
>>>> And after this when you migrate it, then structure is created in new
>>>> database.
>>>>
>>>> I am sorry i have no idea how yoz can fix relation exception manual.
>>>>
>>>> Regards
>>>>
>>>>
>>>> Salima Begum  schrieb am Mi., 16. März
>>>> 2022, 06:51:
>>>>
>>>>> Hi all,
>>>>> After writing test cases I run test cases I am getting an error below
>>>>> ```
>>>>> Python manage.py behave
>>>>> ```
>>>>> After running the above command I am getting this error.
>>>>> ```
>>>>> Creating test database for alias 'default'...
>>>>> Got an error creating the test database: database "test_newDataBase"
>>>>> already exists
>>>>>
>>>>> Type 'yes' if you would like to try deleting the test database
>>>>> 'test_newDataBase', or 'no' to cancel: yes
>>>>> Destroying old test database for alias 'default'...
>>>>> Traceback (most recent call last):
>>>>>   File "C:\Users\USER
>>>>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>>>>> line 86, in _execute
>>>>> return self.cursor.execute(sql, params)
>>>>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not
>>>>> exist
>>>>> .
>>>>> .
>>>>> django.db.utils.ProgrammingError: relation "trades_vk_trade_table"
>>>>> does not exist
>>>>> ```
>>>>> Please help me to resolve this issue.
>>>>>
>>>>> Thank you
>>>>> ~Salima
>>>>>
>>>>> --
>>>>> 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, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> 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, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit

Re: Got an error creating the test database: database "" already exists

2022-03-16 Thread Avinash Alanjakar
Their are lots of pre-bulit apps in django so you need to migrate them
first.
In your case you are using the authentication with migrating their tables
with database.

Try to run command in this sequence. This might be solve your problem.


python manage.py migrate

python manage.py makemigrations

python manage.py migrate


Thanks,
Avinash

On Thu, 17 Mar, 2022, 8:53 am Salima Begum, 
wrote:

> Yes I run migrations still I am seeing the new issue below
> ```
> django.db.utils.ProgrammingError: relation "auth_user" does not exist
> ```
> Thank you
> ~Salima
>
> On Wed, Mar 16, 2022 at 9:23 PM DJANGO DEVELOPER 
> wrote:
>
>> you need to run migrations first and then run the tests. if the issue
>> still persists. let me know
>>
>> On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung 
>> wrote:
>>
>>> Hey salima,
>>>
>>> This error is strange. Django try to use a Relation in postgresql which
>>> doesn't exist.
>>>
>>> I have only tip that you cam reset database. I would delete database in
>>> postgresql and create it new with psql tool. After this you must reset all
>>> migrations:
>>>
>>>
>>> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>>>
>>> And after this when you migrate it, then structure is created in new
>>> database.
>>>
>>> I am sorry i have no idea how yoz can fix relation exception manual.
>>>
>>> Regards
>>>
>>>
>>> Salima Begum  schrieb am Mi., 16. März
>>> 2022, 06:51:
>>>
>>>> Hi all,
>>>> After writing test cases I run test cases I am getting an error below
>>>> ```
>>>> Python manage.py behave
>>>> ```
>>>> After running the above command I am getting this error.
>>>> ```
>>>> Creating test database for alias 'default'...
>>>> Got an error creating the test database: database "test_newDataBase"
>>>> already exists
>>>>
>>>> Type 'yes' if you would like to try deleting the test database
>>>> 'test_newDataBase', or 'no' to cancel: yes
>>>> Destroying old test database for alias 'default'...
>>>> Traceback (most recent call last):
>>>>   File "C:\Users\USER
>>>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>>>> line 86, in _execute
>>>> return self.cursor.execute(sql, params)
>>>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not
>>>> exist
>>>> .
>>>> .
>>>> django.db.utils.ProgrammingError: relation "trades_vk_trade_table" does
>>>> not exist
>>>> ```
>>>> Please help me to resolve this issue.
>>>>
>>>> Thank you
>>>> ~Salima
>>>>
>>>> --
>>>> 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, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>>> 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, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/dja

Re: Got an error creating the test database: database "" already exists

2022-03-16 Thread Salima Begum
Yes I run migrations still I am seeing the new issue below
```
django.db.utils.ProgrammingError: relation "auth_user" does not exist
```
Thank you
~Salima

On Wed, Mar 16, 2022 at 9:23 PM DJANGO DEVELOPER 
wrote:

> you need to run migrations first and then run the tests. if the issue
> still persists. let me know
>
> On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung 
> wrote:
>
>> Hey salima,
>>
>> This error is strange. Django try to use a Relation in postgresql which
>> doesn't exist.
>>
>> I have only tip that you cam reset database. I would delete database in
>> postgresql and create it new with psql tool. After this you must reset all
>> migrations:
>>
>>
>> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>>
>> And after this when you migrate it, then structure is created in new
>> database.
>>
>> I am sorry i have no idea how yoz can fix relation exception manual.
>>
>> Regards
>>
>>
>> Salima Begum  schrieb am Mi., 16. März
>> 2022, 06:51:
>>
>>> Hi all,
>>> After writing test cases I run test cases I am getting an error below
>>> ```
>>> Python manage.py behave
>>> ```
>>> After running the above command I am getting this error.
>>> ```
>>> Creating test database for alias 'default'...
>>> Got an error creating the test database: database "test_newDataBase"
>>> already exists
>>>
>>> Type 'yes' if you would like to try deleting the test database
>>> 'test_newDataBase', or 'no' to cancel: yes
>>> Destroying old test database for alias 'default'...
>>> Traceback (most recent call last):
>>>   File "C:\Users\USER
>>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>>> line 86, in _execute
>>> return self.cursor.execute(sql, params)
>>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not
>>> exist
>>> .
>>> .
>>> django.db.utils.ProgrammingError: relation "trades_vk_trade_table" does
>>> not exist
>>> ```
>>> Please help me to resolve this issue.
>>>
>>> Thank you
>>> ~Salima
>>>
>>> --
>>> 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, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKPY9pkx0hJ3U_DFCia_UUY-ecieMJ0%2BE3uE75aTziehr1KWSg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKPY9pkx0hJ3U_DFCia_UUY-ecieMJ0%2BE3uE75aTziehr1KWSg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6b%3DZTCYy%2BY1NoRSh9t0S0UcLkwcSb_31SYqzOg95SU%2Bq6Q%40mail.gmail.com.


Re: Got an error creating the test database: database "" already exists

2022-03-16 Thread DJANGO DEVELOPER
you need to run migrations first and then run the tests. if the issue still
persists. let me know

On Wed, Mar 16, 2022 at 2:15 PM Sebastian Jung 
wrote:

> Hey salima,
>
> This error is strange. Django try to use a Relation in postgresql which
> doesn't exist.
>
> I have only tip that you cam reset database. I would delete database in
> postgresql and create it new with psql tool. After this you must reset all
> migrations:
>
>
> https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html
>
> And after this when you migrate it, then structure is created in new
> database.
>
> I am sorry i have no idea how yoz can fix relation exception manual.
>
> Regards
>
>
> Salima Begum  schrieb am Mi., 16. März
> 2022, 06:51:
>
>> Hi all,
>> After writing test cases I run test cases I am getting an error below
>> ```
>> Python manage.py behave
>> ```
>> After running the above command I am getting this error.
>> ```
>> Creating test database for alias 'default'...
>> Got an error creating the test database: database "test_newDataBase"
>> already exists
>>
>> Type 'yes' if you would like to try deleting the test database
>> 'test_newDataBase', or 'no' to cancel: yes
>> Destroying old test database for alias 'default'...
>> Traceback (most recent call last):
>>   File "C:\Users\USER
>> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
>> line 86, in _execute
>> return self.cursor.execute(sql, params)
>> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not
>> exist
>> .
>> .
>> django.db.utils.ProgrammingError: relation "trades_vk_trade_table" does
>> not exist
>> ```
>> Please help me to resolve this issue.
>>
>> Thank you
>> ~Salima
>>
>> --
>> 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, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKPY9pkx0hJ3U_DFCia_UUY-ecieMJ0%2BE3uE75aTziehr1KWSg%40mail.gmail.com.


Re: Got an error creating the test database: database "" already exists

2022-03-16 Thread Sebastian Jung
Hey salima,

This error is strange. Django try to use a Relation in postgresql which
doesn't exist.

I have only tip that you cam reset database. I would delete database in
postgresql and create it new with psql tool. After this you must reset all
migrations:

https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html

And after this when you migrate it, then structure is created in new
database.

I am sorry i have no idea how yoz can fix relation exception manual.

Regards


Salima Begum  schrieb am Mi., 16. März 2022,
06:51:

> Hi all,
> After writing test cases I run test cases I am getting an error below
> ```
> Python manage.py behave
> ```
> After running the above command I am getting this error.
> ```
> Creating test database for alias 'default'...
> Got an error creating the test database: database "test_newDataBase"
> already exists
>
> Type 'yes' if you would like to try deleting the test database
> 'test_newDataBase', or 'no' to cancel: yes
> Destroying old test database for alias 'default'...
> Traceback (most recent call last):
>   File "C:\Users\USER
> 1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
> line 86, in _execute
> return self.cursor.execute(sql, params)
> psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not
> exist
> .
> .
> django.db.utils.ProgrammingError: relation "trades_vk_trade_table" does
> not exist
> ```
> Please help me to resolve this issue.
>
> Thank you
> ~Salima
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKGT9mx2sRizWo8Qd%3Dn6yYFKUB1KvjKH%2Bi92Hj_fdoStRYc%3DWg%40mail.gmail.com.


Got an error creating the test database: database "" already exists

2022-03-15 Thread Salima Begum
Hi all,
After writing test cases I run test cases I am getting an error below
```
Python manage.py behave
```
After running the above command I am getting this error.
```
Creating test database for alias 'default'...
Got an error creating the test database: database "test_newDataBase"
already exists

Type 'yes' if you would like to try deleting the test database
'test_newDataBase', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Traceback (most recent call last):
  File "C:\Users\USER
1\PycharmProjects\behaveproject\venv\lib\site-packages\django\db\backends\utils.py",
line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "trades_trade_table" does not exist
.
.
django.db.utils.ProgrammingError: relation "trades_vk_trade_table" does not
exist
```
Please help me to resolve this issue.

Thank you
~Salima

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6b%3DTEv%3DH25L7giQV6w%3DYw6%3D6GJrvh5zPezqQWMger3VNzQ%40mail.gmail.com.


Debug Django Test-cases

2022-02-25 Thread HEMENDRA SINGH HADA
Hi Team,

I am writing some django test-cases, there are multiple test-cases are 
failing inside view or models, but I am not getting exact root cause for 
those failure, 

Could you please suggest me any tool which is used to debug the django unit 
test cases, Also if you can share my some good document to write test-cases.

Thanks in advance !!!

 

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11209f55-3ef0-4b96-b384-93d9c2fa9531n%40googlegroups.com.


Re: Running tests fails in the test runner call_command

2021-12-22 Thread Thomas

fwiw there is a call to the wrapping method 
django.test.DiscoverRunner.run_checks() in the celery python package. And 
I've got django_celery_beat in my list of apps which might be bringing it 
in???
On Tuesday, December 21, 2021 at 4:01:10 PM UTC-8 Thomas wrote:

> I’ve got a 3.2.10 installation and haven’t run my unit tests in a long 
> time. When I try now, I get a failure which seems to trace back to the test 
> runner itself:
>
> TypeError: Unknown option(s) for check command: databases. Valid options 
> are: all, debug, force_color, help, names, no_color, pythonpath, quiet, 
> settings, skip_checks, stderr, stdout, traceback, verbose, verbosity, 
> version.
>
> where the only mention of call_command with an explicit “databases” 
> argument is in django/test/runner.py
>
> I see this argument was introduced in 3.1 and was not present in 3.0.x and 
> earlier.
>
> Any hints on where to look for the root cause or how to patch it up?
>
> TIA
>
> - Tom
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/432c9fa5-a01b-4735-8e5d-d8b3eb44545cn%40googlegroups.com.


Running tests fails in the test runner call_command

2021-12-21 Thread Thomas Lockhart
I’ve got a 3.2.10 installation and haven’t run my unit tests in a long time. 
When I try now, I get a failure which seems to trace back to the test runner 
itself:

TypeError: Unknown option(s) for check command: databases. Valid options are: 
all, debug, force_color, help, names, no_color, pythonpath, quiet, settings, 
skip_checks, stderr, stdout, traceback, verbose, verbosity, version.

where the only mention of call_command with an explicit “databases” argument is 
in django/test/runner.py

I see this argument was introduced in 3.1 and was not present in 3.0.x and 
earlier.

Any hints on where to look for the root cause or how to patch it up?

TIA

- Tom

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21412B61-B532-4F29-8ED6-40CDB1F0AFBD%40gmail.com.


Asynchronous test always failing

2021-11-18 Thread Julie Agopian
Hello, 

I hope I am on the right place.
I want to write some test from my async view and I follow the documentation 
but it keeps failing.


this is my view:

```class Session(View):
""" Asynchronously get a session for a system."""

@classonlymethod
def as_view(cls, **initkwargs):
view = super().as_view(**initkwargs)
view._is_coroutine = asyncio.coroutines._is_coroutine # pylint: 
disable=protected-access
return view

async def get(self, request, **kwargs):
""" Async get list of session between two dates """

end_period: str = request.GET['end']
start_period: str = request.GET['start']
gcloud_id: str = request.GET['gcloud']
offset: int = int(request.GET.get('offset', 10))
page: int = int(request.GET.get('page', 1))
system_uuid: str = kwargs['uuid']

cache_id: str = f"session_{system_uuid}_{start_period}_{end_period}"
if cache.get(cache_id):
log_data = cache.get(cache_id)
else:
session_service: SessionService = SessionService(system_uuid, gcloud_id, 
start_period, end_period)
log_data: List[Dict[str, Union[str, pd.Timestamp]]] = await 
session_service.get_session()
cache.set(cache_id, log_data, timeout=60 * 60)

nb_page: int = math.ceil((len(log_data) / offset))
pagination: Pagination = Pagination(offset, nb_page)
pagination.page = page
return JsonResponse({'logs': 
log_data[pagination.start_limit:pagination.end_limit], 'nb_page': nb_page,
'page': pagination.page},
safe=False)```

the service called in here is actually getting some data from my postgres 
database.

here is my test, basically just following the doc:


```class SystemViewsTest(SystemSetUpTest):
async def test_get_session_detail(self):
uuid: str = '2265d534-5a62-426a-bc44-e17ebddabfb3'

console_gcloud_id = 'console-7ccbe2e157d6'
start_period = '2021-05-06'
end_period = '2021-05-07'
response = await self.async_client.get(
f'/v1/sessions/{uuid}?end={end_period}={start_period}={console_gcloud_id}',
)
print(response)
self.assertEqual(response.status_code, 200)```

SystemSetUpTest is just a class I use to create System data (using the 
setUp method) for my test as it is related to many other models, it 
inherits from django.test import TestCase

but when I want to run my test I have this infinite stack trace saying that 
my db connection already closed, that another session is alredy using my db 
and something about the generator not stopping after throw()..

==
ERROR: test_get_session_detail (systems.tests.test_views.SystemViewsTest)
--
Traceback (most recent call last):
  File 
"/usr/local/lib/python3.8/dist-packages/django/db/backends/base/base.py", 
line 237, in _cursor
return self._prepare_cursor(self.create_cursor(name))
  File "/usr/local/lib/python3.8/dist-packages/django/utils/asyncio.py", 
line 26, in inner
return func(*args, **kwargs)
  File 
"/usr/local/lib/python3.8/dist-packages/django/db/backends/postgresql/base.py", 
line 236, in create_cursor
cursor = self.connection.cursor()
psycopg2.InterfaceError: connection already closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/asgiref/sync.py", line 223, 
in __call__
return call_result.result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 437, in result
return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in 
__get_result
raise self._exception
  File "/usr/local/lib/python3.8/dist-packages/asgiref/sync.py", line 292, 
in main_wrap
result = await self.awaitable(*args, **kwargs)
  File "/app/systems/tests/test_views.py", line 15, in 
test_get_session_detail
response = await self.async_client.get(
  File "/usr/local/lib/python3.8/dist-packages/django/test/client.py", line 
908, in request
self.check_exception(response)
  File "/usr/local/lib/python3.8/dist-packages/django/test/client.py", line 
580, in check_exception
raise exc_value
  File "/usr/local/lib/python3.8/dist-packages/asgiref/sync.py", line 482, 
in thread_handler
raise exc_info[1]
  File 
"/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", 
line 38, in inner
response = await get_response(request)
  File 
"/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 
233, in _get_response_async
response = await wrapped_callback(request, *callback_args, 
**callback_kwargs)
  File 
"/usr/local/lib/python3.8/dist-packages/sentry_sdk/integrations/django/asgi.py",
 
line 94, in sentry_wrapped_callback
return await callback(request, *args, **kwargs)
  File "/app/systems/views/shift.py", line 114, in get
log_data: List[Di

Unable to add token headers to graphene-django test using pytest

2021-10-04 Thread Muhammad Shehzad
*I am trying to add a token to graphene-django headers using pytest. But
It always return that user is anonymous as shown at the end but it
should return user as token is added in fixture@pytest.fixture def
client_query(client): def func(*args, **kwargs): return
graphql_query(*args, **kwargs, client=client) return func @pytest.fixture
def create_candidate(candidate_factory): candidate = [] for _ in range(5):
can = candidate_factory.create() token, __ =
Token.objects.get_or_create(user=can.user) candidate.append(can) return
candidate **This is the test** @pytest.mark.django_db def
test_get_login_candidate(client_query, create_candidate): headers =
{"Authorization": f"Token {create_candidate[0].user.auth_token}"} response
= client_query( """ query { loginCandidate{ id, } } """, headers=headers, )
result = json.loads(response.content) print(result) This is the output
{'errors': [{'message': "'AnonymousUser' object is not iterable",
'locations': [{'line': 3, 'column': 11}], 'path': ['loginCandidate']}],
'data': {'loginCandidate': None}}*

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGv3YND402MKNs6w2iFxEoHsMdMBhOwAKLtZy%3DQ2gZ6h9D-%2Bbw%40mail.gmail.com.


Re: Django Unit-test

2021-07-06 Thread Veera Raj
I am fresher In django wanna have a opportunity.can anyone help me ?

On Tue, Jul 6, 2021, 9:29 PM Yonatan Girma 
wrote:

> Greetings,
>
> We are looking for Django app unit tester for small business project. Any
> person with professional experience please send resume to
> support-...@adulis.com
>
> Respectfully,
> Yonatan G.
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAbCZeDPEjuL-0tHJmAHv%3DUi%3DQRxcaQkjm6OBAFR_WdGXYxJFA%40mail.gmail.com
> 
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACg7y8Q9SNGQHV%3DvyXgGdRAXBH5wnVVc4XF_9OuXiDNXMs8okQ%40mail.gmail.com.


Django Unit-test

2021-07-06 Thread Yonatan Girma
Greetings,

We are looking for Django app unit tester for small business project. Any
person with professional experience please send resume to
support-...@adulis.com

Respectfully,
Yonatan G.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAbCZeDPEjuL-0tHJmAHv%3DUi%3DQRxcaQkjm6OBAFR_WdGXYxJFA%40mail.gmail.com.


Challenges Building and Integrating Test and Live API keys

2021-06-15 Thread Miracle
I want to create a system that works similar to stripe. There'll be live
API keys, as well as test API keys. I have been thinking of how to
implement this architecture, and I am not sure the best way to go about it.
I found a similar question on this but it didn't help much.

Architecturing testmode/livemode using OAuth 2 token
<https://stackoverflow.com/questions/24539688/architecturing-testmode-livemode-using-oauth-2-token>

My current progress is basically:

   - I have decided to use
https://github.com/James1345/django-rest-knox instead
   of DRF's default authtoken because knox supports multiple token creation
   and I thougt I needed that feature.
   - I intend to create tokens as pub_key_ and test_key_ and
   remove or strip the prefix before authentication
   - I intend to create a LiveAccount Model and a TestAcoount model.

However, after authenticating the request from a test api token, it's
unclear how to route or perform requests to TestAcoount instead of
LiveAccount.

Please any ideas or a better implementation strategy is highly welcomed

stackoverflow link:
https://stackoverflow.com/questions/67995479/create-accounts-and-api-tokens-for-live-mode-and-test-mode

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADZv-jCvu16tYsTQa6YbD_98fnbgN%3DRgY80gBH57BebxFCipfQ%40mail.gmail.com.


Re: Question about models. test

2021-05-02 Thread Peter of the Norse
This kind of script can be dangerous.  It’s possible for malicious websites to 
create a page that can use up too many resources or otherwise act strangely.  
URLValidator 
<https://docs.djangoproject.com/en/3.2/ref/validators/#djangohttps://docs.djangoproject.com/en/3.2/ref/validators/%23urlvalidator.core.validators.URLValidator>
 used to do this kind of thing optionally, but that was removed because of all 
of the problems it caused.  If you do try visiting all of the websites, make 
sure you have a low timeout and don’t follow redirects.

> On Feb 25, 2021, at 3:50 PM, Ryan Nowakowski  wrote:
> 
> On Thu, Feb 25, 2021 at 01:06:00AM -0500, dupakoor kannan wrote:
>> I have the following model
>> 
>> class Publication(models.Model):
>>name = models.CharField(max_length=25, blank=True, null=False)
>>publication_url = models.TextField(blank=True)
> 
> Once you clean out all the bad data, you might want to migrate from
> TextField to URLField here.  That would help prevent data entry
> mistakes assuming some of the errors are invalid URLs.
> 
> One other suggestion, even though you didn't ask :)  I'd rename
> publication_url to just url since it's a part of the Publication model,
> the "publication" part is redundant.
> 
>> and observed there are some inactive URLs on the production server (due to
>> data entry mistakes). Is there any way I can write a test for the inactive
>> URLs from the database (local copy)?.
> 
> I assume "inactive" here means that the URLs are returning HTTP 404.
> For the test, you can run this in `python manage.py shell`:
> 
> import requests  # you'll need to pip install requests
> 
> for publication in Publication.objects.all():
>   response = requests.get(publication.publication_url)
>   try:
>   response.raise_for_status()
>   except requests.exceptions.HTTPError:
>   # do something here with your "inactive" URL
>   pass
> 
> 
> If you want to make this easier to run in the future, I suggest making a
> custom management command[1].  If you want this test to run anytime
> Publication.save() is called, add a validator[2] to publication_url.
> 
> [1] https://docs.djangoproject.com/en/3.1/howto/custom-management-commands/
> [2] https://docs.djangoproject.com/en/3.1/ref/validators/
> 
> -- 
> 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, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/20210225225044.GE19963%40fattuba.com.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1EE85283-F866-45F5-B355-0B75CCCB830E%40gmail.com.


Got an error creating the test databse - with mysql and docker-compose

2021-05-01 Thread Gwanghyeon Gim
Hi django developers!

I have an issue with creating test database. I use mysql for db and docker 
compose.

I have no problem running docker containers with docker-compose, but when I 
run test it spits this error message.

Note that the name of django service is web, and mysql service is db.

$ docker-compose run --rm web sh -c "python manage.py test"
Creating sociallogin_web_run ... done
Creating test database for alias 'default'...
Got an error creating the test database: (1044, "Access denied for user 
'myuser'@'%' to database 'test_mydb'")

my docker-compose file:
version: "3.9"

services:

db:
image: mysql:8
env_file:
- .env
command: 
- --default-authentication-plugin=mysql_native_password
restart: always
# ports:
# - "3306:3306"
# volumes:
# - data:/var/lib/mysql

web:
build: .
command: >
sh -c "python manage.py wait_for_db &&
python manage.py makemigrations && 
python manage.py migrate && 
python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/code
ports:
- "8000:8000"
depends_on: 
- db
env_file:
- .env

# volumes:
# data:

my .env file looks like this:
MYSQL_ROOT_PASSWORD=rootpass
MYSQL_USER=exampleuser
MYSQL_PASSWORD=examplepass
MYSQL_DATABASE=exampledb
MYSQL_PORT=3306
SECRET_KEY=exmaple_random_characters


my settings for DATABASES

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ.get('MYSQL_DATABASE'),
'USER': os.environ.get('MYSQL_USER'),
'PASSWORD': os.environ.get('MYSQL_PASSWORD'),
'PORT': os.environ.get('MYSQL_PORT'),
'HOST': 'db',
}
}

I looked at SO 
<https://stackoverflow.com/questions/14186055/django-test-app-error-got-an-error-creating-the-test-database-permission-deni>,
 
and I even tried this <https://stackoverflow.com/a/45131868/11790764>. It 
didn't help me. 

Anyone who's been stuck at similiar problem? 

Thanks guys in advance.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f7e3dc9-2c16-489e-9559-5899dc60dde1n%40googlegroups.com.


Re: How to properly document and test models with natural keys

2021-04-11 Thread Anusheel Bhushan
HI Olivier - 
Django typically has separate settings files for each environment. You can 
also use different environment variables to use when starting the app.
RE: models, here's an example of serialization that could be helpful to 
show how to serialize/deserialize models with foreign keys 
: 
https://github.com/imagineai/create-django-app/blob/master/todoapp/serializers.py

re: unit tests, see some examples of serializers 
here: https://github.com/imagineai/create-django-app/tree/master/todoapp/tests

Both the serializers and the tests above are generated (from a yaml type 
config).

Happy to answer more specific qs...
On Monday, March 29, 2021 at 2:59:12 AM UTC-7 Olivier wrote:

> Hello,
>
> I'm thinking about adding natural keys to a lot of existing models (Djano 
> 3.1.7) to help initializing dev or prod database.
>
> 1. How best to unit test  models using natural keys ?
> I was thinking of separately testing  both serialization and 
> deserialization but would be very curious to learn about examples or 
> alternatives, specifically when Foerign key relations existe between models.
>
> 2. For any unit test, you may have to hand write a YAML sample.
> How is it best to write this sample ?
>
> 3. Suggestions. Recommendations. Pointers ?
>
> Best regards
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9913bb40-4081-47a4-b668-d7c14c00b328n%40googlegroups.com.


How to test foreign key in clean() [was: Django Admin 3.1.7: getting RelatedObjectDoesNotExist for required ForeignKey]

2021-03-30 Thread Olivier
Hello,

I could source the issue in a line in EthernetInterface clean() function.

Here is the error triggering line:
other_if = 
EthernetInterface.objects.exclude(server_host__pk=self.server_host.pk).filter(MAC=self.MAC).first()

When I replace this line with ones bellow, behaviour is as expected (red 
'This field is required' error message display without any exception 
throwing):
try:
 other_if = 
EthernetInterface.objects.exclude(server_host__pk=self.server_host.pk).filter(MAC=self.MAC).first()
except:
 other_if = EthernetInterface.objects.filter(MAC=self.MAC).first()


Though it now works as expected, I'm not satisfied with my workaround 
because I'm catching all errors or exceptions.


1. Within a clean() function body, what is the canonical way to check if a 
(required) foreign key is currently set or not ?
I tried with "if self.server_host" without success.
I was thinking of accessing some model dict if such exist.

2. How can I import RelatedObjectDoesNotExist errors in my code ?

3. Would you say that throwing an error when executing a simple "if 
self.server_host" test is a bug (that should be reported) or not ?

Best regards

Le lundi 29 mars 2021 à 11:02:30 UTC+2, Olivier a écrit :

> Hello,
>
> I'm using Django 3.1.7's Admin form of the following model:
>
> class EthernetInterface(models.Model):
> slug_name = models.CharField(max_length=32)
> MAC = MACAddressField(blank=True, null=True)
> lan = models.ForeignKey(LAN, on_delete=models.PROTECT, 
> related_name='lan_interfaces')
> server_host = models.ForeignKey(ServerHost, on_delete=models.PROTECT, 
> related_name='interfaces')
> objects = NetManager()
>
> Admin form displays both Lan and Server host in bold letters.
>
> When I voluntarily forget to supply a LAN object, Admin form displays a 
> red 'This field is required' error message above LAN selection menu. This 
> is what I expected.
>
> When I voluntarily forget to supply a Server Host object, Django throws a 
> RelatedObjectDoesNotExist 
> exception. This is NOT what I expected as I expected it to display a red 
> 'This field is required' error message.
>
> 1. Are my expectations correct ?
> 2. How can I debug or work around this ? (adding a specific rule in 
> model's clean function was not effective as I think this function is called 
> after individuals fields are checked)
>
> Best regards
>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/85f04480-82ac-4ed4-bd90-4ebee8bbd601n%40googlegroups.com.


How to properly document and test models with natural keys

2021-03-29 Thread Olivier
Hello,

I'm thinking about adding natural keys to a lot of existing models (Djano 
3.1.7) to help initializing dev or prod database.

1. How best to unit test  models using natural keys ?
I was thinking of separately testing  both serialization and 
deserialization but would be very curious to learn about examples or 
alternatives, specifically when Foerign key relations existe between models.

2. For any unit test, you may have to hand write a YAML sample.
How is it best to write this sample ?

3. Suggestions. Recommendations. Pointers ?

Best regards

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16edd7f9-d32e-4d58-bf2d-0a0f9d28087bn%40googlegroups.com.


Re: Question about models. test

2021-02-25 Thread Ryan Nowakowski
On Thu, Feb 25, 2021 at 01:06:00AM -0500, dupakoor kannan wrote:
> I have the following model
> 
> class Publication(models.Model):
> name = models.CharField(max_length=25, blank=True, null=False)
> publication_url = models.TextField(blank=True)

Once you clean out all the bad data, you might want to migrate from
TextField to URLField here.  That would help prevent data entry
mistakes assuming some of the errors are invalid URLs.

One other suggestion, even though you didn't ask :)  I'd rename
publication_url to just url since it's a part of the Publication model,
the "publication" part is redundant.

> and observed there are some inactive URLs on the production server (due to
> data entry mistakes). Is there any way I can write a test for the inactive
> URLs from the database (local copy)?.

I assume "inactive" here means that the URLs are returning HTTP 404.
For the test, you can run this in `python manage.py shell`:

import requests  # you'll need to pip install requests

for publication in Publication.objects.all():
response = requests.get(publication.publication_url)
try:
response.raise_for_status()
except requests.exceptions.HTTPError:
# do something here with your "inactive" URL
pass


If you want to make this easier to run in the future, I suggest making a
custom management command[1].  If you want this test to run anytime
Publication.save() is called, add a validator[2] to publication_url.

[1] https://docs.djangoproject.com/en/3.1/howto/custom-management-commands/
[2] https://docs.djangoproject.com/en/3.1/ref/validators/

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20210225225044.GE19963%40fattuba.com.


Question about models. test

2021-02-24 Thread dupakoor kannan
Hello everyone,

I have the following model

class Publication(models.Model):
name = models.CharField(max_length=25, blank=True, null=False)
publication_url = models.TextField(blank=True)

and observed there are some inactive URLs on the production server (due to
data entry mistakes). Is there any way I can write a test for the inactive
URLs from the database (local copy)?.


Thanks
Kannan

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADiZb_d9uiad-mJ0FoJH2ZH7017L31rO8tw9knSyLSsRRdrO2g%40mail.gmail.com.


Re: test client vs jinja?

2021-02-10 Thread Roy Smith
Hmmm, it's not doing the templates quite right.  assertTemplateUsed() 
doesn't work, but I can get around that easy enough:

-self.assertTemplateUsed(response, 'spi/sock-info.dtl')
+
+self.assertEqual(response.templates, ['spi/sock-info.jinja'])

On Wednesday, February 10, 2021 at 9:32:31 PM UTC-5 Roy Smith wrote:

> I've gotten back to playing with this.  What I've ended up doing is 
> monkey-patching render to send the signal django.test.Client is expecting 
> from the template backend.  Paraphrasing my (python 3.7) code:
>
> from unittest.mock import patch
> from django.test.signals import template_rendered
> from django.shortcuts import render
>
> class TimelineViewTest(TestCase):
> @patch('spi.views.render')
> def test_context_includes_tag_list(self, mock_render):
>
> def render_patch(request, template, context):
> template_rendered.send(sender=self, template=template, 
> context=context)
> return render(request, template, context)
>
> mock_render.side_effect = render_patch
>
> At least doing it this way puts all the weird stuff in my test code.  I 
> didn't have to touch anything in my production view code (or in either 
> django or jinja).
> On Thursday, February 4, 2021 at 7:29:23 PM UTC-5 Roy Smith wrote:
>
>> I started my current project using native django templates and now I'm 
>> converting to jinja2. For the most part, it has gone smoothly. 
>>
>> The surprising roadblock was that this broke all my unit tests. The issue 
>> is that django.template.backends.jinja2.Jinja2 doesn't populate 
>> response.context. 
>>
>> One thought I had was to patch django.shortcuts.render() with 
>> unittest.mock. That didn't work out so well. 
>>
>> Where I seem to be heading now is to have each of my View subclasses have 
>> a build_context() static method, put most of the logic in that, and then I 
>> can call that directly in my unit tests. This seems to be workable, but 
>> it's kind of ugly that I need to alter my production code to make it 
>> testable. 
>>
>> Any wisdom from people who have gone through this would be appreciated. 
>>
>>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0f8e6204-6231-4fa8-b462-04e54efd0e95n%40googlegroups.com.


Re: test client vs jinja?

2021-02-10 Thread Roy Smith
I've gotten back to playing with this.  What I've ended up doing is 
monkey-patching render to send the signal django.test.Client is expecting 
from the template backend.  Paraphrasing my (python 3.7) code:

from unittest.mock import patch
from django.test.signals import template_rendered
from django.shortcuts import render

class TimelineViewTest(TestCase):
@patch('spi.views.render')
def test_context_includes_tag_list(self, mock_render):

def render_patch(request, template, context):
template_rendered.send(sender=self, template=template, 
context=context)
return render(request, template, context)

mock_render.side_effect = render_patch

At least doing it this way puts all the weird stuff in my test code.  I 
didn't have to touch anything in my production view code (or in either 
django or jinja).
On Thursday, February 4, 2021 at 7:29:23 PM UTC-5 Roy Smith wrote:

> I started my current project using native django templates and now I'm 
> converting to jinja2. For the most part, it has gone smoothly. 
>
> The surprising roadblock was that this broke all my unit tests. The issue 
> is that django.template.backends.jinja2.Jinja2 doesn't populate 
> response.context.
>
> One thought I had was to patch django.shortcuts.render() with 
> unittest.mock. That didn't work out so well.
>
> Where I seem to be heading now is to have each of my View subclasses have 
> a build_context() static method, put most of the logic in that, and then I 
> can call that directly in my unit tests. This seems to be workable, but 
> it's kind of ugly that I need to alter my production code to make it 
> testable.
>
> Any wisdom from people who have gone through this would be appreciated.
>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b228c0ca-e7d4-4a0f-8649-859961864163n%40googlegroups.com.


Re: test client vs jinja?

2021-02-10 Thread Roy Smith
It's a known problem.  See https://code.djangoproject.com/ticket/24622.  In 
short, the django template code has hooks to populate these values in the 
test client's response.  The jinja folks (understandably) don't want to add 
the same hooks.
On Friday, February 5, 2021 at 1:37:10 AM UTC-5 Benny M wrote:

> Hi Roy,
>
> I haven’t been through this personally, but it strikes me as odd that the 
> test can’t read the request context. On the surface it would stand to 
> reason that if the test can’t read it, then the page wouldn’t render on 
> browser request. Can you post an example of one of your failing tests and 
> the accompanying failure result?
>
> Benny

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5187a80f-f03f-4400-8b61-3e9cf9467dc5n%40googlegroups.com.


Re: test client vs jinja?

2021-02-04 Thread Benny M
Hi Roy,

I haven’t been through this personally, but it strikes me as odd that the test 
can’t read the request context. On the surface it would stand to reason that if 
the test can’t read it, then the page wouldn’t render on browser request. Can 
you post an example of one of your failing tests and the accompanying failure 
result?

Benny

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH2PR14MB3913E73F316DE1CD18B79ED9C0B29%40CH2PR14MB3913.namprd14.prod.outlook.com.


test client vs jinja?

2021-02-04 Thread Roy Smith
I started my current project using native django templates and now I'm 
converting to jinja2.  For the most part, it has gone smoothly.  

The surprising roadblock was that this broke all my unit tests.   The issue is 
that django.template.backends.jinja2.Jinja2 doesn't populate response.context.

One thought I had was to patch django.shortcuts.render() with unittest.mock.  
That didn't work out so well.

Where I seem to be heading now is to have each of my View subclasses have a 
build_context() static method, put most of the logic in that, and then I can 
call that directly in my unit tests.  This seems to be workable, but it's kind 
of ugly that I need to alter my production code to make it testable.

Any wisdom from people who have gone through this would be appreciated.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70A8C0DD-5C8D-4A30-89A5-A7F50A454DAB%40panix.com.


test

2020-11-11 Thread rssail
message not posting

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4be2fff9-f2dc-4f52-8751-faf577e5bf59n%40googlegroups.com.


Django test runner not respecting unittest.TestCase?

2020-08-10 Thread Derek DeHart
For one of my functional tests, I decided to use unittest.TestCase instead 
of a Django test class because it was convenient when cleaning up the test 
to have direct access to my local development database in the test itself.

Running the test in isolation like so passes as I'd expect:


$ python manage.py test functional_tests.test_functionality
System check identified no issues (0 silenced).
...
--
Ran 3 tests in 0.040s

OK


When I try to run all tests at the same time, however, that test 
specifically errors out, complaining that an object DoesNotExist, as though 
it were using the Django test database:


$ python manage.py test functional_tests
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
..E..
==
ERROR: some_functional_test 
(functional_tests.test_functionality.FunctionalTest)
--
Traceback (most recent call last):

... etc.

app.models.Object.DoesNotExist: Object matching query does not exist.

--
Ran 21 tests in 0.226s

FAILED (errors=1)
Destroying test database for alias 'default'...


I assume the error is with my trying use Object.objects.latest('created') 
when no Objects exist in Django's test database.

Is there some way to prevent Django from wrapping all tests in whatever it 
is about the test runner that prevents my test from accessing an Object 
directly?

I'm currently working around the issue by quarantining unittest.TestCase 
tests in their own directory so that I can run them as a suite, but it'll 
still error out if I ever want to run everything with manage.py test.

If some additional context is helpful, I'm running functional tests against 
an API endpoint running on my local server. I'm testing a create method, 
and I'm trying to avoid having to request DELETE against the endpoint (I 
haven't even implemented DELETE yet) to clean up the test record created by 
the test.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4afd3494-431b-4f18-b5a3-461635989e4an%40googlegroups.com.


Re: social_django.models.UserSocialAuth.DoesNotExist in unit test

2020-08-05 Thread Roy Smith
I got this figured out.  It turns out I had a dependency on social_auth in an 
entirely different part of my code where I execute

reqeust.user.social_auth.get(provider='mediawiki').extra_data['access_token']

regardless of what auth backend was actually used.



> On Aug 4, 2020, at 10:08 PM, Roy Smith  wrote:
> 
> I have both model and social backends configured in settings.py:
> 
>> AUTHENTICATION_BACKENDS = (
>> 'django.contrib.auth.backends.ModelBackend',
>> 'social_core.backends.mediawiki.MediaWiki',
>> )
> 
> 
> When I run this test:
> 
>> from django.test import TestCase, Client
>> from django.contrib.auth.models import User
>> 
>> 
>> class UserActivitiesViewTest(TestCase):
>> def test_mainspace_title_contains_colon(self):
>> user_fred = User.objects.create_user('Fred', 'f...@example.com 
>> <mailto:f...@example.com>', 'password')
>> client = Client()
>> client.force_login(user_fred, 
>> backend='django.contrib.auth.backends.ModelBackend')
>> response = client.get('/spi/spi-user-activities/Foo', {'count': 10, 
>> 'main': 1}, follow=True)
> 
> 
> The view that's being tested is:
> 
>> class UserActivitiesView(LoginRequiredMixin, View):
>> def get(self, request, user_name):
>>   .
> 
> 
> I get a social_django.models.UserSocialAuth.DoesNotExist exception in the 
> client.get() call.  Why is it doing any kind of query on UserSocialAuth if 
> I'm telling force_login() to use ModelBackend?
> 
> I'm running django 2.2, python 3.7
> 

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/D27D0026-FE0A-4F41-B408-130264105A3C%40panix.com.


social_django.models.UserSocialAuth.DoesNotExist in unit test

2020-08-04 Thread Roy Smith
I have both model and social backends configured in settings.py:

> AUTHENTICATION_BACKENDS = (
> 'django.contrib.auth.backends.ModelBackend',
> 'social_core.backends.mediawiki.MediaWiki',
> )


When I run this test:

> from django.test import TestCase, Client
> from django.contrib.auth.models import User
> 
> 
> class UserActivitiesViewTest(TestCase):
> def test_mainspace_title_contains_colon(self):
> user_fred = User.objects.create_user('Fred', 'f...@example.com', 
> 'password')
> client = Client()
> client.force_login(user_fred, 
> backend='django.contrib.auth.backends.ModelBackend')
> response = client.get('/spi/spi-user-activities/Foo', {'count': 10, 
> 'main': 1}, follow=True)


The view that's being tested is:

> class UserActivitiesView(LoginRequiredMixin, View):
> def get(self, request, user_name):
>   .


I get a social_django.models.UserSocialAuth.DoesNotExist exception in the 
client.get() call.  Why is it doing any kind of query on UserSocialAuth if I'm 
telling force_login() to use ModelBackend?

I'm running django 2.2, python 3.7

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/F63F152D-91BE-41DA-A13D-F54D1D708AD8%40panix.com.


How to test get_success_url method in class based view

2020-05-13 Thread Sumit Kumar
Hey, everyone. Please help me in this problem, i'm trying to test the 
get_success_url method, but didn't got success.

https://stackoverflow.com/questions/61745172/how-to-test-get-success-url-in-classbasedview-for-django

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a3e186a0-511c-4f17-b8f9-742cfc6392dc%40googlegroups.com.


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():
with transaction.atomic():
u = User.objects.create_user(username="abc", 
password="pass")
print("created user: {}".format(u.username))

The crash of "SAVEPOINT does not exist" occurs when exiting inner `
*transaction.atomic*' block.


On Tuesday, May 12, 2020 at 10:35:31 AM UTC+3, Uri Kogan wrote:
>
> 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 nested while it should clearly work.
>
> On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>>
>> Probably you need to use TransactionTestCase, which is the parent of 
>> TestCase instead: 
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
>> That page also mentions a specific problem when using transaction on 
>> TestCase:
>> ```
>> A consequence of this, however, is that some database behaviors cannot be 
>> tested within a Django TestCase class. For instance, you cannot test 
>> that a block of code is executing within a transaction, as is required when 
>> using select_for_update() 
>> <https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update>.
>>  
>> In those cases, you should use TransactionTestCase.
>> 111
>>
>> On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:
>>
>>> That not that simple in my case because. I'll show what I mean:
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>> from rolepermissions.roles import assign_role
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> u = User.objects.create_user(username="abc", password="pass")
>>> assign_role(u, "role_admin")
>>> retrieve_and_analyze_view_using_u_credentials()
>>>
>>> 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 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:
>>>>
>>>> When testing django apps, my unit test usually accesses the django app 
>>>> via django test client: 
>>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>>>> .
>>>> Django test client simulates http access, so my Django tests always run 
>>>> my Django code starting from Django views. 
>>>> Even though 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 to add `transaction.atomic` to that data initialization code.
>>>>
>>>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>>>
>>>>> 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 transactions in TestCase.
>>>>>
>>>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>>>>
>>>>>> I don't think the subclass of TestCase need to use 
>>>>>> transaction.atomic. Why can't you just remove the transaction.atomic? 
>>>>>>
>>>>>> Regards, 
>>

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 
nested while it should clearly work.

On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>
> Probably you need to use TransactionTestCase, which is the parent of 
> TestCase instead: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
> That page also mentions a specific problem when using transaction on 
> TestCase:
> ```
> A consequence of this, however, is that some database behaviors cannot be 
> tested within a Django TestCase class. For instance, you cannot test that 
> a block of code is executing within a transaction, as is required when 
> using select_for_update() 
> <https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update>.
>  
> In those cases, you should use TransactionTestCase.
> 111
>
> On Tue, May 12, 2020 at 1:59 PM Uri Kogan > 
> wrote:
>
>> That not that simple in my case because. I'll show what I mean:
>>
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>> from rolepermissions.roles import assign_role
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> u = User.objects.create_user(username="abc", password="pass")
>> assign_role(u, "role_admin")
>> retrieve_and_analyze_view_using_u_credentials()
>>
>> 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 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:
>>>
>>> When testing django apps, my unit test usually accesses the django app 
>>> via django test client: 
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>>> .
>>> Django test client simulates http access, so my Django tests always run 
>>> my Django code starting from Django views. 
>>> Even though 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 to add `transaction.atomic` to that data initialization code.
>>>
>>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>>
>>>> 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 transactions in TestCase.
>>>>
>>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>>>
>>>>> 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 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. The problem is that there is no 
>>>>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>>>>> the 
>>>>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>>>>
&g

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

2020-05-12 Thread Aldian Fazrihady
Probably you need to use TransactionTestCase, which is the parent of
TestCase instead:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
That page also mentions a specific problem when using transaction on
TestCase:
```
A consequence of this, however, is that some database behaviors cannot be
tested within a Django TestCase class. For instance, you cannot test that a
block of code is executing within a transaction, as is required when using
select_for_update()
<https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update>.
In those cases, you should use TransactionTestCase.
111

On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:

> That not that simple in my case because. I'll show what I mean:
>
> from django.contrib.auth.models import User
> from django.test import TestCase
> from rolepermissions.roles import assign_role
>
> class FooTest(TestCase):
> def test_bar(self):
> u = User.objects.create_user(username="abc", password="pass")
> assign_role(u, "role_admin")
> retrieve_and_analyze_view_using_u_credentials()
>
> 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 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:
>>
>> When testing django apps, my unit test usually accesses the django app
>> via django test client:
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>> .
>> Django test client simulates http access, so my Django tests always run
>> my Django code starting from Django views.
>> Even though 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 to add `transaction.atomic` to that data initialization code.
>>
>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>
>>> 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 transactions in TestCase.
>>>
>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>>
>>>> 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 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. The problem is that there is no
>>>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>>>> the
>>>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>>>
>>>>> The following states that TestCase "tests within two nested atomic()
>>>>> blocks", so it should execute "TRANSACTION START"
>>>>>
>>>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>>>
>>>>>
>>>>> from django.contrib.auth.models import User
>>>>> from django.test import TestCase
>>>>>
>>>>>
>>>>> class FooTest(TestCase):
>>>>> def test_bar(self):
>>>>> with transaction.atomic():
>>>>> user = User.objects.create_user(username="abc",
>>>>> password="pass")
>>>&

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

2020-05-12 Thread Uri Kogan
That not that simple in my case because. I'll show what I mean:

from django.contrib.auth.models import User
from django.test import TestCase
from rolepermissions.roles import assign_role

class FooTest(TestCase):
def test_bar(self):
u = User.objects.create_user(username="abc", password="pass")
assign_role(u, "role_admin")
retrieve_and_analyze_view_using_u_credentials()

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 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:
>
> When testing django apps, my unit test usually accesses the django app via 
> django test client: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
> .
> Django test client simulates http access, so my Django tests always run my 
> Django code starting from Django views. 
> Even though 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 to add `transaction.atomic` to that data initialization code.
>
> On Tue, May 12, 2020 at 12:39 PM Uri Kogan > 
> wrote:
>
>> 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 transactions in TestCase.
>>
>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>
>>> 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 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. The problem is that there is no 
>>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>>> the 
>>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>>
>>>> The following states that TestCase "tests within two nested atomic() 
>>>> blocks", so it should execute "TRANSACTION START"
>>>>
>>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>>
>>>> 
>>>> from django.contrib.auth.models import User
>>>> from django.test import TestCase
>>>>
>>>>
>>>> class FooTest(TestCase):
>>>> def test_bar(self):
>>>> with transaction.atomic():
>>>> user = User.objects.create_user(username="abc", 
>>>> password="pass")
>>>>
>>>>
>>>> -- 
>>>> 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, send 
>>>> an email to django...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>> 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, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
>
> -- 
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91984522-1535-4f37-8fb8-ae76c7095298%40googlegroups.com.


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

2020-05-12 Thread Aldian Fazrihady
When testing django apps, my unit test usually accesses the django app via
django test client:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client.
Django test client simulates http access, so my Django tests always run my
Django code starting from Django views.
Even though 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 to add `transaction.atomic` to that data initialization code.

On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> 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 transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> 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 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. The problem is that there is no
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic()
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>>
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> with transaction.atomic():
>>> user = User.objects.create_user(username="abc",
>>> password="pass")
>>>
>>>
>>> --
>>> 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, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com?utm_medium=email_source=footer>
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.com

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAYO3N3E7Jrds9sqmnfKOUFHwtdf%3DXMra2WZ3WCiDiJfEw%40mail.gmail.com.


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 transactions in TestCase.

On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>
> 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 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. The problem is that there is no 
>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the 
>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>
>> The following states that TestCase "tests within two nested atomic() 
>> blocks", so it should execute "TRANSACTION START"
>>
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>
>> 
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>>
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> with transaction.atomic():
>> user = User.objects.create_user(username="abc", 
>> password="pass")
>>
>>
>> -- 
>> 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, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com.


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 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. The problem is that there is no
> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>
> The following states that TestCase "tests within two nested atomic()
> blocks", so it should execute "TRANSACTION START"
>
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>
>
> from django.contrib.auth.models import User
> from django.test import TestCase
>
>
> class FooTest(TestCase):
> def test_bar(self):
> with transaction.atomic():
> user = User.objects.create_user(username="abc",
> password="pass")
>
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7EoAZi_aRZcppf1xZ6XLF4FGJULq3pL7pnoi33HainJa0JgQ%40mail.gmail.com.


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. The problem is that there is no 
"TRANSACTION START". So, when exiting "with transaction.atomic()" block the 
whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"

The following states that TestCase "tests within two nested atomic() 
blocks", so it should execute "TRANSACTION START"
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase


from django.contrib.auth.models import User
from django.test import TestCase


class FooTest(TestCase):
def test_bar(self):
with transaction.atomic():
user = User.objects.create_user(username="abc", password="pass")


-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com.


Custom Mysql Lookup for FULLTEXT Search Returns empy on test runs

2020-05-06 Thread Gui Talarico
Hi everyone - I am sorry if this is not the right place or format to ask 
for this typo of help.
I have been trying to solve this issue for a while but have not had any 
luck.


I created a Custom Lookup to be able to do full text search on mysql:

```

# lookup

class Search(models.Lookup):
lookup_name = "search"

def as_mysql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = lhs_params + rhs_params
return f"MATCH (%s) AGAINST (%s IN BOOLEAN MODE)" % (lhs, rhs), params


models.TextField.register_lookup(Search)

# Migrations

  from django.db import migrations, models

# Table details
table_name = "by_api_casesnapshot"
field_name = "text"
index_name = f"{table_name}_{field_name}_index"

class Migration(migrations.Migration):

dependencies = [("by_api", "0033_add_tag_color")]

operations = [
migrations.CreateModel(...), # As auto-generated
migrations.RunSQL(
f"CREATE FULLTEXT INDEX {index_name} ON {table_name} 
({field_name})",
f"DROP INDEX {index_name} ON {table_name}",
),
]

```

The __search works fine, but I use it inside a test suite it returns empty.

Any help or feedback is appreciated


Details are here
https://stackoverflow.com/questions/61486725/django-mysql-fulltext-search-works-but-not-on-tests

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3fea10db-692b-4865-9733-b87bb647055f%40googlegroups.com.


Re: Creating test databases in parallel

2020-04-02 Thread Ram Rachum
When you say "shrinking your test databases", what do you mean exactly? I'm
a bit of a newbie on that part of Django.

On Wed, Apr 1, 2020 at 8:13 PM Thomas Lockhart 
wrote:

> If you are trying to optimize the test flow, then you may want to spend
> some time shrinking your test databases to a more manageable size. Or have
> two sets; abbreviated and full, with the larger one to exercise your
> (unknown) edge cases.
>
> hth
>
> - Tom
>
> On Apr 1, 2020, at 2:25 AM, cool-RR  wrote:
>
> Hi guys,
>
> I'm trying to optimize our Django testing workflow.
>
> We have 7 different databases, and Django spends a lot of time on these
> lines:
>
>
> Creating test database for alias 'main_database'...
> Creating test database for alias 'foo_database'...
> Creating test database for alias 'bar_database'...
> Creating test database for alias 'baz_database'...
>
>
> This is especially annoying when you're running just one test, but have to
> wait 1:30 minutes just for these test databases.
>
> *Is there any way to speed this up? *Either by parallelizing it or in any
> other way. A few months ago I tried some naive code that parallelizes these
> actions, but it failed. (Unfortunately I don't have the error message
> saved.)
>
>
> Thanks,
> Ram.
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com?utm_medium=email_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/-djWwBB5xac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/43DDD6E9-EAA8-4162-BDB3-665F3CCA00E0%40gmail.com
> <https://groups.google.com/d/msgid/django-users/43DDD6E9-EAA8-4162-BDB3-665F3CCA00E0%40gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANXboVaX%2B737m4G-pXtvhvor00fD-3yknvCc%3DngnThZL0Jz5Bw%40mail.gmail.com.


Re: Creating test databases in parallel

2020-04-01 Thread Thomas Lockhart
If you are trying to optimize the test flow, then you may want to spend some 
time shrinking your test databases to a more manageable size. Or have two sets; 
abbreviated and full, with the larger one to exercise your (unknown) edge cases.

hth

- Tom

> On Apr 1, 2020, at 2:25 AM, cool-RR  wrote:
> 
> Hi guys,
> 
> I'm trying to optimize our Django testing workflow.
> 
> We have 7 different databases, and Django spends a lot of time on these 
> lines: 
> 
> Creating test database for alias 'main_database'...
> Creating test database for alias 'foo_database'...
> Creating test database for alias 'bar_database'...
> Creating test database for alias 'baz_database'...
> 
> This is especially annoying when you're running just one test, but have to 
> wait 1:30 minutes just for these test databases.
> 
> Is there any way to speed this up? Either by parallelizing it or in any other 
> way. A few months ago I tried some naive code that parallelizes these 
> actions, but it failed. (Unfortunately I don't have the error message saved.)
> 
> 
> Thanks,
> Ram.
> 
> -- 
> 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, send an 
> email to django-users+unsubscr...@googlegroups.com 
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43DDD6E9-EAA8-4162-BDB3-665F3CCA00E0%40gmail.com.


Re: Creating test databases in parallel

2020-04-01 Thread Ram Rachum
This is a general article about concurrency in Python. I'm very good with
concurrency in Python, I'm asking about a specific case here.

On Wed, Apr 1, 2020 at 1:20 PM Motaz Hejaze  wrote:

> Long article somehow , but very informative ...
>
> https://realpython.com/python-concurrency/
>
> On Wed, 1 Apr 2020, 11:25 am cool-RR,  wrote:
>
>> Hi guys,
>>
>> I'm trying to optimize our Django testing workflow.
>>
>> We have 7 different databases, and Django spends a lot of time on these
>> lines:
>>
>>
>> Creating test database for alias 'main_database'...
>> Creating test database for alias 'foo_database'...
>> Creating test database for alias 'bar_database'...
>> Creating test database for alias 'baz_database'...
>>
>>
>> This is especially annoying when you're running just one test, but have
>> to wait 1:30 minutes just for these test databases.
>>
>> *Is there any way to speed this up? *Either by parallelizing it or in
>> any other way. A few months ago I tried some naive code that parallelizes
>> these actions, but it failed. (Unfortunately I don't have the error message
>> saved.)
>>
>>
>> Thanks,
>> Ram.
>>
>> --
>> 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, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/-djWwBB5xac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHV4E-c9dGVSG69K%3DNN3GUuVDrAGacLijQeDD6ZFUU3LXNPL3Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHV4E-c9dGVSG69K%3DNN3GUuVDrAGacLijQeDD6ZFUU3LXNPL3Q%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANXboVZdXOhz1G2ja%2B0MPxE9USfU-6UhROufy%2BHVVTc-GYhZDA%40mail.gmail.com.


Re: Creating test databases in parallel

2020-04-01 Thread Motaz Hejaze
Long article somehow , but very informative ...

https://realpython.com/python-concurrency/

On Wed, 1 Apr 2020, 11:25 am cool-RR,  wrote:

> Hi guys,
>
> I'm trying to optimize our Django testing workflow.
>
> We have 7 different databases, and Django spends a lot of time on these
> lines:
>
>
> Creating test database for alias 'main_database'...
> Creating test database for alias 'foo_database'...
> Creating test database for alias 'bar_database'...
> Creating test database for alias 'baz_database'...
>
>
> This is especially annoying when you're running just one test, but have to
> wait 1:30 minutes just for these test databases.
>
> *Is there any way to speed this up? *Either by parallelizing it or in any
> other way. A few months ago I tried some naive code that parallelizes these
> actions, but it failed. (Unfortunately I don't have the error message
> saved.)
>
>
> Thanks,
> Ram.
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-c9dGVSG69K%3DNN3GUuVDrAGacLijQeDD6ZFUU3LXNPL3Q%40mail.gmail.com.


Creating test databases in parallel

2020-04-01 Thread cool-RR
Hi guys,

I'm trying to optimize our Django testing workflow.

We have 7 different databases, and Django spends a lot of time on these 
lines: 


Creating test database for alias 'main_database'...
Creating test database for alias 'foo_database'...
Creating test database for alias 'bar_database'...
Creating test database for alias 'baz_database'...


This is especially annoying when you're running just one test, but have to 
wait 1:30 minutes just for these test databases.

*Is there any way to speed this up? *Either by parallelizing it or in any 
other way. A few months ago I tried some naive code that parallelizes these 
actions, but it failed. (Unfortunately I don't have the error message 
saved.)


Thanks,
Ram.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6619ce10-6a0e-4fde-8d2c-fb81e6e2bd2c%40googlegroups.com.


Issue with Fixutre loading with multiple test cases on Postgres - duplicate key value violates unique constraint

2020-02-24 Thread Lokesh


class Test1(TestCase):
fixtures = ['fixture.json']

@classmethod
def tearDownClass(cls):
super(TestCase, cls).tearDownClass()

def test_demo(self):
u = User.objects.get(username='testuser1')
#some testing - removed actual tests as we can replicate the issue with 
even this code

class Test2(TestCase):
fixtures = ['fixture.json']

def test_demo2(self):
u = User.objects.get(username='testuser1')
#Some testing


I have these two test cases and my fixture has 2 rows in total, one for the 
User table with pk=1, and the other for profile table (one-to-one relation 
with User table)

If I run the test cases independently, both of the work perfect;y. But if I 
run them both at the same time, I get this error

Could not load app1.Profile(pk=1): duplicate key value violates unique 
> constraint "app1_profile_user_id_key"


>From my understanding of the documentation, Django will rollback all 
fixtures after the TestCase is done so that the DB is back to the point 
where only migrations are done and no fixture data is present.  

 Few StackOverflow answers suggested that we need to make an explicit call 
to teardown after the test case is done. So I added this code

@classmethod
def tearDownClass(cls):
super(TestCase, cls).tearDownClass()

This helps in running both the test cases together. But this leads to a new 
issue of DB not being flushed between test cases. Filed a bug report in 
detail on Bug tracker <https://code.djangoproject.com/ticket/31299>. 


Is there something I'm missing here? Any help would be greatly appreciated.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10245efe-9789-4ff9-9eda-a3f4bbc343df%40googlegroups.com.


Saving np.nan to sqlite database Django 2.1 in unit test fails

2020-02-13 Thread BK
I upgraded to django 2.1 and some of my unit tests (which use a sqlite 
database) are failing with the following:

  File 
"/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/db/models/query.py",
 line 268, in __iter__
2113self._fetch_all()
2114  File 
"/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/db/models/query.py",
 line 1186, in _fetch_all
2115self._result_cache = list(self._iterable_class(self))
2116  File 
"/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/db/models/sql/compiler.py",
 line 1042, in apply_converters
2117value = converter(value, expression, connection)
2118  File 
"/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/django/db/backends/sqlite3/operations.py",
 line 254, in converter
2119return create_decimal(value).quantize(quantize_value, 
context=expression.output_field.context)
2120TypeError: argument must be int of float



The unit test involves adding numpy.nan (among other things) to the database 
(in a models.DecimalField field) and at some point later in the test we are 
querying that data and when it try's to evaluate the query set the above error 
occurs.


The following code in sqlite/operations.py was changed from 2.0 to 2.1 which 
seems to be the source of the error.

FROM Django 2.0

def convert_decimalfield_value(self, value, expression, connection):
if value is not None:
value = expression.output_field.format_number(value)
# Value is not converted to Decimal here as it will be converted
# later in BaseExpression.convert_value().
return value



FROM Django 2.1

def get_decimalfield_converter(self, expression):
# SQLite stores only 15 significant digits. Digits coming from
# float inaccuracy must be removed.
create_decimal = decimal.Context(prec=15).create_decimal_from_float
if isinstance(expression, Col):
quantize_value = 
decimal.Decimal(1).scaleb(-expression.output_field.decimal_places)

def converter(value, expression, connection):
if value is not None:
return create_decimal(value).quantize(quantize_value, 
context=expression.output_field.context)
else:
def converter(value, expression, connection):
if value is not None:
return create_decimal(value)
return converter



Has anyone faced this issuenot sure what other details to provide...happy 
to provide more upon request.

Python 3.5.9 (default, Nov 24 2019, 01:35:13)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sqlite3

In [2]: sqlite3.version
Out[2]: '2.6.0'

In [3]: sqlite3.sqlite_version
Out[3]: '3.22.0'


Django==2.1.15
mysqlclient==1.3.9

NumPy==1.11.1
pandas==0.19.2


-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68734337-fa09-4ea1-8834-e1a76ea734bb%40googlegroups.com.


Re: Test -Error :AssertionError: 404 != 200

2020-02-02 Thread Integr@te System
Hi man,

How about pk you expect to test by declare in test.py with '/post/264, so
!= 200 in result!?


On Sun, Feb 2, 2020, 22:05 Body Abdo  wrote:

> Dear all
>
> I can't do the test -error is
> self.assertEqual(response.status_code, 200)
> AssertionError: 404 != 200
> My code is
> views.py
>
> class DetailPageView(DetailView):
> model = Series
> 
> template_name='/var/www/project/tapelss/movies/archive/templates/archive/detail.html'
>
>
> urls.py
>
> app_name = 'archive'
> urlpatterns =[
> path('',views.indexing, name ='indexing'),
> path('post//', DetailPageView.as_view(), name='post_detail'),
> path('post',HomePageView.as_view(), name ='home'),
> path('page',views.page, name= 'page'),
>
>
> tests.py
>
> def test_post_detail_view(self):
> response = self.client.get('/post/264/')
> no_response = self.client.get('/post/100/')
> self.assertEqual(response.status_code, 200)
> self.assertEqual(no_response.status_code, 404)
> self.assertContains(response,'Nice body content')
> self.assertTemplateUsed(response, 'detail.html')
>
>
>
>
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWqTPBf%3DYpHWBZOVdXWmyTfY2KwhWiy7V%3DqREY_nYuRdpw%40mail.gmail.com.


Test -Error :AssertionError: 404 != 200

2020-02-02 Thread Body Abdo
Dear all

I can't do the test -error is 
self.assertEqual(response.status_code, 200)
AssertionError: 404 != 200
My code is
views.py 

class DetailPageView(DetailView):
model = Series

template_name='/var/www/project/tapelss/movies/archive/templates/archive/detail.html'


urls.py

app_name = 'archive'
urlpatterns =[
path('',views.indexing, name ='indexing'),
path('post//', DetailPageView.as_view(), name='post_detail'),
path('post',HomePageView.as_view(), name ='home'),
path('page',views.page, name= 'page'),


tests.py

def test_post_detail_view(self):
response = self.client.get('/post/264/')
no_response = self.client.get('/post/100/')
self.assertEqual(response.status_code, 200)
self.assertEqual(no_response.status_code, 404)
self.assertContains(response,'Nice body content')
self.assertTemplateUsed(response, 'detail.html')





-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com.


Re: add icmp test

2020-01-26 Thread Gil Obradors
Of course, as pure python


https://stackoverflow.com/a/10402323

Missatge de paulo milo escano  del dia dg., 26
de gen. 2020 a les 16:41:

> can django support ping test, such as using subprocess module
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/08519882-2a8b-408b-b939-8ab80c718bf8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/08519882-2a8b-408b-b939-8ab80c718bf8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK-JoTT6%3DiX5Dy0WiqUH%3DSSLtujscNToghcXa4B_CnkZ_PYyew%40mail.gmail.com.


add icmp test

2020-01-26 Thread paulo milo escano
can django support ping test, such as using subprocess module

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08519882-2a8b-408b-b939-8ab80c718bf8%40googlegroups.com.


Re: Error with running test suite while contributing to django

2020-01-25 Thread Muhammed abdul Quadir owais
Oh!
Reply me … if you find the solution of it …

thanks

> On 26-Jan-2020, at 12:13 AM, aakansha jain  wrote:
> 
> I am also getting the same issue.
> I am to getting how to run the django development environment so that I can 
> contribute to Django.
> 
> On Friday, January 24, 2020 at 6:10:40 PM UTC+5:30, Muhammed abdul Quadir 
> owais wrote:
> Hi , 
> 
> I want help over here ,..
> I'm a newbie for django contributions so I got stuck over here...
> After cloning the django from git hub ( obviously after the action of fork) 
> and running commands (like $ python -m pip install -e 
> /path/to/your/local/clone/django/
> and $ python -m pip install -r requirements/py3.txt (no errors here) then ,.. 
> then after cd to tests then running this command 
> ./runtests.py
> )
> the test here is giving as response..
> 
> ss...sss..s..ss..sss..s.s..s...s.s...s.s..s..ss..s...sss...s.ssss.s..s.s.s.sss..s..s..s.s......s..s...ss...x...s.x.sss.s...s...s

Re: Error with running test suite while contributing to django

2020-01-25 Thread aakansha jain
I am also getting the same issue.
I am to getting how to run the django development environment so that I can 
contribute to Django.

On Friday, January 24, 2020 at 6:10:40 PM UTC+5:30, Muhammed abdul Quadir 
owais wrote:
>
> Hi , 
>
> I want help over here ,..
> I'm a newbie for django contributions so I got stuck over here...
> After cloning the django from git hub ( obviously after the action of 
> fork) and running commands (like $ python -m pip install -e 
> /path/to/your/local/clone/django/
> and $ python -m pip install -r requirements/py3.txt (no errors here) then 
> ,.. 
> then after cd to tests then running this command ./runtests.py
> )
> the test here is giving as response..
>
> ss...sss..s..ss..sss..s.s..s...s.s...s.s..s..ss..s...sss...s.ssss.s..s.s.s.sss..s..s..s.s......s..s...ss...x...s.x.sss.s...s...s.s...

Error with running test suite while contributing to django

2020-01-24 Thread Muhammed abdul Quadir owais
Hi , 

I want help over here ,..
I'm a newbie for django contributions so I got stuck over here...
After cloning the django from git hub ( obviously after the action of fork) 
and running commands (like $ python -m pip install -e 
/path/to/your/local/clone/django/
and $ python -m pip install -r requirements/py3.txt (no errors here) then 
,.. 
then after cd to tests then running this command ./runtests.py
)
the test here is giving as response..

ss...sss..s..ss..sss..s.s..s...s.s...s.s..s..ss..s...sss...s.ssss.s..s.s.s.sss..s..s..s.s......s..s...ss...x...s.x.sss.s...s...s.s...s..sss

When I use requests test loginView, return 302 and response header set-cookie , in sessionid line, there are always have a "SameSite=Lax," before sessionid string. This causes client cookies parser pr

2020-01-08 Thread bjxyys XIN


{set-cookie: 
csrftoken=dsEtx2CP6rX5bhIbRmkTOv5LmciytID5t6ShQbgNMTALTnhCoXdxWQ1TcAzxQoDO; 
expires=Wed, 06 Jan 2021 17:01:00 GMT; Max-Age=31449600; Path=/; 
SameSite=Lax,sessionid=2rtrkbnhc8m30iqs7sw4em014hr6a3ss; expires=Wed, 22 Jan 
2020 17:01:00 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax, location: 
/, cache-control: max-age=0, no-cache, no-store, must-revalidate, private, 
date: Wed, 08 Jan 2020 17:01:00 GMT, vary: Cookie, content-length: 0, 
x-frame-options: DENY, content-type: text/html; charset=utf-8, 
x-content-type-options: nosniff, server: WSGIServer/0.2 CPython/3.7.6, expires: 
Wed, 08 Jan 2020 17:01:00 GMT}



-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/405d95e3-7292-4a43-8fc9-474521bb4287%40googlegroups.com.


Re: Unable to create a new virtual environement 'test'

2019-12-11 Thread Hima Bindu chowdary
it worked! really appreciate the help!

On Wednesday, December 4, 2019 at 10:24:30 PM UTC+5:30, Manjunatha C wrote:
>
> Python -m venv envname 
>
> Try with this command

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d18ddcf1-0ad5-4a5e-a88e-bf605fb47943%40googlegroups.com.


Unable to create a new virtual environement 'test'

2019-12-04 Thread Manjunatha C
Python -m venv envname

Try with this command

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ecfbbe3b-dda3-435e-9b29-5a7a8937ea69%40googlegroups.com.


Re: Unable to create a new virtual environement 'test'

2019-12-04 Thread Suraj Thapa FC
Wrote the following
Virtualenv test

On Wed, 4 Dec 2019, 4:57 pm Hima Bindu chowdary, 
wrote:

> I had created a virtualwrapper then had to create a virtual env called test
> when i ran the following command i got this :
>
> C:\Users\User>py -m pip install virtualenv test
> Requirement already satisfied: virtualenv in
> c:\users\user\appdata\local\programs\python\python38\lib\site-packages
> (16.7.8)
> ERROR: Could not find a version that satisfies the requirement test (from
> versions: none)
> ERROR: No matching distribution found for test
>
> I need to create a virtual environment but it says it is already present..
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/48edad31-e33c-4460-91c0-f80b7e6adce4%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/48edad31-e33c-4460-91c0-f80b7e6adce4%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPjsHcFP48cOdtgttMSRUTAua2mJsKnEq_-CNY15-tqx9B5hag%40mail.gmail.com.


Unable to create a new virtual environement 'test'

2019-12-04 Thread Hima Bindu chowdary
I had created a virtualwrapper then had to create a virtual env called test
when i ran the following command i got this :

C:\Users\User>py -m pip install virtualenv test
Requirement already satisfied: virtualenv in 
c:\users\user\appdata\local\programs\python\python38\lib\site-packages 
(16.7.8)
ERROR: Could not find a version that satisfies the requirement test (from 
versions: none)
ERROR: No matching distribution found for test

I need to create a virtual environment but it says it is already present..

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/48edad31-e33c-4460-91c0-f80b7e6adce4%40googlegroups.com.


Unit test in django

2019-12-02 Thread Saswat Ray
*def webhook_register(request, organization_pk, campaign_id):user_id =
Campaign.objects.filter(id=campaign_id)user_id =
user_id[0].__dict__["user_id"]# social_user_details =
UserSocialAuth.objects.filter(provider=request.GET["provider"],
user_id=user_id)social_user_details =
UserSocialAuth.objects.filter(provider="shopify", user_id=user_id)shop
= social_user_details[0].__dict__['extra_data']['shop']
SOCIAL_AUTH_ACCESS_TOKEN =
social_user_details[0].__dict__['extra_data']['access_token']# shop =
'store-adi.myshopify.com <http://store-adi.myshopify.com>'headers = {
  "X-Shopify-Access-Token": SOCIAL_AUTH_ACCESS_TOKEN,"Accept":
"application/json","Content-Type": "application/json",}
payload = {"webhook": {"topic": "orders/create",
"address": "https://%s/webhook/receiver/shopify/%s; % (NGROK_DOMAIN,
campaign_id),"format": "json"}}response =
requests.post("https://; + shop + "/admin/api/2019-10/webhooks.json",
data=json.dumps(payload), headers=headers)   #
print(response.content)return HttpResponse('success')*


*i am writing unitest for the above function,there are some Factory and
fakers method is used. I am looking how i can convert this *
user_id = Campaign.objects.filter(id=campaign_id)

to equivalent statment for unit test using  CampaignFactory method .



*Thanks*,
*Saswat*

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEhPkLEVGr6P4w78KD%2BPbP0%3DeNYFcFWQZaFOAyQJm_GkGJjGVw%40mail.gmail.com.


Django Rest Framework test fails or passes, depending on number of functions in APITestCase class

2019-10-24 Thread Conor
Hei all,

I have an issue with a test class (APITestCase) where a function can pass 
the test if it is the only function within the class, or fail, if it is one 
of two or more functions.

I have put this question on Stack Overflow where it is available with nicer 
formatting. 

https://stackoverflow.com/questions/58530256/django-rest-framework-tests-fail-and-pass-depending-on-number-of-functions

If I run the following, the test will succeed.

class AudioTests(APITestCase):
# setup a test user and a factory
# factory = APIRequestFactory()
test_user = None

@classmethod
def setUpTestData(cls):
importer()  # imports data into the database
cls.test_user = User(username='jim', password='monkey123', 
email='j...@jim.com')
cls.test_user.save()


def test_audio_retrieve(self):
"""
Check that audio returns a 200 OK
"""
factory = APIRequestFactory()
view = AudioViewSet.as_view(actions={'get': 'retrieve'})

# Make an authenticated request to the view...
request = factory.get('/api/v1/audio/')

# force refresh of user
self.test_user.refresh_from_db()
user = User.objects.get(username='jim')

force_authenticate(request, user=user)
response = view(request, pk="2")

self.assertContains(response, 'audio')
self.assertEqual(response.status_code, status.HTTP_200_OK)

But if I add a second method as show in the code below, the newly added 
test_audio_list() will pass, but the previously passing 
test_audio_retrieve() will fail with a 404.

class AudioTests(APITestCase):
# setup a test user and a factory
# factory = APIRequestFactory()
test_user = None

@classmethod
def setUpTestData(cls):
importer()  # imports data into the database
cls.test_user = User(username='jim', password='monkey123', 
email='j...@jim.com')
cls.test_user.save()

def test_audio_list(self):
"""
Check that audo returns a 200 OK
"""
factory = APIRequestFactory()
view = AudioViewSet.as_view(actions={'get': 'list'})

# Make an authenticated request to the view...
request = factory.get('/api/v1/audio/')

self.test_user.refresh_from_db()
force_authenticate(request, user=self.test_user)
response = view(request, pk="1")

self.assertContains(response, 'audio/c1ha')
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_audio_retrieve(self):
"""
Check that audio returns a 200 OK
"""
factory = APIRequestFactory()
view = AudioViewSet.as_view(actions={'get': 'retrieve'})

# Make an authenticated request to the view...
request = factory.get('/api/v1/audio/')

# force refresh of user
self.test_user.refresh_from_db()
user = User.objects.get(username='jim')

force_authenticate(request, user=user)
response = view(request, pk="2")

self.assertContains(response, 'audio')
self.assertEqual(response.status_code, status.HTTP_200_OK)

I'm going slightly crackers trying to find out what's going run, but I am 
completely out of ideas. Any light anyone can shed on this is much 
appreciated.

Cheers,

Conor

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e3a91932-11a2-482d-a7ca-8bbaf460bb79%40googlegroups.com.


Re: facing issue on unit test

2019-09-08 Thread Arulselvam K
Thanks!, So for each test , do i need to add same test data? or do we have 
any other way not to repeat the same test data?

On Tuesday, 13 August 2019 20:32:16 UTC+5:30, Vinicius Assef wrote:
>
> The database is cleared after each test method.
>
> So, in a new testcase your database is empty.
>
> On Tue, 13 Aug 2019 at 00:34, Arulselvam K  > wrote:
>
>> Have hosted the code @ "https://github.com/tbone230590/plib; 
>> Here is the problem I have two models Book and IssuedBook, IssuedBook 
>> have foreign key relation to Book object.Those models are defined @ 
>> "/api/data/models" I have unit tests for testing those models and are 
>> available @ "/api/unit_tests/models". 
>> I am able to test Book model successfully. But I have a test for 
>> IssuedBook model which is referring Book model is getting failed. 
>> It seems cause of the problem is referring Book object created in 
>> BookTestCase that was previously run. But I dont understand that why Book 
>> record getting deleted after first testcase execution.
>> Could you educate me on this to solve the problem?
>>
>> -- 
>> 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, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3bd0af6e-7e6d-4115-9c95-f92c4d9ca60d%40googlegroups.com.


Re: facing issue on unit test

2019-08-13 Thread Vinicius Assef
The database is cleared after each test method.

So, in a new testcase your database is empty.

On Tue, 13 Aug 2019 at 00:34, Arulselvam K  wrote:

> Have hosted the code @ "https://github.com/tbone230590/plib;
> Here is the problem I have two models Book and IssuedBook, IssuedBook have
> foreign key relation to Book object.Those models are defined @
> "/api/data/models" I have unit tests for testing those models and are
> available @ "/api/unit_tests/models".
> I am able to test Book model successfully. But I have a test for
> IssuedBook model which is referring Book model is getting failed.
> It seems cause of the problem is referring Book object created in
> BookTestCase that was previously run. But I dont understand that why Book
> record getting deleted after first testcase execution.
> Could you educate me on this to solve the problem?
>
> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFmXjSDqk2mahFjnKB-GJOAx6h9kJMGGo1aW29K%3DcOAk6mwP9g%40mail.gmail.com.


facing issue on unit test

2019-08-12 Thread Arulselvam K
Have hosted the code @ "https://github.com/tbone230590/plib; 
Here is the problem I have two models Book and IssuedBook, IssuedBook have 
foreign key relation to Book object.Those models are defined @ 
"/api/data/models" I have unit tests for testing those models and are 
available @ "/api/unit_tests/models". 
I am able to test Book model successfully. But I have a test for IssuedBook 
model which is referring Book model is getting failed. 
It seems cause of the problem is referring Book object created in 
BookTestCase that was previously run. But I dont understand that why Book 
record getting deleted after first testcase execution.
Could you educate me on this to solve the problem?

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cf28d61d-8582-4148-a14a-9349fdfcca8f%40googlegroups.com.


Re: Test

2019-08-06 Thread Mike Dewhirst

On 7/08/2019 1:35 pm, Tosin Ayoola wrote:
Halo guyz,  working on an e-commerce project & I rili wan write the 
test for this project,  hoping someone can lead me in direction to go


https://docs.djangoproject.com/en/2.2/topics/testing/


--
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, send 
an email to django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHLKn716OH2SPV1S5N4JfOc%3DMpfpN-NaKzoaRAb%2B0HwOS1KwOA%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAHLKn716OH2SPV1S5N4JfOc%3DMpfpN-NaKzoaRAb%2B0HwOS1KwOA%40mail.gmail.com?utm_medium=email_source=footer>.


--
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad9ca54b-e641-d90d-db9c-34e61ad2c66c%40dewhirst.com.au.


Test

2019-08-06 Thread Tosin Ayoola
Halo guyz,  working on an e-commerce project & I rili wan write the test
for this project,  hoping someone can lead me in direction to go

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHLKn716OH2SPV1S5N4JfOc%3DMpfpN-NaKzoaRAb%2B0HwOS1KwOA%40mail.gmail.com.


Raise concurrent.futures._base.CancelledError when i test django channels websocket

2019-06-11 Thread nima
Hi. I'm using Django channels in server side for a speech to text 
application. When I test websocket with jmeter(+120 user or thread in 1 
second), about half of requests fail. Here is my code:

class Consumer(AsyncWebsocketConsumer):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.session = aiohttp.ClientSession()
# some other initialization

async def connect(self):
await self.accept()

async def received(self, text_data=None, bytes_data=None):
self.data = bytes_data
async with self.session:
  await self.send(bytes_data=(await 
self._fetch(self.session)).encode())

async def _fetch(self, client):
async with client.post(url=self.url,
  headers=self.headers,
  
params=self.querystrings,
  data=self.data) as 
resp:
return await resp.text()



for 100-120 requests in 1 sec(i.e. 100-120 users in jmeter) it works well. 
But for +120 requests some of them failed. Each request sends 319523 bytes 
to websocket and then websocket sends them to an api and send back 
response. Here is the exception that raise for +120 requests:



[2019-06-11 07:20:29 +] [31064] [ERROR] Exception in ASGI application

Traceback (most recent call last):

File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step

result = coro.throw(exc)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
674, in transfer_data

message = yield from self.read_message()

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
742, in read_message

frame = yield from self.read_data_frame(max_size=self.max_size)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
815, in read_data_frame

frame = yield from self.read_frame(max_size)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
884, in read_frame

extensions=self.extensions,

File "/usr/local/lib/python3.5/dist-packages/websockets/framing.py", line 
99, in read

data = yield from reader(2)

File "/usr/lib/python3.5/asyncio/streams.py", line 669, in readexactly

yield from self._wait_for_data('readexactly')

File "/usr/lib/python3.5/asyncio/streams.py", line 459, in _wait_for_data

yield from self._waiter

File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__

yield self # This tells Task to wait for completion.

File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup

future.result()

File "/usr/lib/python3.5/asyncio/futures.py", line 285, in result

raise CancelledError

concurrent.futures._base.CancelledError


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

File 
"/usr/local/lib/python3.5/dist-packages/uvicorn/protocols/websockets/websockets_impl.py",
 
line 146, in run_asgi

result = await self.app(self.scope, self.asgi_receive, self.asgi_send)

File "/usr/local/lib/python3.5/dist-packages/uvicorn/middleware/asgi2.py", 
line 7, in __call__

await instance(receive, send)

File "/usr/local/lib/python3.5/dist-packages/channels/sessions.py", line 
183, in __call__

return await self.inner(receive, self.send)

File "/usr/local/lib/python3.5/dist-packages/channels/middleware.py", line 
41, in coroutine_call

await inner_instance(receive, send)

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
59, in __call__

[receive, self.channel_receive], self.dispatch

File "/usr/local/lib/python3.5/dist-packages/channels/utils.py", line 52, 
in await_many_dispatch

await dispatch(result)

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
73, in dispatch

await handler(message)

File 
"/usr/local/lib/python3.5/dist-packages/channels/generic/websocket.py", 
line 198, in websocket_receive

await self.receive(bytes_data=message["bytes"])

File "/home/nima/stt/stt_project/stt_app/consumer.py", line 257, in receive

await self.send(bytes_data=(await self._fetch(self.session)).encode())

File 
"/usr/local/lib/python3.5/dist-packages/channels/generic/websocket.py", 
line 213, in send

await super().send({"type": "websocket.send", "bytes": bytes_data})

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
81, in send

await self.base_send(message)

File "/usr/local/lib/python3.5/dist-packages/channels/sessions.py", line 
236, in send

return await self.real_send(message)

File 
"/usr/local/lib/python3.5/dist-packages/uvicorn/protocols/w

possible bug: test loader fails if models/__init__.py defined

2019-05-08 Thread Matthew Hegarty
Hi

I have imported my model classes in models/__init__.py (as described in docs 
<https://docs.djangoproject.com/en/dev/ref/applications/#how-applications-are-loaded>
):

You must define or import all models in your application’s models.py or 
> models/__init__.py. Otherwise, the application registry may not be fully 
> populated at this point, which could cause the ORM to malfunction.


However after doing this, running tests with ./manage.py test -k causes the 
unittest loader to fail with:

ERROR: myapp.api.models (unittest.loader._FailedTest)
--
ImportError: Failed to import test module: myapp.api.models
Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
  File "/usr/lib/python3.6/unittest/loader.py", line 369, in 
_get_module_from_name
__import__(name)
  File "/myapp/api/models/__init__.py", line 5, in 
from .api_key import ApiKey
  File "/myapp/api/models/api_key.py", line 17, in 
class ApiKey(models.Model):
  File "/-Z_V0-nQl/lib/python3.6/site-packages/django/db/models/base.py", 
line 111, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class myapp.api.models.api_key.ApiKey doesn't declare 
an explicit app_label and isn't in an application in INSTALLED_APPS.


The workaround is to run: ./manage.py test -k api.tests  
(then the test loader doesn't try to load __init__.py)

This issue is discussed on SO 
<https://stackoverflow.com/questions/21069880/running-django-tutorial-tests-fail-no-module-named-polls-tests>
 
- I wondered if it could be a bug?

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4f622eb1-d3fc-4fe9-a6fa-e097f7257130%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django test

2019-04-22 Thread Elber Tavares
Test django

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20190421230217.7EDA0C248C%40localhost.
For more options, visit https://groups.google.com/d/optout.


Re: Inconsistent Django test results depending upon how the test is called in Django 1.5.1 running on Python 2.7.4

2019-03-27 Thread Ruben Alves
I had a similar problem and I solved it by making all tests inherit from 
`django.test.TestCase`.  I had some tests inheriting from 
`unittest.TestCase`, which doesn't reset the database after the test is 
finished.

I found the answer on https://stackoverflow.com/a/436795/6490637

Em segunda-feira, 2 de dezembro de 2013 00:24:01 UTC, Paul Whipp escreveu:
>
> I have test cases that pass when tested individually, pass when the full 
> app is tested but fail when the tests for the entire project are run:
>
> (lsapi)~ $ django test
> Creating test database for alias 'default'...
> .s.x..Exception
>  RuntimeError: 'maximum recursion depth exceeded' in  0x13447d0> ignored
> Exception RuntimeError: 'maximum recursion depth exceeded' in  remove at 0x13447d0> ignored
> Exception RuntimeError: 'maximum recursion depth exceeded' in  remove at 0x13447d0> ignored
> ...ssE.E.E.Setting
>  content_object to liquid app one
> .EEE....
> ==
> ERROR: test_get_direct_notes (lsapi.tests.DirectGetTestCase)
> --
> Traceback (most recent call last):
>   File "ls-api/lsapi/tests.py", line 869, in _method
> 
>   File "ls-core/lscore/model/note.py", line 37, in company
> return self.content_object.company
> AttributeError: 'NoneType' object has no attribute 'company'
> ...
>
>
> (lsapi)~ $ django test lsapi.NotesTestCase.test_wrong_user_cannot_put
> Creating test database for alias 'default'...
> .
> ------
> Ran 1 test in 0.241s
>
> OK
> Destroying test database for alias 'default'...
>
>
> (lsapi)~ $ django test lsapi
> Creating test database for alias 'default'...
> ...ss..Setting
>  content_object to liquid app one
> ...Exception RuntimeError: 'maximum recursion depth exceeded 
> while calling a Python object' in <_ctypes.DictRemover object at 0x46dac70> 
> ignored
> .....
> --
> Ran 303 tests in 71.469s
>
> OK (skipped=2)
> Destroying test database for alias 'default'...
>
> The 'django' command is an alias for django-admin.py. So the tests pass if 
> run as a single case or as a test suite when testing the entire app but 
> fail with errors if run when running the tests for all of the apps in the 
> project.
>
> Investigating the error in the full suite test: It is the result of an 
> attribute being None when it 'should' have a value. The attribute is a 
> content_object set up in a fixture.
>
> I added a debugging setattr on the class and nothing is setting it to 
> None so it seems that the fixture code is not being properly executed to 
> set up the object leading to the errors. The fixture is using content types 
> because it is for 'notes' that can be associated with various model classes:
>
> notes.py:
>
> ...
> class Note(TimeStampedModel):
> content_type = models.ForeignKey(ContentType)
> object_id = models.PositiveIntegerField()
> content_object = generic.GenericForeignKey('content_type', 'object_id')
> ...
> def __setattr__(self, key, value):
>   if key == 'content_object':
>   if value is None:
>   import pdb; pdb.set_trace()
>   print('Setting content_object to {0}'.format(value))
>   return super(Note, self).__setattr__(key, value)
>
> local_test.json:
>
> ...
>  {"pk": 1, "model": "lscore.note",
>   "fields": {"content_type": 16,
>"object_id": 2,
>"created_by": 4,
>&qu

Test FrameWork Cleanup

2019-03-22 Thread Gourav Sardana
Hey,

I am Gourav Sardana undergraduate computer science student.I am interested 
in the idea of test framework cleanup. @Mentors Can i ask you one thing?  
we have to build a software for improving code or we have to add this in 
our django core code?

Regards,
Gourav Sardana

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1ba6880e-dbb4-45af-a13a-548ad7d5320b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread jgibson
result = qs1.difference(qs2)

if Result is length 0 then all of 1 is in 2.

On Monday, March 18, 2019 at 8:15:19 AM UTC-4, Thomas Klopf wrote:
>
> Hello,
>   Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the 
> database, if possible.
>
> Thanks!
> Tom
>
>
> On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com 
> wrote:
>>
>> Tom,
>>
>> Could you clarify "fits into"?
>>
>> qs1 = Table.objects.all()
>> qs2 = Table.objects.filter(color='blue')
>>
>>
>> mo1 = qs1[0]
>>
>>
>> Are you trying to determine if mo1 is in qs2?
>>
>> Best
>>
>> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>>
>>> Hi all,
>>>   Please I have a question, couldn't find any answer for it..
>>>
>>>   Let's say I have 2 QuerySets:
>>>   1) Select all records from table
>>>   2) Select all records from table where color = "blue"
>>>
>>> So QuerySet #2 is more restricted than QuerySet #1
>>>
>>> So question is - if I get a model object from QuerySet #1, is it 
>>> possible to check if the model object is 'filtered'  or fits into QuerySet 
>>> #2, without actually executing the SQL for QuerySet #2 to find the record 
>>> again?
>>>
>>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
>>> would test if the record fits into the QuerySet in purely python/django.
>>>
>>> Thanks in advance!
>>> Tom
>>>
>>>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c5314fff-37cf-4763-9ab8-2c055add3901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread Jani Tiainen
Hi,

Note that Django querysets are lazy.

So running:

qs1 = MyModel.objects.all()

As is, doing that doesn't execute any queries. If you want filtered
objects, just add filter:

qs2 = qs1.filter(color="blue")

qs2 is not even evaluated yet. You need actually cause something that
evaluates queryset.

But if you want to fetch all objects from qs1 and then apply some
"filtering" you can just evaluate whole queryset and it's results
will be cached. You can use list comprehensions or itertools to filter your
objects in Python.


On Mon, Mar 18, 2019 at 2:16 PM Thomas Klopf  wrote:

> Hello,
>   Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the
> database, if possible.
>
> Thanks!
> Tom
>
>
> On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com
> wrote:
>>
>> Tom,
>>
>> Could you clarify "fits into"?
>>
>> qs1 = Table.objects.all()
>> qs2 = Table.objects.filter(color='blue')
>>
>>
>> mo1 = qs1[0]
>>
>>
>> Are you trying to determine if mo1 is in qs2?
>>
>> Best
>>
>> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>>
>>> Hi all,
>>>   Please I have a question, couldn't find any answer for it..
>>>
>>>   Let's say I have 2 QuerySets:
>>>   1) Select all records from table
>>>   2) Select all records from table where color = "blue"
>>>
>>> So QuerySet #2 is more restricted than QuerySet #1
>>>
>>> So question is - if I get a model object from QuerySet #1, is it
>>> possible to check if the model object is 'filtered'  or fits into QuerySet
>>> #2, without actually executing the SQL for QuerySet #2 to find the record
>>> again?
>>>
>>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally
>>> would test if the record fits into the QuerySet in purely python/django.
>>>
>>> Thanks in advance!
>>> Tom
>>>
>>> --
> 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, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a09cf16e-8f9c-4bf0-b382-708ba21d28bd%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a09cf16e-8f9c-4bf0-b382-708ba21d28bd%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with Django.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeVhEmC2kGeGmHYjRcq1KJJvhxwbUBEyHv8zdriHDF1eQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread Thomas Klopf
Hello,
  Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the 
database, if possible.

Thanks!
Tom


On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com wrote:
>
> Tom,
>
> Could you clarify "fits into"?
>
> qs1 = Table.objects.all()
> qs2 = Table.objects.filter(color='blue')
>
>
> mo1 = qs1[0]
>
>
> Are you trying to determine if mo1 is in qs2?
>
> Best
>
> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>
>> Hi all,
>>   Please I have a question, couldn't find any answer for it..
>>
>>   Let's say I have 2 QuerySets:
>>   1) Select all records from table
>>   2) Select all records from table where color = "blue"
>>
>> So QuerySet #2 is more restricted than QuerySet #1
>>
>> So question is - if I get a model object from QuerySet #1, is it possible 
>> to check if the model object is 'filtered'  or fits into QuerySet #2, 
>> without actually executing the SQL for QuerySet #2 to find the record again?
>>
>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
>> would test if the record fits into the QuerySet in purely python/django.
>>
>> Thanks in advance!
>> Tom
>>
>>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a09cf16e-8f9c-4bf0-b382-708ba21d28bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-15 Thread Phako Perez
You can create query as

def get_query(value=None):
if value:
  query = “select all records from table where color = ‘" + value + “‘
  query = “select all records from table”

return query

Sent from my iPhone

> On Mar 15, 2019, at 6:20 AM, jgib...@caktusgroup.com wrote:
> 
> Tom,
> 
> Could you clarify "fits into"?
> 
> qs1 = Table.objects.all()
> qs2 = Table.objects.filter(color='blue')
> 
> 
> mo1 = qs1[0]
> 
> 
> Are you trying to determine if mo1 is in qs2?
> 
> Best
> 
>> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>> Hi all,
>>   Please I have a question, couldn't find any answer for it..
>> 
>>   Let's say I have 2 QuerySets:
>>   1) Select all records from table
>>   2) Select all records from table where color = "blue"
>> 
>> So QuerySet #2 is more restricted than QuerySet #1
>> 
>> So question is - if I get a model object from QuerySet #1, is it possible to 
>> check if the model object is 'filtered'  or fits into QuerySet #2, without 
>> actually executing the SQL for QuerySet #2 to find the record again?
>> 
>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
>> would test if the record fits into the QuerySet in purely python/django.
>> 
>> Thanks in advance!
>> Tom
>> 
> 
> -- 
> 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, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/26c692ef-6e97-4fa2-b5ef-6ebb24e408cb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2A56D6F6-0AC6-4463-8887-F291E5915A9A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-15 Thread jgibson
Tom,

Could you clarify "fits into"?

qs1 = Table.objects.all()
qs2 = Table.objects.filter(color='blue')


mo1 = qs1[0]


Are you trying to determine if mo1 is in qs2?

Best

On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>
> Hi all,
>   Please I have a question, couldn't find any answer for it..
>
>   Let's say I have 2 QuerySets:
>   1) Select all records from table
>   2) Select all records from table where color = "blue"
>
> So QuerySet #2 is more restricted than QuerySet #1
>
> So question is - if I get a model object from QuerySet #1, is it possible 
> to check if the model object is 'filtered'  or fits into QuerySet #2, 
> without actually executing the SQL for QuerySet #2 to find the record again?
>
> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
> would test if the record fits into the QuerySet in purely python/django.
>
> Thanks in advance!
> Tom
>
>

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/26c692ef-6e97-4fa2-b5ef-6ebb24e408cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


test if model object fits into QuerySet without executing SQL?

2019-03-15 Thread Thomas Klopf
Hi all,
  Please I have a question, couldn't find any answer for it..

  Let's say I have 2 QuerySets:
  1) Select all records from table
  2) Select all records from table where color = "blue"

So QuerySet #2 is more restricted than QuerySet #1

So question is - if I get a model object from QuerySet #1, is it possible 
to check if the model object is 'filtered'  or fits into QuerySet #2, 
without actually executing the SQL for QuerySet #2 to find the record again?

I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
would test if the record fits into the QuerySet in purely python/django.

Thanks in advance!
Tom

-- 
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/64c7da25-67e2-498b-ba6c-4997122adf1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


test message

2019-02-25 Thread Mike Dewhirst
No need to answer this. I'm just seeing if googlegroups sends it me. 
Haven't much from the list since gmail got itself listed in SORBS the 
other day - and in particular I didn't get a message I posted in the 
browser.


--
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, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f90e83f0-82c4-d460-5080-7a28d4bf1961%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   9   10   >