<commit_before>#!/usr/bin/env python2
# -*- coding : utf8 -*-

import unittest
from section_four import *


class TestSectionFour(unittest.TestCase):
    def test_init(self):
        self.assertIsNotNone(init_ec2())

    def test_sg(self):
        #[{u'GroupName': 'toto42', u'GroupId': 'sg-xxxxx'}]
        for key, val in list_all_sg():
            self.assertTrue('GroupName' in key)
    


if __name__ == '__main__':
    unittest.main()
<commit_msg>adding tests for list_all_sg and getrules() helpers<commit_after>#!/usr/bin/env python2
# -*- coding : utf8 -*-

import unittest
import re
from section_four import *


class TestSectionFour(unittest.TestCase):
    def setUp(self):
        """this is run before each test"""
        self.testee=SectionFour()


    def test_init(self):
        self.assertIsNotNone(self.testee)

    def test_sg_groupname_present(self):
        """testing that the function list_all_sg returns the right format 1/3"""
        #[{u'GroupName': 'toto42', u'GroupId': 'sg-xxxxx'}]
        for sgname, sgid in self.testee.list_all_sg():
            self.assertTrue('GroupName' in sgname) 

    def test_sg_groupid_present(self):
        """testing that the function list_all_sg returns the right format 2/3"""
        for sgname, sgid in self.testee.list_all_sg():
            self.assertTrue('GroupId' in sgid)

    def test_sg_id_format(self):
        """testing that the function list_all_sg returns the right format 3/3"""
        if self.testee.list_all_sg():
            # matching sg to format sg-12345678 regex sg-[0-9a-f]{8}
            self.assertTrue(re.match(r'sg-[0-9a-f]{8}',self.testee.list_all_sg()[0]['GroupId']))
    
    def test_rules_format(self):
        """testing that the function getrules() returns the right format"""
        if self.testee.getrules():
            self.assertTrue('FromPort' in self.testee.getrules()[0].keys())

    def tearDown(self):
        """this is after before each test"""
        del self.testee

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.1310990635781173, 'fraction_numerical': 0.015278462296697881, 'mean_word_length': 3.0118577075098814, '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': '618254', 'n_tokens_mistral': 680, 'n_tokens_neox': 647, 'n_words': 159}