aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_gsxws.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-10-31 11:19:54 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-10-31 11:19:54 +0200
commitcf61815f971b1e1067ddc6759a3ccb5880e19df7 (patch)
tree1c755a15a9a190ebbcbb25d2d4d998e34c17c39a /tests/test_gsxws.py
parent0b71cd3eac7baa0a6cb614f628a5e9c1458a253a (diff)
downloadpy-gsxws-cf61815f971b1e1067ddc6759a3ccb5880e19df7.tar.gz
py-gsxws-cf61815f971b1e1067ddc6759a3ccb5880e19df7.tar.bz2
py-gsxws-cf61815f971b1e1067ddc6759a3ccb5880e19df7.zip
Added some tests
Diffstat (limited to 'tests/test_gsxws.py')
-rw-r--r--tests/test_gsxws.py41
1 files changed, 30 insertions, 11 deletions
diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py
index 164c90c..5f3476e 100644
--- a/tests/test_gsxws.py
+++ b/tests/test_gsxws.py
@@ -4,13 +4,13 @@ import os
import logging
from datetime import date, datetime
-from unittest import main, skip, TestCase
+from unittest import TestCase, main, skip
-from gsxws.core import validate
+from gsxws.core import validate, GsxCache
from gsxws.objectify import parse, gsx_diags_timestamp
from gsxws.products import Product
from gsxws import (repairs, escalations, lookups, returns,
- GsxError, ServicePart, diagnostics, comptia,
+ GsxError, diagnostics, comptia,
comms,)
@@ -153,14 +153,19 @@ class RepairTestCase(RemoteTestCase):
self.issue = self._issues[0][0]
-class TestCoreFunctions(TestCase):
+class CoreFunctionTestCase(TestCase):
def test_dump(self):
rep = repairs.Repair(blaa=u'ääöö')
part = repairs.RepairOrderLine()
part.partNumber = '661-5571'
rep.orderLines = [part]
self.assertRegexpMatches(rep.dumps(),
- '<GsxObject><blaa>ääöö</blaa><orderLines>')
+ '<GsxObject><blaa>ääöö</blaa><orderLines>')
+
+ def test_cache(self):
+ """Make sure the cache is working."""
+ c = GsxCache('test').set('spam', 'eggs')
+ self.assertEquals(c.get('spam'), 'eggs')
class TestTypes(TestCase):
@@ -189,7 +194,7 @@ class TestErrorFunctions(TestCase):
def test_code(self):
self.assertEqual(self.data.errors['RPR.ONS.025'],
- 'This unit is not eligible for an Onsite repair from GSX.')
+ 'This unit is not eligible for an Onsite repair from GSX.')
def test_message(self):
self.assertRegexpMatches(self.data.message, 'Multiple error messages exist.')
@@ -547,18 +552,22 @@ class TestOnsiteDispatchDetail(TestCase):
self.assertIsInstance(self.data.dispatchOrderLines.isSerialized, bool)
-class TestRepairUpdate(RemoteTestCase):
+class RepairUpdateTestCase(RemoteTestCase):
def setUp(self):
- super(TestRepairUpdate, self).setUp()
- self.dispatchId = 'G135934345'
+ super(RepairUpdateTestCase, self).setUp()
+ self.dispatchId = 'G210427158'
self.repair = repairs.CarryInRepair(self.dispatchId)
- def test_set_repair_status(self):
+ def test_set_status_open(self):
result = self.repair.set_status('BEGR')
self.assertEqual(result.confirmationNumber, self.dispatchId)
+ def test_set_status_ready(self):
+ result = self.repair.set_status('RFPU')
+ self.assertEqual(result.confirmationNumber, self.dispatchId)
+
def test_set_repair_techid(self):
- result = self.repair.set_techid('XXXXX')
+ result = self.repair.set_techid(os.getenv('GSX_TECHID'))
self.assertEqual(result.confirmationNumber, self.dispatchId)
@@ -574,6 +583,16 @@ class TestCarryinRepairDetail(TestCase):
self.assertEqual(self.data.primaryAddress.firstName, u'Ääkköset')
+class ConnectionTestCase(TestCase):
+ """Basic connection tests."""
+
+ def test_access_denied(self):
+ """Make sure we fail with 403 when connecting from non-whitelisted IP."""
+ from gsxws.core import connect
+ with self.assertRaisesRegexp(GsxError, 'Access denied'):
+ connect(os.getenv('GSX_USER'), os.getenv('GSX_SOLDTO'), os.getenv('GSX_ENV'))
+
+
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
main()