# Path: chemistry/util.py
# def calculate_tasks(files_id_list, smile, mol_data, models):
#     num = len(files_id_list)
#     num += 1 if smile else 0
#     num += 1 if mol_data else 0
# 
#     #TODO: 计算需要优化
#     for fid in files_id_list:
#         if not fid:
#             continue
# 
#         #根据id，获取前端页面上传的文件model
#         f_record = ProcessedFile.objects.get(fid=fid)
#         if f_record.file_type.lower() in ('smi', 'cas'):
#             num += cnt_batch_file_task(f_record)
# 
#     return num * len(models)


import base64
from django.test import TestCase
from django.contrib.auth.models import User
from mock import Mock, patch
from nose.tools import eq_, ok_
from utils import basic_auth_api
from chemistry.util import calculate_tasks

    def tearDown(self):
        self.user.delete()


class TaskSubmitTest(TestCase):

    smile = "COc1ccccc1NC(=O)CC(=O)C"
    files_id_list = ['ff2da209-7fd5-4fe4-a398-ee4c3a2a6d68',
                     'b56be350-17dd-4bf4-846e-fce7a5a1a299']
    mol_data = None
    models = [{'model': 'koa', 'temperature': '10'},
              {'model': 'pl', 'temperature': '11'}]
    task_name = "test_task"
    task_notes = "test_notes"

    def setUp(self):
        self.user = User.objects.create_user('test1', 'test1@t.com', '123')

    def tearDown(self):
        self.user.delete()

    def test_submit(self):
        pass

    def test_calculate_task(self):
        num = calculate_tasks(self.files_id_list, self.smile,
                              self.mol_data, self.models)
        eq_(num, 6)


# Path: chemistry/util.py
# def calculate_tasks(files_id_list, smile, mol_data, models):
#     num = len(files_id_list)
#     num += 1 if smile else 0
#     num += 1 if mol_data else 0
# 
#     #TODO: 计算需要优化
#     for fid in files_id_list:
#         if not fid:
#             continue
# 
#         #根据id，获取前端页面上传的文件model
#         f_record = ProcessedFile.objects.get(fid=fid)
#         if f_record.file_type.lower() in ('smi', 'cas'):
#             num += cnt_batch_file_task(f_record)
# 
#     return num * len(models)


# Path: chemistry/tests.py
import base64
from django.test import TestCase
from django.contrib.auth.models import User
from mock import Mock, patch
from nose.tools import eq_, ok_
from utils import basic_auth_api
from chemistry.util import calculate_tasks


    def tearDown(self):
        self.user.delete()


class TaskSubmitTest(TestCase):

    smile = "COc1ccccc1NC(=O)CC(=O)C"
    files_id_list = ['ff2da209-7fd5-4fe4-a398-ee4c3a2a6d68',
                     'b56be350-17dd-4bf4-846e-fce7a5a1a299']
    mol_data = None
    models = [{'model': 'koa', 'temperature': '10'},
              {'model': 'pl', 'temperature': '11'}]
    task_name = "test_task"
    task_notes = "test_notes"

    def setUp(self):
        self.user = User.objects.create_user('test1', 'test1@t.com', '123')

    def tearDown(self):
        self.user.delete()

    def test_submit(self):
        pass

    def test_calculate_task(self):
        num = calculate_tasks(self.files_id_list, self.smile,
                              self.mol_data, self.models)
        eq_(num, 6)


        num = calculate_tasks([], self.smile,