Exemplo n.º 1
0
 def testGetRoles(self):
     xml = """
     <person>
     <role name="Chairman">
         <email id="chairman" />
     </role>
     <role name="Secretary" club="Denmead">
         <email id="denmead.secretary" />
     </role>
     <role name="Captain" club="Denmead" />
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     dataObject = PersonData()
     PartialContacts("").getRoles(personElement, dataObject)
     expectedResults = []
     expectedResults.append(("Chairman", None, "chairman"))
     expectedResults.append(("Secretary", "Denmead", "denmead.secretary"))
     expectedResults.append(("Captain", "Denmead", None))
     for expected, result in zip(expectedResults, dataObject.roles):
         expName, expClub, expEmail = expected
         self.assertEquals(expName, result.name)
         self.assertEquals(expClub, result.club)
         self.assertEquals(expEmail, result.email)
     self.assertEquals(len(expectedResults), len(dataObject.roles))
Exemplo n.º 2
0
 def testGetHeaderMessagesPartialContacts(self):
     result = PartialContacts("").getHeaderMessages()
     expectedResult = """
     <p>
         <a href="http://www.gsam.co.uk/" target="_blank">Game Set &amp; Match</a>, the
         League's sponsors, are located at Unit 1, Beaver Trade Park, Quarry Lane, Chichester PO19 8NY
         (tel: 01243 538800).
     </p>
     <p>
         The main means of communication on league matters is by e-mail. <b>For
         urgent contacts, however, it may be preferable to telephone; telephone
         numbers for committee members, club secretaries and team captains and
         managers are given on the <a href="/cgi-bin/page.py?id=fullContacts">Full Contacts</a> page.</b>
     </p>
     <p>
         All e-mail contacts should be made using the e-mail addresses
         assigned to the relevant roles in the League's domain (that is,
         addresses ending with <i>sehicl.org.uk</i>). This ensures that when the
         person performing a role changes, the e-mail is still routed to the correct
         person. The easiest way to do this is to click on the person's name in
         the lists below.
     </p>
     <p>
         Please let <script language="javascript">
             document.write(mailTo("website", "", "SEHICL Webmaster", "the Webmaster"));
         </script>
         <noscript>the Webmaster<i> (Javascript not enabled: cannot display mail link)</i>
         </noscript> know if any of the information below is incomplete or incorrect.
     </p>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 3
0
 def testGetPersonHtmlPersonNotSpecified(self):
     person = None
     email = None
     defaultText = "Hello goodbye"
     result = PartialContacts("").getPersonHtml(person, email, defaultText,
                                                False)
     expectedResult = "Hello goodbye"
     self.assertEquals(expectedResult, result)
Exemplo n.º 4
0
 def testGetPersonHtmlPersonSpecifiedEmailNotSpecifiedNotFull(self):
     person = PersonData(name="Pandolf Ironhead")
     email = None
     defaultText = "Hello goodbye"
     result = PartialContacts("").getPersonHtml(person, email, defaultText,
                                                True)
     expectedResult = "Pandolf Ironhead"
     self.assertEquals(expectedResult, result)
Exemplo n.º 5
0
 def testGetEmailElementNotSpecified(self):
     xml = """
     <role club="       OPCS    "/>
     """
     roleElement = ElementTree.fromstring(xml)
     dataObject = RoleData()
     PartialContacts("").getEmail(roleElement, dataObject)
     expectedResult = None
     self.assertEquals(expectedResult, dataObject.email)
Exemplo n.º 6
0
 def testGetClubClubNotSpecified(self):
     xml = """
     <role/>
     """
     roleElement = ElementTree.fromstring(xml)
     dataObject = RoleData()
     PartialContacts("").getClub(roleElement, dataObject)
     expectedResult = None
     self.assertEquals(expectedResult, dataObject.club)
Exemplo n.º 7
0
 def testGetRoleNameNameSpecified(self):
     xml = """
     <role name=" sad sagsdgsa     "/>
     """
     roleElement = ElementTree.fromstring(xml)
     dataObject = RoleData()
     PartialContacts("").getRoleName(roleElement, dataObject)
     expectedResult = "sad sagsdgsa"
     self.assertEquals(expectedResult, dataObject.name)
