import unittest
import logging
from gdcdatamodel.mappings import (
    get_file_es_mapping,
    get_participant_es_mapping,
    get_annotation_es_mapping,
    get_project_es_mapping
)


logging.basicConfig(level=logging.INFO)


class TestElasticsearchMappings(unittest.TestCase):

    def test_file_mapping_import(self):
        get_file_es_mapping()

    def test_participant_mapping_import(self):
        get_participant_es_mapping()

    def test_project_mapping_import(self):
        get_project_es_mapping()

    def test_annotation_mapping_import(self):
        get_annotation_es_mapping()

    def test_file_mapping_top_level(self):
        m = get_file_es_mapping()['properties']
        properties = {'file_name', 'submitter_id', 'related_archives',
                      'file_size', 'state', 'access', 'platform',
                      'participants', 'data_subtype', 'archives',
                      'annotations', 'experimental_strategy', 'data_type',
                      'tags', 'uploaded_datetime', 'file_id', 'related_files',
                      'state_comment', 'published_datetime', 'center',
                      'md5sum', 'data_format', 'acl', 'associated_entities'}
        self.assertEqual(properties, set(m.keys()))

    def test_participant_mapping_top_level(self):
        m = get_participant_es_mapping()['properties']
        properties = {'files', 'annotations', 'days_to_index', 'submitter_id',
                      'project', 'clinical', 'metadata_files', 'samples',
                      'participant_id', 'summary', 'tissue_source_site'}
        self.assertEqual(properties, set(m.keys()))

    def test_project_mapping_top_level(self):
        m = get_project_es_mapping()['properties']
        properties = {'code', 'name', 'summary', 'state', 'program',
                      'primary_site', 'project_id', 'disease_type'}
        self.assertEqual(properties, set(m.keys()))

    def test_annotation_mapping_top_level(self):
        m = get_annotation_es_mapping()['properties']
        properties = {'category', 'status', 'classification', 'creator',
                      'created_datetime', 'notes', 'submitter_id', 'project',
                      'item_type', 'item_id', 'annotation_id'}
        self.assertEqual(properties, set(m.keys()))

@@ -737,24 +737,17 @@
 ', '
-related_archives
+file_size
 ',%0A 
@@ -766,29 +766,16 @@
         
- 'file_size',
  'state'
@@ -797,18 +797,33 @@
 atform',
-%0A
  
+'participants',%0A
         
@@ -835,31 +835,16 @@
         
-'participants',
  'data_s
@@ -860,16 +860,30 @@
 'archive
+', 'annotation
 s',%0A    
@@ -899,31 +899,16 @@
         
- 'annotations',
  'experi
@@ -937,16 +937,24 @@
 a_type',
+ 'tags',
 %0A       
@@ -967,24 +967,16 @@
         
- 'tags',
  'upload
@@ -1141,16 +1141,38 @@
 , 'acl',
+%0A                     
  'associ

update tests