def setUp(self): self.fixture = _get_fixture_data()['services'] self.meta = Meta(self.fixture)
class TestMeta(unittest.TestCase): def setUp(self): self.fixture = _get_fixture_data()['services'] self.meta = Meta(self.fixture) def tearDown(self): pass def test_Meta_instance_has_the_correct_attributes(self): self.assertTrue(hasattr(self.meta, 'price')) self.assertTrue(hasattr(self.meta, 'priceCaveats')) self.assertTrue(hasattr(self.meta, 'documents')) self.assertTrue(hasattr(self.meta, 'serviceId')) self.assertTrue(hasattr(self.meta, 'contact')) self.assertIn('name', self.meta.contact) self.assertIn('phone', self.meta.contact) self.assertIn('email', self.meta.contact) def test_contact_information_is_correct(self): self.assertEqual(self.meta.contact['name'], 'Contact name') self.assertEqual(self.meta.contact['phone'], 'Contact number') self.assertEqual(self.meta.contact['email'], 'Contact email') def test_get_service_id_returns_the_correct_information(self): self.assertEqual( self.meta.get_service_id({'id': 1234567890123456}), ['1234', '5678', '9012', '3456'] ) self.assertEqual( self.meta.get_service_id({'id': 123456789012345}), ['1234', '5678', '9012', '345'] ) self.assertEqual( self.meta.get_service_id({'id': '5-G4-1046-001'}), ['5-G4-1046-001'] ) def test_external_framework_url_returns_correct_suffix(self): self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'G-Cloud 7'}), 'http://ccs-agreements.cabinetoffice.gov.uk/contracts/rm1557vii' ) self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'G-Cloud 6'}), 'http://ccs-agreements.cabinetoffice.gov.uk/contracts/rm1557vi' ) self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'None'}), None ) def test_get_documents_returns_the_correct_document_information(self): keys = [ 'pricing', 'sfiaRateDocument', 'serviceDefinitionDocument', 'termsAndConditions' ] expected_information = [ { 'name': 'Pricing', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/123456/1234567890123456-pricing-document.pdf' ) }, { 'name': 'SFIA rate card', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/123456/1234567890123456-sfia-rate-card.pdf' ) }, { 'name': 'Service definition', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/' + '123456/1234567890123456-service-definition-document.pdf' ) }, { 'name': 'Terms and conditions', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/' + '123456/1234567890123456-terms-and-conditions.pdf' ) } ] documents = self.meta.get_documents(self.fixture) for idx, document in enumerate(documents): self.assertEqual( documents[idx]['name'], expected_information[idx]['name'] ) self.assertEqual( documents[idx]['url'], expected_information[idx]['url'] ) self.assertEqual(documents[idx]['extension'], 'pdf') def test_vat_status_is_correct(self): # if VAT is not included price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Excluding VAT', price_caveats) # if VAT is included self.fixture['vatIncluded'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Including VAT', price_caveats) def test_education_pricing_status_is_correct(self): # if Education pricing is included price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Education pricing available', price_caveats) # if Education pricing is excluded self.fixture['educationPricing'] = False price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Education pricing available', price_caveats) def test_termination_costs_status_is_correct(self): # if Termination costs are excluded price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Termination costs apply', price_caveats) # if Termination costs are included self.fixture['terminationCost'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Termination costs apply', price_caveats) # if the question wasn't asked del self.fixture['terminationCost'] price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Termination costs apply', price_caveats) def test_minimum_contract_status_is_correct(self): price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Minimum contract period: Month', price_caveats) def test_options_are_correct_if_both_false(self): price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertNotIn('Free option available', price_caveats) def test_options_are_correct_if_free_is_false_and_trial_true(self): self.fixture['trialOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Free option available', price_caveats) self.assertIn('Trial option available', price_caveats) def test_options_are_correct_if_free_is_true_and_trial_false(self): self.fixture['freeOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertIn('Free option available', price_caveats) def test_options_are_correct_if_free_is_true_and_trial_false(self): self.fixture['freeOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertIn('Free option available', price_caveats) def test_options_are_correct_if_both_are_not_set(self): del self.fixture['freeOption'] del self.fixture['trialOption'] price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertNotIn('Free option available', price_caveats)
class TestMeta(unittest.TestCase): def setUp(self): self.fixture = _get_fixture_data()['services'] self.meta = Meta(self.fixture) def tearDown(self): pass def test_Meta_instance_has_the_correct_attributes(self): self.assertTrue(hasattr(self.meta, 'price')) self.assertTrue(hasattr(self.meta, 'priceCaveats')) self.assertTrue(hasattr(self.meta, 'documents')) self.assertTrue(hasattr(self.meta, 'serviceId')) self.assertTrue(hasattr(self.meta, 'contact')) self.assertIn('name', self.meta.contact) self.assertIn('phone', self.meta.contact) self.assertIn('email', self.meta.contact) def test_contact_information_is_correct(self): self.assertEqual(self.meta.contact['name'], 'Contact name') self.assertEqual(self.meta.contact['phone'], 'Contact number') self.assertEqual(self.meta.contact['email'], 'Contact email') def test_get_service_id_returns_the_correct_information(self): self.assertEqual( self.meta.get_service_id({'id': 1234567890123456}), ['1234', '5678', '9012', '3456'] ) self.assertEqual( self.meta.get_service_id({'id': '5-G4-1046-001'}), ['5-G4-1046-001'] ) def test_external_framework_url_returns_correct_suffix(self): self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'G-Cloud 7'}), 'http://ccs-agreements.cabinetoffice.gov.uk/contracts/rm1557vii' ) self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'G-Cloud 6'}), 'http://ccs-agreements.cabinetoffice.gov.uk/contracts/rm1557vi' ) self.assertEqual( self.meta.get_external_framework_url({'frameworkName': 'None'}), 'http://ccs-agreements.cabinetoffice.gov.uk/contracts/' ) def test_get_documents_returns_the_correct_document_information(self): keys = [ 'pricing', 'sfiaRateDocument', 'serviceDefinitionDocument', 'termsAndConditions' ] expected_information = [ { 'name': 'Pricing', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/123456/1234567890123456-pricing-document.pdf' ) }, { 'name': 'SFIA rate card', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/123456/1234567890123456-sfia-rate-card.pdf' ) }, { 'name': 'Service definition', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/' + '123456/1234567890123456-service-definition-document.pdf' ) }, { 'name': 'Terms and conditions', 'url': ( 'https://assets.digitalmarketplace.service.gov.uk/' + 'documents/' + '123456/1234567890123456-terms-and-conditions.pdf' ) } ] documents = self.meta.get_documents(self.fixture) for idx, document in enumerate(documents): self.assertEqual( documents[idx]['name'], expected_information[idx]['name'] ) self.assertEqual( documents[idx]['url'], expected_information[idx]['url'] ) self.assertEqual(documents[idx]['extension'], 'pdf') def test_vat_status_is_correct(self): # if VAT is not included price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Excluding VAT', price_caveats) # if VAT is included self.fixture['vatIncluded'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Including VAT', price_caveats) def test_education_pricing_status_is_correct(self): # if Education pricing is included price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Education pricing available', price_caveats) # if Education pricing is excluded self.fixture['educationPricing'] = False price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Education pricing available', price_caveats) def test_termination_costs_status_is_correct(self): # if Termination costs are excluded price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Termination costs apply', price_caveats) # if Termination costs are included self.fixture['terminationCost'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Termination costs apply', price_caveats) # if the question wasn't asked del self.fixture['terminationCost'] price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Termination costs apply', price_caveats) def test_minimum_contract_status_is_correct(self): price_caveats = self.meta.get_price_caveats(self.fixture) self.assertIn('Minimum contract period: Month', price_caveats) def test_options_are_correct_if_both_false(self): price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertNotIn('Free option available', price_caveats) def test_options_are_correct_if_free_is_false_and_trial_true(self): self.fixture['trialOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Free option available', price_caveats) self.assertIn('Trial option available', price_caveats) def test_options_are_correct_if_free_is_true_and_trial_false(self): self.fixture['freeOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertIn('Free option available', price_caveats) def test_options_are_correct_if_free_is_true_and_trial_false(self): self.fixture['freeOption'] = True price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertIn('Free option available', price_caveats) def test_options_are_correct_if_both_are_not_set(self): del self.fixture['freeOption'] del self.fixture['trialOption'] price_caveats = self.meta.get_price_caveats(self.fixture) self.assertNotIn('Trial and free options available', price_caveats) self.assertNotIn('Trial option available', price_caveats) self.assertNotIn('Free option available', price_caveats)