# Path: prometapi/bicikeljproxy/models.py
# def _parse_main_xml(data):
# 	json = {}
# 	carto = ET.fromstring(data)
# 
# 	count = 0
# 	for marker in carto.findall('./markers/marker'):
# 		assert len(marker.getchildren()) == 0, 'Marker has children!? ' + repr(marker.getchildren())
# 		station_id = unicode_type(marker.attrib['number'])
# 		json[station_id] = dict(marker.attrib)
# 	
# 		count += 1
# 	assert count > 0, 'No markers found in main XML!?'
# 	
# 	return json
# 
# def _parse_station_xml(data):
# 	sta_xml = ET.fromstring(data)
# 
# 	sta_dict = {}
# 	for elem in sta_xml.findall('./*'):
# 		sta_dict[elem.tag] = elem.text
# 
# 	expected_keys = list(sorted(sta_dict.keys()))
# 	assert expected_keys == ['available', 'free', 'ticket', 'total'], 'Missing or added keys in station XML!? %r' % expected_keys
# 	# backwards compatibility
# 	return sta_dict


import unittest
import os, sys
import simplejson
from prometapi.bicikeljproxy.models import _parse_main_xml, _parse_station_xml



testdatadir = os.path.join(os.path.dirname(__file__), 'testdata')

class TestXMLParsing(unittest.TestCase):
	def runTest(self):
		
		main_data = open(os.path.join(testdatadir, 'carto.xml')).read()
		main_json = open(os.path.join(testdatadir, 'carto.json')).read()
		
		station_data = open(os.path.join(testdatadir, 'station_2.xml')).read()

# Path: prometapi/bicikeljproxy/models.py
# def _parse_main_xml(data):
# 	json = {}
# 	carto = ET.fromstring(data)
# 
# 	count = 0
# 	for marker in carto.findall('./markers/marker'):
# 		assert len(marker.getchildren()) == 0, 'Marker has children!? ' + repr(marker.getchildren())
# 		station_id = unicode_type(marker.attrib['number'])
# 		json[station_id] = dict(marker.attrib)
# 	
# 		count += 1
# 	assert count > 0, 'No markers found in main XML!?'
# 	
# 	return json
# 
# def _parse_station_xml(data):
# 	sta_xml = ET.fromstring(data)
# 
# 	sta_dict = {}
# 	for elem in sta_xml.findall('./*'):
# 		sta_dict[elem.tag] = elem.text
# 
# 	expected_keys = list(sorted(sta_dict.keys()))
# 	assert expected_keys == ['available', 'free', 'ticket', 'total'], 'Missing or added keys in station XML!? %r' % expected_keys
# 	# backwards compatibility
# 	return sta_dict


# Path: prometapi/bicikeljproxy/tests.py
import unittest
import os, sys
import simplejson
from prometapi.bicikeljproxy.models import _parse_main_xml, _parse_station_xml




testdatadir = os.path.join(os.path.dirname(__file__), 'testdata')

class TestXMLParsing(unittest.TestCase):
	def runTest(self):
		
		main_data = open(os.path.join(testdatadir, 'carto.xml')).read()
		main_json = open(os.path.join(testdatadir, 'carto.json')).read()
		
		station_data = open(os.path.join(testdatadir, 'station_2.xml')).read()

		station_json = open(os.path.join(testdatadir, 'station_2.json')).read()