# 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/views.py
# def get_repo(request, language):
#     language_obj = get_object_or_404(Language, name=language)
#     repos = Repo.objects.filter(language=language_obj)
#     # If there are repos with the chosen language
#     if repos.exists():
#         # Choose a random repo
#         repo = random.choice(repos)
#     else:
#         repo = None
# 
#     return render(request, 
#                     'base/home.html', 
#                     {'all_languages': Language.objects.order_by('name'),
#                     'selected': language,
#                     'repo': repo
#                     }
#                 )


from django.core.urlresolvers import reverse
from django_webtest import WebTest
from nose.tools import *
from wtfhack.base.models import Repo, Language
from wtfhack.base.views import get_repo
'''Functional tests using WebTest'''



class TestAUser(WebTest):

    def setUp(self):
        self.python = Language.objects.create(name='python',
                                    learn_url='http://www.diveintopython.net/toc/index.html')

# 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/views.py
# def get_repo(request, language):
#     language_obj = get_object_or_404(Language, name=language)
#     repos = Repo.objects.filter(language=language_obj)
#     # If there are repos with the chosen language
#     if repos.exists():
#         # Choose a random repo
#         repo = random.choice(repos)
#     else:
#         repo = None
# 
#     return render(request, 
#                     'base/home.html', 
#                     {'all_languages': Language.objects.order_by('name'),
#                     'selected': language,
#                     'repo': repo
#                     }
#                 )


# Path: wtfhack/functional_tests/webtest_tests.py
from django.core.urlresolvers import reverse
from django_webtest import WebTest
from nose.tools import *
from wtfhack.base.models import Repo, Language
from wtfhack.base.views import get_repo

'''Functional tests using WebTest'''



class TestAUser(WebTest):

    def setUp(self):
        self.python = Language.objects.create(name='python',
                                    learn_url='http://www.diveintopython.net/toc/index.html')

        self.ruby = Language.objects.create(name='ruby',