#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import argparse

# Path hack. (for importing)
import sys
import os
sys.path.insert(0, os.path.abspath('..'))
import tungsten

appid = ''

class TungstenTestSuite(unittest.TestCase):

    def setUp(self):
        self.appid = appid

    def test_error_appid(self):
        """
        Test error response of a faulty appid
        client and an 'error' result object tested
        """

        client = tungsten.Tungsten('XXXX')
        result = client.query('pi')

        self.assertFalse(result.success)
        self.assertEqual(result.error, 'Invalid appid')

    def test_pi(self):
        """
        Test repsonse of a standard query, namely the API functionality
        client, result and pods tested
        """

        client = tungsten.Tungsten(appid)
        result = client.query('pi')

        self.assertTrue(result.success)
        self.assertEqual(result.error, None)

        # Pod information expected to be returned
        expected_titles = ['Input',
                           'Decimal approximation',
                           'Property',
                           'Number line',
                           'Continued fraction',
                           'Alternative representations',
                           'Series representations',
                           'Integral representations']
        expected_ids = ['Input',
                        'DecimalApproximation',
                        'Property',
                        'NumberLine',
                        'ContinuedFraction',
                        'AlternativeRepresentations:MathematicalFunctionIdentityData',
                        'SeriesRepresentations:MathematicalFunctionIdentityData',
                        'IntegralRepresentations:MathematicalFunctionIdentityData']
        expected_scanners = ['Identity',
                             'Numeric',
                             'Numeric',
                             'NumberLine',
                             'ContinuedFraction',
                             'MathematicalFunctionData',
                             'MathematicalFunctionData',
                             'MathematicalFunctionData']

        # Returned pod information
        titles = [pod.title for pod in result.pods]
        ids = [pod.id for pod in result.pods]
        scanners = [pod.scanner for pod in result.pods]

        self.assertEqual(titles, expected_titles)
        self.assertEqual(ids, expected_ids)
        self.assertEqual(scanners, expected_scanners)

if __name__ == '__main__':
    # Get appid from first argument of commandline
    appid = sys.argv[1]

    # Change sys.argv back to rest of arguments for unit test
    sys.argv[1:] = sys.argv[2:]

    # Run unit tests
    unittest.main()

@@ -40,16 +40,263 @@
 -8 -*-%0A%0A
+%22%22%22%0ATungsten Test Suite%0A~~~~~~~~~~~~~~~~~~~%0A%0AA series of unittests to check the basic functionality of the Tungsten API.%0A%0ANOTE: Test suite could use some attention with a more methodical approach%0Ato testing results and important edge cases.%0A%0A%22%22%22%0A%0A
 import u
@@ -629,59 +629,8 @@
 pid%0A
-        client and an 'error' result object tested%0A
     
@@ -843,32 +843,32 @@
 f):%0A        %22%22%22%0A
+
         Test rep
@@ -927,47 +927,8 @@
 ity%0A
-        client, result and pods tested%0A
     
@@ -2713,16 +2713,530 @@
 nners)%0A%0A
+    def test_params(self):%0A        %22%22%22%0A        Test query / response of query with specified parameters%0A        %22%22%22%0A        client = tungsten.Tungsten(appid)%0A%0A        # Parameters as list and as string%0A        params = %7B'format': %5B'minput', 'moutput'%5D, 'scanner': 'numeric'%7D%0A%0A        result = client.query('pi', params)%0A        %0A        for pod in result.pods:%0A            self.assertIn(pod.scanner, %5B'Numeric'%5D)%0A            for format in pod.formats:%0A                self.assertIn(format, %5B'minput', 'moutput'%5D)%0A%0A
 if __nam

Add test_params() for Pod.formats, query(params)