Basic fist tests for PhotoAlbum model.
This commit is contained in:
		
							
								
								
									
										61
									
								
								django_lostplaces/lostplaces/tests/models/test_link_model.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								django_lostplaces/lostplaces/tests/models/test_link_model.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
 | 
			
		||||
import os
 | 
			
		||||
import shutil
 | 
			
		||||
from unittest import mock
 | 
			
		||||
 | 
			
		||||
from django.test import TestCase
 | 
			
		||||
from django.db import models
 | 
			
		||||
from django.core.files import File
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.contrib.auth.models import User
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
 | 
			
		||||
from lostplaces.models import ExternalLink, PhotoAlbum, Place
 | 
			
		||||
from lostplaces.tests.models import ModelTestCase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ExternalLinkTestCase(ModelTestCase):
 | 
			
		||||
    model = ExternalLink
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class PhotoAlbumTestCase(ModelTestCase):
 | 
			
		||||
    model = PhotoAlbum
 | 
			
		||||
        
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def setUpTestData(cls):
 | 
			
		||||
        user = User.objects.create_user(
 | 
			
		||||
            username='testpeter',
 | 
			
		||||
            password='Develop123'
 | 
			
		||||
        )
 | 
			
		||||
    
 | 
			
		||||
        place = Place.objects.create(
 | 
			
		||||
            name='Im a place',
 | 
			
		||||
            submitted_when=timezone.now(),
 | 
			
		||||
            submitted_by=User.objects.get(username='testpeter').explorer,
 | 
			
		||||
            location='Testtown',
 | 
			
		||||
            latitude=50.5,
 | 
			
		||||
            longitude=7.0,
 | 
			
		||||
            description='This is just a test, do not worry'
 | 
			
		||||
        )
 | 
			
		||||
        place.tags.add('I a tag', 'testlocation')
 | 
			
		||||
        place.save()
 | 
			
		||||
 | 
			
		||||
        PhotoAlbum.objects.create(
 | 
			
		||||
            url='https://lostplaces.example.com/album/',
 | 
			
		||||
            label='TestLink',
 | 
			
		||||
            submitted_by=user.explorer,
 | 
			
		||||
            place=place,
 | 
			
		||||
            submitted_when=timezone.now()
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def setup(self):
 | 
			
		||||
        self.album_link = PhotoAlbum.objects.get(id=1)
 | 
			
		||||
 | 
			
		||||
    def test_label(self):
 | 
			
		||||
        self.assertField('label', models.CharField)
 | 
			
		||||
 | 
			
		||||
    def test_url(self):
 | 
			
		||||
        self.assertField('url', models.URLField)
 | 
			
		||||
    
 | 
			
		||||
		Reference in New Issue
	
	Block a user