Exemplo n.º 8
0
 def testGetAddressNoAddressSpecified(self):
     xml = """
     <person/>
     """
     personElement = ElementTree.fromstring(xml)
     dataObject = PersonData()
     PartialContacts("").getAddress(personElement, dataObject)
     expectedResult = None
     self.assertEquals(expectedResult, dataObject.address)
Exemplo n.º 9
0
 def testGetNameNameSpecified(self):
     xml = """
     <person>
         <name>    Jeremy Hicks   </name>
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     dataObject = PersonData()
     PartialContacts("").getName(personElement, dataObject)
     expectedResult = "Jeremy Hicks"
     self.assertEquals(expectedResult, dataObject.name)
Exemplo n.º 10
0
 def testGetRole(self):
     xml = """
     <role name="Secretary" club="Corinthians">
         <email id="corinthians.secretary" />
     </role>
     """
     roleElement = ElementTree.fromstring(xml)
     result = PartialContacts("").getRole(roleElement)
     self.assertEquals("Secretary", result.name)
     self.assertEquals("Corinthians", result.club)
     self.assertEquals("corinthians.secretary", result.email)
Exemplo n.º 11
0
 def testGetPhoneNumbersNoNumbersSpecified(self):
     xml = """
     <person>
         <address> Four Stoneycroft Rise              </address>
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     dataObject = PersonData()
     PartialContacts("").getPhoneNumbers(personElement, dataObject)
     expectedResult = []
     self.assertEquals(expectedResult, dataObject.phoneNumbers)
Exemplo n.º 12
0
 def testGetPhoneNumbersSomeNumbersSpecified(self):
     xml = """
     <person>
         <phone> 07423152361  </phone>
         <phone>02392 563323</phone>
         <phone>0193 282 2282</phone>
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     dataObject = PersonData()
     PartialContacts("").getPhoneNumbers(personElement, dataObject)
     expectedResult = ["07423 152361", "023 9256 3323", "01932 822282"]
     self.assertEquals(expectedResult, dataObject.phoneNumbers)
Exemplo n.º 13
0
 def testGetPersonHtmlPersonSpecifiedEmailSpecifiedNotFull(self):
     person = PersonData(name="Pandolf Ironhead")
     email = "pandolf"
     defaultText = "Hello goodbye"
     result = PartialContacts("").getPersonHtml(person, email, defaultText,
                                                True)
     expectedResult = """
     <script language="javascript">
         document.write(mailTo("pandolf", "", "", "Pandolf Ironhead"));
     </script>
     <noscript>Pandolf Ironhead<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 14
0
 def testGetCommitteeContactHtmlNoPersonForRole(self):
     roleName = "Treasurer"
     person = None
     role = None
     defaultText = "Not filled at the moment"
     result = PartialContacts("").getCommitteeContactHtml(
         roleName, person, role, defaultText)
     expectedResult = """
     <tr>
         <td class="role">Treasurer</td>
         <td>Not filled at the moment</td>
     </tr>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 15
0
 def testGetCommitteeContactHtmlPersonForRoleNoEmail(self):
     roleName = "Manager"
     person = PersonData(name="Steve Evans")
     role = RoleData()
     defaultText = "Not filled at the moment"
     result = PartialContacts("").getCommitteeContactHtml(
         roleName, person, role, defaultText)
     expectedResult = """
     <tr>
         <td class="role">Manager</td>
         <td>Steve Evans</td>
     </tr>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 16
0
 def testGetClubContactListHtmlNotFullSecretaryNotSpecified(self):
     contactsByRole = {}
     contactsByRole["asdgsdags"] = (PersonData(name="Contact 1",
                                               address="Buckingham Palace",
                                               phoneNumbers=["0124124"]),
                                    RoleData(email="thesecretary"))
     contactsByRole["Under-16"] = (PersonData(name="Contact 2",
                                              phoneNumbers=["113"]),
                                   RoleData())
     contactsByRole["Captain"] = (PersonData(name="Contact 3",
                                             phoneNumbers=["999"]),
                                  RoleData())
     result = PartialContacts("").getClubContactListHtml(contactsByRole)
     expectedResult = "TBC"
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 17
0
 def testGetCommitteeContactHtmlPersonForRoleWithEmail(self):
     roleName = "Manager"
     person = PersonData(name="Steve Evans")
     role = RoleData(email="rufcmgr")
     defaultText = "Not filled at the moment"
     result = PartialContacts("").getCommitteeContactHtml(
         roleName, person, role, defaultText)
     expectedResult = """
     <tr>
         <td class="role">Manager</td>
         <td><script language="javascript">
         document.write(mailTo("rufcmgr", "", "", "Steve Evans"));
     </script>
     <noscript>Steve Evans<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript></td>
     </tr>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 18
0
 def testGetCommitteeContactsNoRolesFilled(self):
     personList = []
     result = PartialContacts("").getCommitteeContacts(personList)
     expectedResult = """
     <table>
         <tbody>
             <tr>
                 <td class="role">President</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Chairman</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Vice-Chairman</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Secretary</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Treasurer</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Umpires' Co-ordinator</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Fixture Secretary</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Webmaster</td>
                 <td>Currently vacant</td>
             </tr>
         </tbody>
     </table>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 19
0
 def testGetClubContactListHtmlNotFullSecretarySpecified(self):
     contactsByRole = {}
     contactsByRole["Secretary"] = [(PersonData(name="Contact 1",
                                                address="Buckingham Palace",
                                                phoneNumbers=["0124124"]),
                                     RoleData(email="thesecretary"))]
     contactsByRole["Under-16"] = [(PersonData(name="Contact 2",
                                               phoneNumbers=["113"]),
                                    RoleData())]
     contactsByRole["Captain"] = [(PersonData(name="Contact 3",
                                              phoneNumbers=["999"]),
                                   RoleData())]
     result = PartialContacts("").getClubContactListHtml(contactsByRole)
     expectedResult = """
     <script language="javascript">
         document.write(mailTo("thesecretary", "", "", "Contact 1"));
     </script>
     <noscript>Contact 1<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 20
0
 def testGetPersonDataNotFullData(self):
     xml = """
     <person>
         <name>Rick Marston</name>
         <address>113 Festing Grove, Portsmouth PO4 9QE</address>
         <phone>023 9273 5987</phone>
         <phone>07724 138531</phone>
         <role name="Secretary" club="Portsmouth">
             <email id="portsmouth.secretary" />
         </role>
         <role name="B team" club="Portsmouth" />
         <role name="C team" club="Portsmouth" />
         <role name="Under-16" club="Portsmouth" />
     </person>
     """
     personElement = ElementTree.fromstring(xml)
     result = PartialContacts("").getPersonData(personElement)
     self.assertEquals("Rick Marston", result.name)
     self.assertEquals(4, len(result.roles))
     self.assertEquals(None, result.address)
     self.assertEquals([], result.phoneNumbers)
Exemplo n.º 21
0
 def testFormatPhoneNumberInvalidCharacters(self):
     value = "1252asfd67s65sfd"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "???12526765"
     self.assertEquals(expectedResult, result)
Exemplo n.º 22
0
 def testFormatPhoneNumberStartingWith01xxTooManyDigits(self):
     value = "0132 41 141444"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "???013241141444"
     self.assertEquals(expectedResult, result)
Exemplo n.º 23
0
 def testGetCommitteeContactsSomeRolesFilled(self):
     personList = []
     personList.append(PersonData(name="Carol Cooper", \
                                  roles=[RoleData(name="President", email="president")]))
     personList.append(PersonData(name="Richard Matthews", \
                                  roles=[RoleData(name="Chairman", email="chairman"), \
                                         RoleData(name="Secretary", club="Denmead", email="denmead.secretary")]))
     personList.append(PersonData(name="Jeremy Hicks", \
                                  roles=[RoleData(name="Fixture secretary", email="fixturesec"), \
                                         RoleData(name="Webmaster", email="website")]))
     result = PartialContacts("").getCommitteeContacts(personList)
     expectedResult = """
     <table>
         <tbody>
             <tr>
                 <td class="role">President</td>
                 <td><script language="javascript">
         document.write(mailTo("president", "", "", "Carol Cooper"));
     </script>
     <noscript>Carol Cooper<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript></td>
             </tr>
             <tr>
                 <td class="role">Chairman</td>
                 <td><script language="javascript">
         document.write(mailTo("chairman", "", "", "Richard Matthews"));
     </script>
     <noscript>Richard Matthews<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript></td>
             </tr>
             <tr>
                 <td class="role">Vice-Chairman</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Secretary</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Treasurer</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Umpires' Co-ordinator</td>
                 <td>Currently vacant</td>
             </tr>
             <tr>
                 <td class="role">Fixture Secretary</td>
                 <td><script language="javascript">
         document.write(mailTo("fixturesec", "", "", "Jeremy Hicks"));
     </script>
     <noscript>Jeremy Hicks<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript></td>
             </tr>
             <tr>
                 <td class="role">Webmaster</td>
                 <td><script language="javascript">
         document.write(mailTo("website", "", "", "Jeremy Hicks"));
     </script>
     <noscript>Jeremy Hicks<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript></td>
             </tr>
         </tbody>
     </table>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 24
