Exemplo n.º 1
0
 def test_empties(self):
     profile = new_profile()
     expected = [['links', 'item', 0],
                 ['version'], ['attributes', 'contentencoded'],
                 ['attributes', 'contenttemplated'],
                 ['attributes', 'description'], ['attributes', 'tags', 0],
                 ['attributes', 'published'],
                 ['attributes', 'teaser'],
                 ['attributes', 'byline']]
     for empty_path in empty_values(profile):
         self.assertIn(empty_path, expected)
Exemplo n.º 2
0
 def test_new_profile(self):
     profile = new_profile()
     self.assertIn('links', profile)
     self.assertIn('attributes', profile)
     self.assertIn('version', profile)
     self.assertNotIn('collection',  profile['links'])
     self.assertNotIn('REQUIRED', profile)
     self.assertNotIn('OPTIONAL', profile)
     self.assertIn('title', profile['attributes'])
     self.assertIn('byline', profile['attributes'])
     self.assertIn('guid', profile['attributes'])
Exemplo n.º 3
0
    def test_validate_fail_incorrect_value_type(self):
        profile = new_profile()
        for path in find_value(profile, 'REQUIRED_VALUE'):
            set_nested_value(profile, path, 'Fixed!')

        # Clobber list with new dictionary
        test_copy = copy.deepcopy(profile)
        test_copy['links']['alternate'] = {'WRONG': 'Bad Value'}
        self.assertFalse(validate(test_copy)[0])

        # Clobber list with string
        test_copy = copy.deepcopy(profile)
        set_nested_value(test_copy, ['links', 'item'], 'Bad Value')
        self.assertFalse(validate(test_copy)[0])

        # Clobber string with new dictionary
        test_copy = copy.deepcopy(profile)
        test_copy['attributes']['guid'] = [{'new Key': 'Bad Value'}]
        self.assertFalse(validate(test_copy)[0])
Exemplo n.º 4
0
 def test_validate_fail_missing_required(self):
     profile = new_profile()
     self.assertFalse(validate(profile))
Exemplo n.º 5
0
 def test_validate_pass(self):
     profile = new_profile()
     for path in find_value(profile, 'REQUIRED_VALUE'):
         set_nested_value(profile, path, 'Fixed!')
     self.assertTrue(validate(profile))
Exemplo n.º 6
0
 def test_edit_profile(self):
     profile = new_profile()
     test_item = self.datadoc.items[1]
     new_data = edit_profile(profile, test_item)
     self.assertEqual(new_data['attributes']['contentencoded'],
                      test_item['attributes']['contentencoded'])
Exemplo n.º 7
0
 def test_new_profile_with_collection(self):
     collection_url = "http://SOMECOLLECTION"
     profile = new_profile(collection=collection_url)
     self.assertIn('collection', profile['links'])
     self.assertEqual(profile['links']['collection'][0]['href'],
                      collection_url)