Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-31 Thread Alisue Lambda
> Alex
Well as Yo-Yo Ma said, sometime the tests stand for testing django's inner 
working thus the real models are required.

> Yo-Yo Ma
I haven't tried but thanks for the solution :-)


On Wednesday, July 16, 2014 11:17:56 PM UTC+9, Alisue Lambda wrote:
>
> Hi all. 
>
> Well today I tried Django 1.7c1 with my program and found that the 
> previous testing strategy seems not work.
>
> I have several models which only required during tests. Before Django 1.7, 
> I could create these kind of temporary models by defining these in 
> `app/tests/models.py` with `app_label` specification like this (
> https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
>  
> It was quite good strategy for me because I could reduce the dependency of 
> the apps and make the app independent.
>
> But now, it seems Django 1.7c1 cannot find this kind of definitions. I 
> have to add `app.tests` in `INSTALLED_APPS` which was not required before 
> Django 1.7c1.
> However, if I add `app.tests` and `app2.tests`, I have to modify `label` 
> of the `app2.tests` because there is already `app_label='tests'` in the 
> registry. It is quite tough job while I have a lot of apps which follow 
> this strategy to test the app.
> Additionally, I don't really want to list `app.tests` in my 
> `INSTALLED_APPS` while it is not actually app which required for the site.
>
> So I wonder if there are any better way to define the temporary models. In 
> summary, what I want to do is
>
> 1. I want to add temporary models which only required during tests
> 2. I don't want to mess the db with temporary models (except during tests)
>
> Any idea? Thank you for your cooperation.
>
>
> Best regard,
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c4ee6dc3-79c5-4222-8309-662aefc1d354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-29 Thread Yo-Yo Ma
I use mock for every testcase I have in my app (no queries in my entire 
test suite), but sometimes I also need to include a real model (but no 
queries or db), due to the complexity of the situation (e.g., relying on a 
bit more of Django's inner workings without having to mock 10-15 methods). 
In other words, despite unit tests being very controlled and specific to a 
few lines of code, sometimes I need to allow some infrastructure to run, in 
order to keep my tests simple, and more importantly, to keep them forward 
compatible.

To reiterate, I'm aware that, in a perfect world, the required components 
would just be mocked, but for my 9 test methods, I would have more than 
doubled the length of the tests and been left with an unreadable mess.

Here's the solution I came up with last night, after asking the question: 
https://gist.github.com/anonymous/a11898d0cd8ffc78b531 
(get_model(, ) was messier, due to the need for exception 
handling).

On Friday, August 29, 2014 10:57:05 AM UTC-4, Alex Chiaranda wrote:
>
> Hi, can't you guys mock these models ?
>
> On Thursday, August 28, 2014 9:31:04 PM UTC-3, Yo-Yo Ma wrote:
>>
>> Ugh... same problem here. It seems you can't really create a model in 
>> setUp anymore. I'll post a reply, if I find anything.
>>
>> On Wednesday, July 16, 2014 10:17:56 AM UTC-4, Alisue Lambda wrote:
>>>
>>> Hi all. 
>>>
>>> Well today I tried Django 1.7c1 with my program and found that the 
>>> previous testing strategy seems not work.
>>>
>>> I have several models which only required during tests. Before Django 
>>> 1.7, I could create these kind of temporary models by defining these in 
>>> `app/tests/models.py` with `app_label` specification like this (
>>> https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
>>>  
>>> It was quite good strategy for me because I could reduce the dependency of 
>>> the apps and make the app independent.
>>>
>>> But now, it seems Django 1.7c1 cannot find this kind of definitions. I 
>>> have to add `app.tests` in `INSTALLED_APPS` which was not required before 
>>> Django 1.7c1.
>>> However, if I add `app.tests` and `app2.tests`, I have to modify `label` 
>>> of the `app2.tests` because there is already `app_label='tests'` in the 
>>> registry. It is quite tough job while I have a lot of apps which follow 
>>> this strategy to test the app.
>>> Additionally, I don't really want to list `app.tests` in my 
>>> `INSTALLED_APPS` while it is not actually app which required for the site.
>>>
>>> So I wonder if there are any better way to define the temporary models. 
>>> In summary, what I want to do is
>>>
>>> 1. I want to add temporary models which only required during tests
>>> 2. I don't want to mess the db with temporary models (except during 
>>> tests)
>>>
>>> Any idea? Thank you for your cooperation.
>>>
>>>
>>> Best regard,
>>>
>>>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5cad5371-3a23-4f53-bc84-41a809976f04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-29 Thread Alex Chiaranda
Hi, can't you guys mock these models ?

On Thursday, August 28, 2014 9:31:04 PM UTC-3, Yo-Yo Ma wrote:
>
> Ugh... same problem here. It seems you can't really create a model in 
> setUp anymore. I'll post a reply, if I find anything.
>
> On Wednesday, July 16, 2014 10:17:56 AM UTC-4, Alisue Lambda wrote:
>>
>> Hi all. 
>>
>> Well today I tried Django 1.7c1 with my program and found that the 
>> previous testing strategy seems not work.
>>
>> I have several models which only required during tests. Before Django 
>> 1.7, I could create these kind of temporary models by defining these in 
>> `app/tests/models.py` with `app_label` specification like this (
>> https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
>>  
>> It was quite good strategy for me because I could reduce the dependency of 
>> the apps and make the app independent.
>>
>> But now, it seems Django 1.7c1 cannot find this kind of definitions. I 
>> have to add `app.tests` in `INSTALLED_APPS` which was not required before 
>> Django 1.7c1.
>> However, if I add `app.tests` and `app2.tests`, I have to modify `label` 
>> of the `app2.tests` because there is already `app_label='tests'` in the 
>> registry. It is quite tough job while I have a lot of apps which follow 
>> this strategy to test the app.
>> Additionally, I don't really want to list `app.tests` in my 
>> `INSTALLED_APPS` while it is not actually app which required for the site.
>>
>> So I wonder if there are any better way to define the temporary models. 
>> In summary, what I want to do is
>>
>> 1. I want to add temporary models which only required during tests
>> 2. I don't want to mess the db with temporary models (except during tests)
>>
>> Any idea? Thank you for your cooperation.
>>
>>
>> Best regard,
>>
>>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1d86fe6-717b-4bfd-ad54-bfcbcee83991%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-28 Thread Yo-Yo Ma
Ugh... same problem here. It seems you can't really create a model in setUp 
anymore. I'll post a reply, if I find anything.

On Wednesday, July 16, 2014 10:17:56 AM UTC-4, Alisue Lambda wrote:
>
> Hi all. 
>
> Well today I tried Django 1.7c1 with my program and found that the 
> previous testing strategy seems not work.
>
> I have several models which only required during tests. Before Django 1.7, 
> I could create these kind of temporary models by defining these in 
> `app/tests/models.py` with `app_label` specification like this (
> https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
>  
> It was quite good strategy for me because I could reduce the dependency of 
> the apps and make the app independent.
>
> But now, it seems Django 1.7c1 cannot find this kind of definitions. I 
> have to add `app.tests` in `INSTALLED_APPS` which was not required before 
> Django 1.7c1.
> However, if I add `app.tests` and `app2.tests`, I have to modify `label` 
> of the `app2.tests` because there is already `app_label='tests'` in the 
> registry. It is quite tough job while I have a lot of apps which follow 
> this strategy to test the app.
> Additionally, I don't really want to list `app.tests` in my 
> `INSTALLED_APPS` while it is not actually app which required for the site.
>
> So I wonder if there are any better way to define the temporary models. In 
> summary, what I want to do is
>
> 1. I want to add temporary models which only required during tests
> 2. I don't want to mess the db with temporary models (except during tests)
>
> Any idea? Thank you for your cooperation.
>
>
> Best regard,
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2a208687-4cf9-461f-9347-3a7efbfa066c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I create models which only required during tests in Django 1.7c1?

2014-07-16 Thread Alisue Lambda
Hi all. 

Well today I tried Django 1.7c1 with my program and found that the previous 
testing strategy seems not work.

I have several models which only required during tests. Before Django 1.7, 
I could create these kind of temporary models by defining these in 
`app/tests/models.py` with `app_label` specification like this (
https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py).
 
It was quite good strategy for me because I could reduce the dependency of 
the apps and make the app independent.

But now, it seems Django 1.7c1 cannot find this kind of definitions. I have 
to add `app.tests` in `INSTALLED_APPS` which was not required before Django 
1.7c1.
However, if I add `app.tests` and `app2.tests`, I have to modify `label` of 
the `app2.tests` because there is already `app_label='tests'` in the 
registry. It is quite tough job while I have a lot of apps which follow 
this strategy to test the app.
Additionally, I don't really want to list `app.tests` in my 
`INSTALLED_APPS` while it is not actually app which required for the site.

So I wonder if there are any better way to define the temporary models. In 
summary, what I want to do is

1. I want to add temporary models which only required during tests
2. I don't want to mess the db with temporary models (except during tests)

Any idea? Thank you for your cooperation.


Best regard,

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8192f21-4acd-4320-9efa-6f38fafce202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.