Adds new fixtures and started on membership tests

This commit is contained in:
Mark Polak committed 2013-09-11 22:12:38 +02:00
1 parent c256c8d522
commit 9686821aa7
8 files changed
+88 -3

No files matched your search

+1
View File
@@ -0,0 +1 @@
[{"pk": 1, "model": "tastypie.apikey", "fields": {"user": 2, "key": "0593572687d43fa8d86c1663e5ddf826bace073a", "created": "2013-09-11T19:17:16.036Z"}}]
+17
View File
@@ -0,0 +1,17 @@
[
{
"pk": 2,
"model": "dusken.member",
"fields": {
"phone_number": null,
"updated": "2013-09-11T18:45:06.354Z",
"groups": [],
"created": "2013-09-11T18:45:06.354Z",
"place_of_study": [],
"date_of_birth": null,
"legacy_id": null,
"address": null,
"user_permissions": []
}
}
]
+1
View File
@@ -0,0 +1 @@
[{"pk": 1, "model": "dusken.membership", "fields": {"member": 2, "updated": "2013-09-11T18:45:13.341Z", "created": "2013-09-11T18:45:13.341Z", "payment": null, "mtype": 1, "start_date": "2013-09-11"}}, {"pk": 2, "model": "dusken.membership", "fields": {"member": 2, "updated": "2013-09-11T18:45:30.084Z", "created": "2013-09-11T18:45:30.084Z", "payment": null, "mtype": 1, "start_date": "2013-09-15"}}, {"pk": 3, "model": "dusken.membership", "fields": {"member": 2, "updated": "2013-09-11T18:45:53.522Z", "created": "2013-09-11T18:45:53.522Z", "payment": null, "mtype": 2, "start_date": "2013-09-11"}}]
+1
View File
@@ -0,0 +1 @@
[{"pk": 1, "model": "dusken.membershiptype", "fields": {"duration_months": 12, "updated": "2013-09-11T18:44:13.123Z", "name": "Medlemskap ved DNS", "created": "2013-09-11T18:44:13.123Z", "end_month": 7, "end_day_of_month": 31}}, {"pk": 2, "model": "dusken.membershiptype", "fields": {"duration_months": 6, "updated": "2013-09-11T18:44:31.824Z", "name": "Halvtaarsmedlemskap", "created": "2013-09-11T18:44:31.824Z", "end_month": 7, "end_day_of_month": 31}}]
+1
View File
@@ -0,0 +1 @@
[{"pk": 1, "model": "auth.user", "fields": {"username": "mark", "first_name": "", "last_name": "", "is_active": true, "is_superuser": true, "is_staff": true, "last_login": "2013-09-11T16:46:09.869Z", "groups": [], "user_permissions": [], "password": "pbkdf2_sha256$10000$8NUVcwCrxbai$5gri/57kESD/t8ZhpZxueVGQcPCW8l3PSCjSuxDp4AI=", "email": "mark@thedutchies.com", "date_joined": "2013-08-21T19:53:07.653Z"}}, {"pk": 2, "model": "auth.user", "fields": {"username": "markpo", "first_name": "", "last_name": "", "is_active": true, "is_superuser": false, "is_staff": false, "last_login": "2013-09-11T18:45:06.339Z", "groups": [], "user_permissions": [], "password": "", "email": "", "date_joined": "2013-09-11T18:44:52Z"}}]
+1
View File
@@ -1,2 +1,3 @@
from member import *
from group import *
from membership import *
+39
View File
@@ -0,0 +1,39 @@
import logging
from dusken.models import Address, Country, Member
from support.test import ResourceTestCase
from tastypie.models import ApiKey
from utils.tests import load_test_fixtures_for_membership
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
class MembershipTest(ResourceTestCase):
membership_url = '/api/v1/membership/'
membership_url_single = '/api/v1/membership/{}/'.format(1)
def setUp(self):
load_test_fixtures_for_membership()
self.creds = self.create_apikey(
username=Member.objects.get(user_ptr_id=2).username,
api_key=ApiKey.objects.get(user=Member.objects.get(user_ptr_id=2)).key)
super(MembershipTest, self).setUp()
def test_get_memberships(self):
resp = self.api_client.get(
self.membership_url,
format='json',
authentication=self.creds
)
self.assertValidJSONResponse(resp)
def test_get_single_membership(self):
resp = self.api_client.get(
self.membership_url_single,
format='json',
authentication=self.creds
)
self.assertValidJSONResponse(resp)
+27 -3
View File
@@ -1,13 +1,16 @@
import os.path
from django.core.management import call_command
import django
from dusken.models import Member
from tastypie.models import create_api_key
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def test_fixtures():
''' Returns a list with the locations of all defined fixtures. '''
return [os.path.join('dusken', 'fixtures', 'address.json'),
os.path.join('dusken', 'fixtures', 'country.json'),
return [os.path.join('dusken', 'fixtures', 'country.json'),
os.path.join('dusken', 'fixtures', 'address.json'),
os.path.join('dusken', 'fixtures', 'institution.json'),
]
]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def load_test_fixtures():
@@ -16,3 +19,24 @@ def load_test_fixtures():
for all tests in a test class.'''
for f in test_fixtures():
call_command('loaddata', f, verbosity=0)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def test_fixtures_member():
''' Returns a list with the locations of all defined fixtures. '''
return [os.path.join('dusken', 'fixtures', 'address.json'),
os.path.join('dusken', 'fixtures', 'country.json'),
os.path.join('dusken', 'fixtures', 'institution.json'),
]
def test_fixtures_membership():
return test_fixtures() + [
os.path.join('dusken', 'fixtures', 'users.json'),
os.path.join('dusken', 'fixtures', 'apikey.json'),
os.path.join('dusken', 'fixtures', 'member.json'),
os.path.join('dusken', 'fixtures', 'membershiptype.json'),
os.path.join('dusken', 'fixtures', 'membership.json'),
]
def load_test_fixtures_for_membership():
django.db.models.signals.post_save.disconnect(create_api_key, sender=Member)
for f in test_fixtures_membership():
call_command('loaddata', f, verbosity=0)