Re: About unit testing

2010-01-22 Thread Dougal Matthews
If you look at the tests in django-shorturls you can see how they created
models that were only used for the tests:


http://github.com/jacobian/django-shorturls/tree/master/src/shorturls/tests/


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2010/1/22 Gabriel Reis 

> Hi,
>
> I would like to know if it is mandatory to create an application and define
> my model in the models.py file or if it is possible to define a model
> locally in my test method (inside my TestCase class) and interact with it
> and saving without creating an application and the models.py. In other
> words, is it possible to force the creation of the table inside the test
> method?
> Example:
>
> class MyTestCase(TestCase):
>
> def test_something(self):
> class MyModel(models.Model):
> foo = CharField(max_length=10)
>
> call_something_to_sync_db()
>
> m = MyModel(foo='something')
> m.save()
>
>
> Thanks for your attention!
>
> Kind regards,
>
> Gabriel
>
> --
> Gabriel de Carvalho Nogueira Reis
> Software Developer
> +44 7907 823942
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: About unit testing

2010-01-22 Thread Larrik Jaerico
What are you actually trying to accomplish?

On Jan 22, 6:25 am, Gabriel Reis  wrote:
> Hi,
>
> I would like to know if it is mandatory to create an application and define
> my model in the models.py file or if it is possible to define a model
> locally in my test method (inside my TestCase class) and interact with it
> and saving without creating an application and the models.py. In other
> words, is it possible to force the creation of the table inside the test
> method?
> Example:
>
> class MyTestCase(TestCase):
>
>     def test_something(self):
>         class MyModel(models.Model):
>             foo = CharField(max_length=10)
>
>         call_something_to_sync_db()
>
>         m = MyModel(foo='something')
>         m.save()
>
> Thanks for your attention!
>
> Kind regards,
>
> Gabriel
>
> --
> Gabriel de Carvalho Nogueira Reis
> Software Developer
> +44 7907 823942

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



About unit testing

2010-01-22 Thread Gabriel Reis
Hi,

I would like to know if it is mandatory to create an application and define
my model in the models.py file or if it is possible to define a model
locally in my test method (inside my TestCase class) and interact with it
and saving without creating an application and the models.py. In other
words, is it possible to force the creation of the table inside the test
method?
Example:

class MyTestCase(TestCase):

def test_something(self):
class MyModel(models.Model):
foo = CharField(max_length=10)

call_something_to_sync_db()

m = MyModel(foo='something')
m.save()


Thanks for your attention!

Kind regards,

Gabriel

--
Gabriel de Carvalho Nogueira Reis
Software Developer
+44 7907 823942

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.