def testCollections(self): req = Requirement() self.assertIsNone(req.collections) req = Requirement(collections={'andrew'}) self.assertEqual(len(req.collections), 1) self.assertEqual(req.collections, {'andrew'})
def testBase(self): r0 = Requirement() r1 = Requirement() r2 = Requirement() req = collections.OrderedDict(a=[r0, r1], b=[r2]) number_requirements(req, 1980) self.assertEqual(r0.label, '1980.1.1') self.assertEqual(r1.label, '1980.1.2') self.assertEqual(r2.label, '1980.2.1')
def testTypes(self): req = Requirement() self.assertIsNone(req.types) req = Requirement(specification=TestSpecification(type='andrew')) self.assertEqual(len(req.types), 1) self.assertEqual(req.types, {'andrew'}) req = Requirement(details=[Detail(specification=TestSpecification(type='andrew')), Detail(specification=TestSpecification(type='1980'))]) self.assertEqual(len(req.types), 2) self.assertEqual(req.types, {'andrew', '1980'})
def testPrerequisites(self): req = Requirement() self.assertEqual(len(req.prerequisites), 0) req = Requirement(specification=TestSpecification(prerequisites={'andrew'})) self.assertEqual(len(req.prerequisites), 1) self.assertEqual(req.prerequisites, {'andrew'}) req = Requirement(details=[Detail(specification=TestSpecification(prerequisites={'andrew'})), Detail(specification=TestSpecification(prerequisites={'1980'}))]) self.assertEqual(len(req.prerequisites), 2) self.assertEqual(req.prerequisites, {'andrew', '1980'})
def testNames(self): req = Requirement() self.assertEqual(len(req.names), 0) req = Requirement(specification=TestSpecification(name='andrew')) self.assertEqual(len(req.names), 1) self.assertEqual(req.names, {'andrew'}) req = Requirement(details=[Detail(specification=TestSpecification(name='andrew')), Detail(specification=TestSpecification(name='1980'))]) self.assertEqual(len(req.names), 2) self.assertEqual(req.names, {'andrew', '1980'})
def testInit(self): kwargs = dict(name='name', path='path', filename='filename', line=1, label='label', requirement='requirement', requirement_line=2, design=['design'], design_line=3, issues=['issues'], issues_line=4, details=['d0', 'd1'], detail='detail', detail_line=5, deprecated=False, deprecated_line=6, duplicate=False, verification=['v0', 'v1'], verification_line=7, validation=['v2', 'v3'], validation_line=8, prerequisites=set(['p0', 'p1']), skip=False, deleted=False) req = Requirement(**kwargs) for key, value in kwargs.items(): attrib = getattr(req, key) self.assertEqual(attrib, value)
def testStr(self): s = str( Requirement(requirement='requirement', design=['design'], issues=['issues'])) self.assertIn("Requirement: requirement", s) self.assertIn("Design: ['design']", s) self.assertIn("Issues: ['issues']", s)
def testTestable(self): req = Requirement() self.assertFalse(req.testable) req.specification = TestSpecification() self.assertTrue(req.testable) req.specification.skip = True self.assertFalse(req.testable) req.specification = None self.assertFalse(req.testable) req.details.append(Detail(specification=TestSpecification())) self.assertTrue(req.testable) req.details[0].specification.skip = True self.assertFalse(req.testable)
def testStr(self): s = str( Requirement(requirement='requirement', design=['design'], issues=['issues'])) self.assertIn("requirement = 'requirement'", s) self.assertIn("design = ['design']", s) self.assertIn("issues = ['issues']", s)
def testTestable(self): req = Requirement() self.assertTrue(req.testable) req = Requirement(skip=True) self.assertFalse(req.testable) req = Requirement(deleted=True) self.assertFalse(req.testable) req = Requirement() req.details = [Requirement()] self.assertTrue(req.testable) req = Requirement() req.details = [Requirement(skip=True)] self.assertFalse(req.testable) req = Requirement() req.details = [Requirement(deleted=True)] self.assertFalse(req.testable)
def testClassification(self): req = Requirement() self.assertIsNone(req.classification) req = Requirement(classification='andrew') self.assertEqual(req.classification, 'andrew')