Any chance someone can give me some guidance on what to do here? I just need some advice on where I should start and how. Test this regular expression : ^(?!666|000)(?P<area>[0-8][0-9]{2})[- ]?(?!00)(?P<group>\d{2})[- ]?(?!0000)(?P<serial>\d{4})$ You should test all these cases: - all valid SSNs constructed with - connectors: 001-01-0001, 001-01-0002, ... 899-99-9999 - all invalid SSNs beginning with 666- - all invalid SSN's in the range of 900- to 999- - representative invalid samples equaling 0 in each SSN section: 000-xx-xxxx, xxx-00-xxxx and xxx-xx-0000 You should count and report the number of positive assertions performed. This number should be greater than 98M. Submit your python source file containing the tests. Submit the console output generated when your tests are run (Screen shot or text in a file) You can start with: import reclass SSN:debug = Falsepattern = r"^(?!666|000)(?P<area>[0-8][0-9]{2})[- ]?(?!00)(?P<group>\d{2})[- ]?(?!0000)(?P<serial>\d{4})$"ssn_regex = re.compile(pattern)@staticmethoddef is_valid(number):match = SSN.ssn_regex.match(number)if match == None:return Falsereturn match.group() == number Also, you may want to refer to an example we did in class: import unittestfrom dice_notation import DiceNotationclass TestDiceNotation(unittest.TestCase):    def test_is_valid_3d6(self):        self.assertTrue(DiceNotation.is_valid('3d6'))            def test_is_valid_3d16(self):        self.assertTrue(DiceNotation.is_valid('3d16'))            def test_is_valid_potato(self):        self.assertFalse(DiceNotation.is_valid('potato'))            def test_is_valid_1d6_plus_plus_5(self):        self.assertFalse(DiceNotation.is_valid('1d6++5'))            def test_dice_notation_1d12_div_2_minus_1_roll100(self):        notation = DiceNotation('1d12/2-1')        for _ in range(100):            roll = notation.roll()            self.assertTrue(roll >= -1 and roll <= 5)              if __name__ == '__main__':    unittest.main()

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter14: Exploring Object-based Programming: Designing An Online Poker
Section14.1: Visual Overview: Custom Objects, Properties, And Methods
Problem 7QC
icon
Related questions
Question

Any chance someone can give me some guidance on what to do here? I just need some advice on where I should start and how.

Test this regular expression :

^(?!666|000)(?P<area>[0-8][0-9]{2})[- ]?(?!00)(?P<group>\d{2})[- ]?(?!0000)(?P<serial>\d{4})$
You should test all these cases:
- all valid SSNs constructed with - connectors: 001-01-0001, 001-01-0002, ... 899-99-9999
- all invalid SSNs beginning with 666-
- all invalid SSN's in the range of 900- to 999-
- representative invalid samples equaling 0 in each SSN section: 000-xx-xxxx, xxx-00-xxxx and xxx-xx-0000
You should count and report the number of positive assertions performed. This number should be greater than 98M.
Submit your python source file containing the tests.
Submit the console output generated when your tests are run (Screen shot or text in a file)
You can start with:
import re

class SSN:

debug = False

pattern = r"^(?!666|000)(?P<area>[0-8][0-9]{2})[- ]?(?!00)(?P<group>\d{2})[- ]?(?!0000)(?P<serial>\d{4})$"

ssn_regex = re.compile(pattern)

@staticmethod

def is_valid(number):

match = SSN.ssn_regex.match(number)

if match == None:

return False

return match.group() == number

Also, you may want to refer to an example we did in class:

import unittest
from dice_notation import DiceNotation

class TestDiceNotation(unittest.TestCase):

    def test_is_valid_3d6(self):
        self.assertTrue(DiceNotation.is_valid('3d6'))
        
    def test_is_valid_3d16(self):
        self.assertTrue(DiceNotation.is_valid('3d16'))
        
    def test_is_valid_potato(self):
        self.assertFalse(DiceNotation.is_valid('potato'))
        
    def test_is_valid_1d6_plus_plus_5(self):
        self.assertFalse(DiceNotation.is_valid('1d6++5'))
        
    def test_dice_notation_1d12_div_2_minus_1_roll100(self):
        notation = DiceNotation('1d12/2-1')
        for _ in range(100):
            roll = notation.roll()
            self.assertTrue(roll >= -1 and roll <= 5)
        
      
if __name__ == '__main__':
    unittest.main()

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage