<commit_before>#!/usr/bin/python

import unittest
from PySide.QtGui import QApplication
from QtMobility.Contacts import *

class QtContactsUsage(unittest.TestCase):

    def testNewandRetrieveContact(self):
        app = QApplication([])
        cm = QContactManager()

        #Create a new Contact
        exampleContact = QContact()
        nameDetail = QContactName()
        nameDetail.setFirstName("John")
        nameDetail.setLastName("PySide")
        phoneNumberDetail = QContactPhoneNumber()
        phoneNumberDetail.setNumber("+123 4567")
        exampleContact.saveDetail(nameDetail)
        exampleContact.saveDetail(phoneNumberDetail)

        self.assert_(cm.saveContact(exampleContact))

        filtr = QContactLocalIdFilter()
        filtr.add(exampleContact.localId())

        newContact = cm.contacts(filtr)[0]

        surname = newContact.detail(QContactName.DefinitionName).value(QContactName.FieldLastName)
        phone = newContact.detail(QContactPhoneNumber.DefinitionName).value(QContactPhoneNumber.FieldNumber)

        self.assertEqual("PySide", surname)
        self.assertEqual("+123 4567", phone)

        self.assert_(cm.removeContact(exampleContact.localId()))

if __name__ == '__main__':
    unittest.main()<commit_msg>Add small QtContacts test.<commit_after>#!/usr/bin/python

import unittest
from PySide.QtGui import QApplication
from QtMobility.Contacts import *

class QtContactsUsage(unittest.TestCase):

    def testNewandRetrieveContact(self):
        app = QApplication([])
        cm = QContactManager()

        #Create a new Contact
        exampleContact = QContact()
        nameDetail = QContactName()
        nameDetail.setFirstName("John")
        nameDetail.setLastName("PySide")
        phoneNumberDetail = QContactPhoneNumber()
        phoneNumberDetail.setNumber("+123 4567")
        exampleContact.saveDetail(nameDetail)
        exampleContact.saveDetail(phoneNumberDetail)

        self.assert_(cm.saveContact(exampleContact))

        filtr = QContactLocalIdFilter()
        filtr.add(exampleContact.localId())

        newContact = cm.contacts(filtr)[0]

        surname = newContact.detail(QContactName.DefinitionName).value(QContactName.FieldLastName)
        phone = newContact.detail(QContactPhoneNumber.DefinitionName).value(QContactPhoneNumber.FieldNumber)

        self.assertEqual("PySide", surname)
        self.assertEqual("+123 4567", phone)

        self.assert_(cm.removeContact(exampleContact.localId()))


class PhoneNumberTest(unittest.TestCase):

    def basicTest(self):
        number = QContactPhoneNumber()
        self.assertEqual(number.number(), '')

        subtypes = [QContactPhoneNumber.SubTypeCar, QContactPhoneNumber.SubTypeFax]
        number.setSubTypes(subtypes)
        self.assertEqual(number.subTypes(), subtypes)
        self.assertEqual(number.value(QContactPhoneNumber.FieldSubTypes), subtypes)

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.10122282608695653, 'fraction_numerical': 0.010190217391304348, 'mean_word_length': 3.630503144654088, 'pattern_counts': {'":': 0, '<': 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': '4988616', 'n_tokens_mistral': 849, 'n_tokens_neox': 803, 'n_words': 125}