0
 def testFormatPhoneNumberStartingWith0x1CorrectNumberOfDigits(self):
     value = "0191 41 14 14 4"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "0191 411 4144"
     self.assertEquals(expectedResult, result)
Exemplo n.º 25
0
 def testFormatPhoneNumberInvalidLength(self):
     value = "012141"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "???012141"
     self.assertEquals(expectedResult, result)
Exemplo n.º 26
0
 def testFormatPhoneNumberNotStartingWith0(self):
     value = "112 141 41414"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "???11214141414"
     self.assertEquals(expectedResult, result)
Exemplo n.º 27
0
 def testFormatPhoneNumberStartingWith0x1TooFewDigits(self):
     value = "016 141 4141"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "???0161414141"
     self.assertEquals(expectedResult, result)
Exemplo n.º 28
0
 def testFormatPhoneNumberStartingWith01xx9Digits(self):
     value = "0193 41 14 1"
     result = PartialContacts("").formatPhoneNumber(value)
     expectedResult = "01934 1141"
     self.assertEquals(expectedResult, result)
Exemplo n.º 29
0
 def testGetAllClubsContactHtml(self):
     people = []
     people.append(
         PersonData(name="Jeremy Hicks",
                    roles=[
                        RoleData(name="Secretary",
                                 email="rufc",
                                 club="Rotherham")
                    ]))
     people.append(
         PersonData(name="Peter Hicks",
                    roles=[
                        RoleData(name="Secretary",
                                 email="pvfc",
                                 club="Port Vale")
                    ]))
     people.append(
         PersonData(name="Joe Hicks",
                    roles=[
                        RoleData(name="Secretary",
                                 email="pfc",
                                 club="Portsmouth")
                    ]))
     contactsByClubAndRole = {}
     for p in people:
         role = p.roles[0]
         contactsByClubAndRole[role.club] = {role.name: [(p, p.roles[0])]}
     result = PartialContacts("").getAllClubsContactsHtml(
         contactsByClubAndRole)
     expectedResult = """
     <table>
         <tbody>
             <tr>
                 <td class="role">Portsmouth</td>
                 <td>
                     <script language="javascript">
         document.write(mailTo("pfc", "", "", "Joe Hicks"));
     </script>
     <noscript>Joe Hicks<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
                 </td>
             </tr>
             <tr>
                 <td class="role">Port Vale</td>
                 <td>
                     <script language="javascript">
         document.write(mailTo("pvfc", "", "", "Peter Hicks"));
     </script>
     <noscript>Peter Hicks<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
                 </td>
             </tr>
             <tr>
                 <td class="role">Rotherham</td>
                 <td>
                     <script language="javascript">
         document.write(mailTo("rufc", "", "", "Jeremy Hicks"));
     </script>
     <noscript>Jeremy Hicks<i> (Javascript not enabled: cannot display mail link)</i>
     </noscript>
                 </td>
             </tr>
         </tbody>
     </table>
     """
     self.assertMultiLineEqual(expectedResult, result)
Exemplo n.º 30
0
 def testGetContentPartialContacts(self):
     rootElement = ElementTree.parse("testData/contacts.xml")
     PartialContacts("").getContent(rootElement)