baverman/supplement — Issue #19: Invalid scope
Author: baverman
Created: 2012-03-07 10:40:01+00:00
State: open

# -*- coding: utf-8 -*-
from unittest import skipIf
from django.test import TestCase
from django.conf import settings

from suds.client import Client

from logibox.testutils import TestFactory, DjangoSudsTransport
from api.models import ApiAuth
from account.utils import do_hash_password

settings.DEBUG = True
only_for_api_settings = skipIf('api' not in settings.SETTINGS_MODULE, 'Only for settings_api')

@only_for_api_settings
class EmsServiceTestCase(TestCase):
def setUp(self):
self.factory = TestFactory()
self.sender = self.factory.create_sender()
ApiAuth(sender=self.sender, ip='127.0.0.1', password=do_hash_password('test'),
allowed_services='ems').save()

def get_soap_client(self, username, password):
client = Client('http://testserver/api/soap/ems/?wsdl',
transport=DjangoSudsTransport(self.client), cache=None)

request_header = client.factory.create('AuthHeader')
request_header.username = self.sender.number
request_header.password = 'test'
client.set_options(soapheaders=request_header)

def test_station_list(self):
client = self.get_|||||||||
p1 = self.factory.p0001
p2 = self.factory.p0002

stations = client.service.getStations().Station
assert len(stations) == 2

station = stations[0]
assert station.number == '0001'
assert station.title == 'Почтомат 1'
assert station.address == 'Город 1, Улица первого почтомата 1 стр. 2'
assert station.districtTitle == 'Район 1'
assert station.districtCode == '1'
assert station.districtIntCode == None
assert station.workingHours == 'rtc'
assert station.gps