# Path: wtfhack/base/models.py
# class Repo(models.Model):
#     # Full name is required
#     full_name = models.CharField(max_length=500, unique=True, null=False)
#     url = models.URLField(null=True)
#     language = models.ForeignKey(Language, related_name='repos')
#     description = models.CharField(max_length=500, null=True, blank=True)
# 
# 
#     def save(self, *args, **kwargs):
#         '''Override save method to set default url.'''
#         BASE = 'https://github.com/'
#         # Default url to base url + full_name
#         if not self.url:
#             self.url = BASE + self.full_name
#         super(Repo, self).save(*args, **kwargs)
# 
# 
#     def __unicode__(self):
#         return "{full_name}: {language}".format(full_name=self.full_name,
#                                                 language=self.language.name)
# 
# class Language(models.Model):
#     name = models.CharField(max_length=40, null=False)
#     learn_url = models.URLField(null=True, blank=True)
# 
#     @staticmethod
#     def all():
#         return [l.name for l in Language.objects.order_by('name')]
#     def __unicode__(self):
#         return self.name


from django.test import TestCase
from nose.tools import assert_equal
from wtfhack.base.models import Repo, Language
        self.ruby = Language.objects.create(name='ruby',
                                    learn_url="http://tryruby.org/levels/1/challenges/0")

    def test_model(self):
        assert_equal(len(Repo.objects.all()), 0)
        repo = Repo.objects.create(full_name='ruby/ruby',
                                    language=self.ruby)
        assert_equal(len(Repo.objects.all()), 1)
        assert_equal(repo.language.name, 'ruby')

    def test_save_url(self):
        # repo is saved without specifying url
        repo = Repo.objects.create(full_name='ruby/ruby', language=self.ruby)
        # url should default to base url + full name
        assert_equal(repo.url, u'https://github.com/ruby/ruby')

    def test_unicode(self):
        repo = Repo.objects.create(full_name='sloria/usv', language=self.python)
        assert_equal(str(repo), "sloria/usv: python")


class LanguageTest(TestCase):


    def test_model(self):
        lang = Language.objects.create(name='python',
                                    learn_url='http://www.diveintopython.net/toc/index.html')
        assert_equal(len(Language.objects.all()), 1)
        assert_equal(lang.name, 'python')
    def test_all(self):

# Path: wtfhack/base/models.py
# class Repo(models.Model):
#     # Full name is required
#     full_name = models.CharField(max_length=500, unique=True, null=False)
#     url = models.URLField(null=True)
#     language = models.ForeignKey(Language, related_name='repos')
#     description = models.CharField(max_length=500, null=True, blank=True)
# 
# 
#     def save(self, *args, **kwargs):
#         '''Override save method to set default url.'''
#         BASE = 'https://github.com/'
#         # Default url to base url + full_name
#         if not self.url:
#             self.url = BASE + self.full_name
#         super(Repo, self).save(*args, **kwargs)
# 
# 
#     def __unicode__(self):
#         return "{full_name}: {language}".format(full_name=self.full_name,
#                                                 language=self.language.name)
# 
# class Language(models.Model):
#     name = models.CharField(max_length=40, null=False)
#     learn_url = models.URLField(null=True, blank=True)
# 
#     @staticmethod
#     def all():
#         return [l.name for l in Language.objects.order_by('name')]
#     def __unicode__(self):
#         return self.name


# Path: wtfhack/base/unit_tests.py
from django.test import TestCase
from nose.tools import assert_equal
from wtfhack.base.models import Repo, Language

        self.ruby = Language.objects.create(name='ruby',
                                    learn_url="http://tryruby.org/levels/1/challenges/0")

    def test_model(self):
        assert_equal(len(Repo.objects.all()), 0)
        repo = Repo.objects.create(full_name='ruby/ruby',
                                    language=self.ruby)
        assert_equal(len(Repo.objects.all()), 1)
        assert_equal(repo.language.name, 'ruby')

    def test_save_url(self):
        # repo is saved without specifying url
        repo = Repo.objects.create(full_name='ruby/ruby', language=self.ruby)
        # url should default to base url + full name
        assert_equal(repo.url, u'https://github.com/ruby/ruby')

    def test_unicode(self):
        repo = Repo.objects.create(full_name='sloria/usv', language=self.python)
        assert_equal(str(repo), "sloria/usv: python")


class LanguageTest(TestCase):


    def test_model(self):
        lang = Language.objects.create(name='python',
                                    learn_url='http://www.diveintopython.net/toc/index.html')
        assert_equal(len(Language.objects.all()), 1)
        assert_equal(lang.name, 'python')
    def test_all(self):

        python = Language.objects.create(name='python',