Ejemplo n.º 1
0
    def test_specific_returns_the_instance_in_the_correct_class_type(self):
        shelf = create_test_abstract_shelf()

        expectedContentType = ContentType.objects.get_for_model(shelf.specific)
        self.assertEqual(shelf.content_type, expectedContentType)

        shelf.delete()

        shelf = create_test_promo_shelf()

        expectedContentType = ContentType.objects.get_for_model(shelf.specific)
        self.assertEqual(shelf.content_type, expectedContentType)

        shelf.delete()
Ejemplo n.º 2
0
    def test_initialising_a_sub_class_instance_assigns_the_correct_content_type(
            self):
        abstractShelf = create_test_abstract_shelf('Abstract test id')
        shelf = create_test_promo_shelf()

        expectedContentType = ContentType.objects.get_for_model(shelf)
        notExpectedContentType = ContentType.objects.get_for_model(
            abstractShelf)

        self.assertEqual(shelf.content_type, expectedContentType)
        self.assertNotEqual(shelf.content_type, notExpectedContentType)

        shelf.delete()
        abstractShelf.delete()
Ejemplo n.º 3
0
    def test_page_serializable_data_function_returns_the_full_content_of_shared_shelves(
            self):
        """
        serializable_data is used in the saving of a revision,
        so to check its working correctly we check the content of the revision.
        """
        shelf = create_test_promo_shelf()
        body_content_string = '[{"type": "simple_page_heading_shelf", "value": {"heading": "Heading", "shelf_id":' \
                              ' "1"}, "id": "b2d5e2e8-ae9d-46ef-92e6-27745a85df8c"},{"type": "promo_shelf", "value": ' \
                              + str(shelf.id) + ', "id": "14dd05e9-1d75-4831-a969-01f5c2c82b55"}]'
        page = create_test_page()
        body_field = [
            field for field in page._meta.fields if field.name == 'body'
        ][0]
        page.body = body_field.to_python(body_content_string)

        page.save_revision()
        body_dict = json.loads(
            json.loads(page.get_latest_revision().content_json)['body'])

        self.assertEqual(len(body_dict), 2)
        self.assertIsTrue('content' in body_dict[1])
        self.assertIsTrue('shelf_id' in body_dict[1]['content'])
        self.assertEqual(body_dict[1]['content']['shelf_id'], shelf.shelf_id)
Ejemplo n.º 4
0
    def test_meta_variant_returns_the_correct_value(self):
        shelf = create_test_promo_shelf()

        expected_value = 'how-are-you'

        self.assertEqual(expected_value, shelf.meta_variant)
Ejemplo n.º 5
0
    def test_meta_layout_returns_the_correct_value(self):
        shelf = create_test_promo_shelf()

        expected_value = 'cta_on_right'

        self.assertEqual(expected_value, shelf.meta_layout)