<commit_before>'''
unit tests for routingslip application. Assumes django server is up
and running on the specified host and port.

Tests cover routingslip, routingslipcomment, and routingslipentry URLs.
'''

import unittest
import getopt, sys
import json

from service.serviceapi import ServiceAPI
from test.tscharts.tscharts import Login, Logout
from test.patient.patient import CreatePatient, DeletePatient
from test.station.station import CreateStation, DeleteStation
from test.clinic.clinic import CreateClinic, DeleteClinic

class CreateRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token):
        super(CreateRoutingSlip, self).__init__()
        
        self.setHttpMethod("POST")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self._payload = {}
        self.setPayload(self._payload)
        self.setURL("tscharts/v1/routingslip/")

    def setClinic(self, clinic):
        self._payload["clinic"] = clinic
        self.setPayload(self._payload)
    
    def setPatient(self, patient):
        self._payload["patient"] = patient
        self.setPayload(self._payload)

    def setCategory(self, category):
        self._payload["category"] = category
        self.setPayload(self._payload)
    
class GetRoutingSlip(ServiceAPI):
    def makeURL(self):
        hasQArgs = False
        if not self._id == None:
            base = "tscharts/v1/routingslip/{}/".format(self._id)
        else:
            base = "tscharts/v1/routingslip/".format(self._id)

        if not self._patient == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "patient={}".format(self._patient)
            hasQArgs = True

        if not self._clinic == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "clinic={}".format(self._clinic)
            hasQArgs = True

        self.setURL(base)

    def __init__(self, host, port, token):
        super(GetRoutingSlip, self).__init__()
        
        self.setHttpMethod("GET")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self.clearArgs()
        self.makeURL()

    def clearArgs(self):
        self._patient = None
        self._clinic = None
        self._clinicstation = None
        self._id = None

    def setClinic(self, clinic):
        self._clinic = clinic
        self.makeURL()

    def setPatient(self, patient):
        self._patient = patient
        self.makeURL()

    def setId(self, id):
        self._id = id
        self.makeURL()

class UpdateRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token, id, category):
        super(UpdateRoutingSlip, self).__init__()
        
        self.setHttpMethod("PUT")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        payload = {"category": category}
        self.setPayload(payload)
        self.setURL("tscharts/v1/routingslip/{}/".format(id))

    def clearPayload(self):
        self._payload = {}
        self.setPayload(self._payload)
    
class DeleteRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token, id):
        super(DeleteRoutingSlip, self).__init__()
        
        self.setHttpMethod("DELETE")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self.setURL("tscharts/v1/routingslip/{}/".format(id))

class CreateRoutingSlipEntry(ServiceAPI):
    def __init__(self, host, port, token):
        super(CreateRoutingSlipEntry, self).__init__()
        
        self.setHttpMethod("POST")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self._payload = {}
        self.setPayload(self._payload)
        self.setURL("tscharts/v1/routingslipentry/")

    def setStation(self, station):
        self._payload["station"] = station
        self.setPayload(self._payload)
    
    def setRoutingSlip(self, routingslip):
        self._payload["routingslip"] = routingslip
        self.setPayload(self._payload)

    def clearPayload(self):
        self._payload = {}
        self.setPayload(self._payload)
    
class GetRoutingSlipEntry(ServiceAPI):

    def makeURL(self):
        hasQArgs = False
        if not self._id == None:
            base = "tscharts/v1/routingslipentry/{}/".format(self._id)
        else:
            base = "tscharts/v1/routingslipentry/".format(self._id)

        if not self._routingslip == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "routingslip={}".format(self._routingslip)
            hasQArgs = True

        if not self._station == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"<commit_msg>fix routingslip unit test URL syntax<commit_after>'''
unit tests for routingslip application. Assumes django server is up
and running on the specified host and port.

