<commit_before>from apel.db.records import CloudSummaryRecord
from unittest import TestCase

class CloudRecordTest(TestCase):
    '''
    Test case for CloudSummaryRecord
    '''
    
    def setUp(self):
        self._msg1 = '''
SiteName: CESNET
Month: 10
Year: 2011
GlobalUserName: /DC=es/DC=irisgrid/O=cesga/CN=javier-lopez
VO: ops
VOGroup: /ops
VORole: Role=NULL
Status: completed
CloudType: OpenNebula
ImageId: 'scilin6'
EarliestStartTime: 1318840264
LatestStartTime: 1318840264
WallDuration: None
CpuDuration: None
NetworkInbound: 0
NetworkOutbound: 0
Memory: 512
Disk: None
NumberOfVMs: 1
'''
        
        self._values1 = {'SiteName': 'CESNET',
                        'Status': 'completed',
                        'CloudType': 'OpenNebula',
                        'NetworkInbound': 0,
                        'NetworkOutbound': 0,
                        'Memory': 512,
                        'ImageId': '\'scilin6\'',
                        'NumberOfVMs': 1
                        }
        
        
        self.cases = {}
        self.cases[self._msg1] = self._values1

    def test_load_from_msg(self):
        
        for msg in self.cases.keys():
        
            cr = CloudSummaryRecord()
            cr.load_from_msg(msg)
            
            cont = cr._record_content
        
            for key in self.cases[msg].keys():
                self.assertEqual(cont[key], self.cases[msg][key], "%s != %s for key %s" % (cont[key], self.cases[msg][key], key))
        
        
    def test_mandatory_fields(self):
        record = CloudSummaryRecord()
        record.set_field('SiteName', 'MySite')
        record.set_field('Month', 1)
        record.set_field('Year', 2012)
        record.set_field('GlobalUserName', 'me')
        record.set_field('VO', 'myVO')
        record.set_field('VOGroup', 'myVOGroup')
        record.set_field('VORole', 'myVORole')
        record.set_field('Status', 'completed')
        record.set_field('CloudType', 'OpenStack')<commit_msg>Added new fields to cloud summary test<commit_after>from apel.db.records import CloudSummaryRecord
from unittest import TestCase

class CloudRecordTest(TestCase):
    '''
    Test case for CloudSummaryRecord
    '''
    
    def setUp(self):
        self._msg1 = '''
SiteName: CESNET
CloudComputeService: OpenNebula Service A
Month: 10
Year: 2011
GlobalUserName: /DC=es/DC=irisgrid/O=cesga/CN=javier-lopez
VO: ops
VOGroup: /ops
VORole: Role=NULL
Status: completed
CloudType: OpenNebula
ImageId: 'scilin6'
EarliestStartTime: 1318840264
LatestStartTime: 1318840264
WallDuration: None
CpuDuration: None
NetworkInbound: 0
NetworkOutbound: 0
PublicIPCount: 5
Memory: 512
Disk: None
BenchmarkType: Si2k
Benchmark: 1006.3
NumberOfVMs: 1
'''
        
        self._values1 = {'SiteName': 'CESNET',
                        'CloudComputeService': 'OpenNebula Service A', 
                        'Status': 'completed',
                        'CloudType': 'OpenNebula',
                        'NetworkInbound': 0,
                        'NetworkOutbound': 0,
                        'PublicIPCount': 5,
                        'Memory': 512,
                        'ImageId': '\'scilin6\'',
                        'BenchmarkType': 'Si2k',
                        'Benchmark': 1006.3,
                        'NumberOfVMs': 1
                        }
        
        
        self.cases = {}
        self.cases[self._msg1] = self._values1

    def test_load_from_msg(self):
        
        for msg in self.cases.keys():
        
            cr = CloudSummaryRecord()
            cr.load_from_msg(msg)
            
            cont = cr._record_content
        
            for key in self.cases[msg].keys():
                self.assertEqual(cont[key], self.cases[msg][key], "%s != %s for key %s" % (cont[key], self.cases[msg][key], key))
        
        
    def test_mandatory_fields(self):
        record = CloudSummaryRecord()
        record.set_field('SiteName', 'MySite')
        record.set_field('Month', 1)
        record.set_field('Year', 2012)
        record.set_field('GlobalUserName', 'me')
        record.set_field('VO', 'myVO')
        record.set_field('VOGroup', 'myVOGroup')
        record.set_field('VORole', 'myVORole')
        record.set_field('Status', 'completed')
        record.set_field('CloudType', 'OpenStack')
{'fraction_non_alphanumeric': 0.11772853185595568, 'fraction_numerical': 0.02585410895660203, 'mean_word_length': 1.9882758620689656, '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': '1653151', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1284, 'n_words': 269}