import pytest

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api.api.settings")

import django
from django.test import TestCase
from scrapi.processing.postgres import PostgresProcessor, Document

from . import utils
from scrapi.linter.document import RawDocument

django.setup()

test_db = PostgresProcessor()

# NORMALIZED = NormalizedDocument(utils.RECORD)
RAW = RawDocument(utils.POSTGRES_RAW_DOC)


class DocumentTestCase(TestCase):

    @pytest.mark.django_db
    def test_raw_processing(self):
        test_db.process_raw(RAW)
        queryset = Document(docID='someID', source=RAW['source'])
        assert queryset.docID == RAW.attributes['docID']

@@ -1,12 +1,14 @@
+# 
 import pytes
@@ -270,16 +270,36 @@
 Document
+, NormalizedDocument
 %0A%0Adjango
@@ -343,96 +343,94 @@
 ()%0A%0A
-# NORMALIZED = NormalizedDocument(utils.RECORD)%0ARAW = RawDocument(utils.POSTGRES_RAW_DOC
+RAW = RawDocument(utils.POSTGRES_RAW_DOC)%0ANORMALIZED = NormalizedDocument(utils.RECORD
 )%0A%0A%0A
@@ -468,35 +468,8 @@
 ):%0A%0A
-    @pytest.mark.django_db%0A
     
@@ -655,8 +655,248 @@
 docID'%5D%0A
+%0A    def test_normalized_processing(self):%0A        test_db.process_normalized(RAW, NORMALIZED)%0A        queryset = Document(docID=RAW%5B'docID'%5D, source=RAW%5B'source'%5D)%0A        assert(queryset.source == NORMALIZED%5B'shareProperties'%5D%5B'source'%5D)%0A

Add test for process normalized