Tests cover routingslip, routingslipcomment, and routingslipentry URLs.
'''

import unittest
import getopt, sys
import json

from service.serviceapi import ServiceAPI
from test.tscharts.tscharts import Login, Logout
from test.patient.patient import CreatePatient, DeletePatient
from test.station.station import CreateStation, DeleteStation
from test.clinic.clinic import CreateClinic, DeleteClinic

class CreateRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token):
        super(CreateRoutingSlip, self).__init__()
        
        self.setHttpMethod("POST")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self._payload = {}
        self.setPayload(self._payload)
        self.setURL("tscharts/v1/routingslip/")

    def setClinic(self, clinic):
        self._payload["clinic"] = clinic
        self.setPayload(self._payload)
    
    def setPatient(self, patient):
        self._payload["patient"] = patient
        self.setPayload(self._payload)

    def setCategory(self, category):
        self._payload["category"] = category
        self.setPayload(self._payload)
    
class GetRoutingSlip(ServiceAPI):
    def makeURL(self):
        hasQArgs = False
        if not self._id == None:
            base = "tscharts/v1/routingslip/{}/".format(self._id)
        else:
            base = "tscharts/v1/routingslip/"

        if not self._patient == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "patient={}".format(self._patient)
            hasQArgs = True

        if not self._clinic == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "clinic={}".format(self._clinic)
            hasQArgs = True

        self.setURL(base)

    def __init__(self, host, port, token):
        super(GetRoutingSlip, self).__init__()
        
        self.setHttpMethod("GET")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self.clearArgs()
        self.makeURL()

    def clearArgs(self):
        self._patient = None
        self._clinic = None
        self._id = None

    def setClinic(self, clinic):
        self._clinic = clinic
        self.makeURL()

    def setPatient(self, patient):
        self._patient = patient
        self.makeURL()

    def setId(self, id):
        self._id = id
        self.makeURL()

class UpdateRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token, id, category):
        super(UpdateRoutingSlip, self).__init__()
        
        self.setHttpMethod("PUT")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        payload = {"category": category}
        self.setPayload(payload)
        self.setURL("tscharts/v1/routingslip/{}/".format(id))

    def clearPayload(self):
        self._payload = {}
        self.setPayload(self._payload)
    
class DeleteRoutingSlip(ServiceAPI):
    def __init__(self, host, port, token, id):
        super(DeleteRoutingSlip, self).__init__()
        
        self.setHttpMethod("DELETE")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self.setURL("tscharts/v1/routingslip/{}/".format(id))

class CreateRoutingSlipEntry(ServiceAPI):
    def __init__(self, host, port, token):
        super(CreateRoutingSlipEntry, self).__init__()
        
        self.setHttpMethod("POST")
        self.setHost(host)
        self.setPort(port)
        self.setToken(token)
        self._payload = {}
        self.setPayload(self._payload)
        self.setURL("tscharts/v1/routingslipentry/")

    def setStation(self, station):
        self._payload["station"] = station
        self.setPayload(self._payload)
    
    def setRoutingSlip(self, routingslip):
        self._payload["routingslip"] = routingslip
        self.setPayload(self._payload)

    def clearPayload(self):
        self._payload = {}
        self.setPayload(self._payload)
    
class GetRoutingSlipEntry(ServiceAPI):

    def makeURL(self):
        hasQArgs = False
        if not self._id == None:
            base = "tscharts/v1/routingslipentry/{}/".format(self._id)
        else:
            base = "tscharts/v1/routingslipentry/"

        if not self._routingslip == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
            base += "routingslip={}".format(self._routingslip)
            hasQArgs = True

        if not self._station == None:
            if not hasQArgs:
                base += "?"
            else:
                base += "&"
{'fraction_non_alphanumeric': 0.11213801601971657, 'fraction_numerical': 0.001643047853768741, 'mean_word_length': 2.1375644329896906, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5426993', 'n_tokens_mistral': 2977, 'n_tokens_neox': 2836, 'n_words': 575}