tests.py

1
""" tests.py - Contains tests and assertions for Gitar.
2
    Copyright © 2016 Maarten "Vngngdn" Vangeneugden
3
4
    This program is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU Affero General Public License as
6
    published by the Free Software Foundation, either version 3 of the
7
    License, or (at your option) any later version.
8
9
    This program is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Affero General Public License for more details.
13
14
    You should have received a copy of the GNU Affero General Public License
15
    along with this program. If not, see https://www.gnu.org/licenses/agpl.html.
16
"""
17
18
from django.test import TestCase
19
from .models import *
20
21
from GitPython import Repo # Necessary in order to test for repository existence.
22
23
class ReposTests(TestCase):
24
    def all_stored_repos_exist():
25
        repositories = Repository.objects.all()
26
        for repository in repositories:
27
            gitRepo = Repo(repository.directory)
28
            assert gitRepo # If a repo doesn't exist, the test fails.
29
    def all_repos_are_bare():
30
        repositories = Repository.objects.all()
31
        for repository in repositories:
32
            gitRepo = Repo(repository.directory)
33
            assert gitRepo.bare # All repos must be bare, or the test fails.
34
    def fuck_PHP(): # WHOOHOOO EASTER EGG
35
        repositories = Repository.objects.all()
36
        for repository in repositories:
37
            assert not repository.programmingLanguage == "PHP", \
38
                    "PHP is too horrible of a language to program in."
39